﻿function winOpen(URL,hght,wdth)	{
			hght = (hght < 1) ? Math.round(window.screen.height*hght) : hght;
			wdth = (wdth < 1) ? Math.round(window.screen.width*wdth) : wdth;
			var x=Math.round((window.screen.width-wdth)/2); x = (x < 0) ? 0 : x;
			var y=Math.round((window.screen.height-hght)/2); y = (y < 0) ? 0 : y-20;
			eval("popup=window.open('"+URL+"','popup','height="+hght+",width="+wdth+",toolbar=no,status=no,directories=no,location=no,scrollbars=no,menubar=no,resizable=no,top=" + y + ",left=" + x + "');");
			if (!popup.opener) popup.opener = self;
			popup.focus();
		}

function openModalWindow(datastart, datavars, dialogWidth, dialogHeight, noRestrict){
		if (noRestrict == null) noRestrict = false;
		
		var dataPage=datastart+datavars;

		winbinary = null;
		var restrict = "";
		
		if (noRestrict == false) restrict = "resizable=no,";
		else restrict = "resizable=yes,";
		if (screen.availWidth < dialogWidth) dialogWidth = screen.availWidth;
		if (screen.availHeight < dialogHeight) dialogHeight = screen.availHeight;
		var dialogTop=(screen.availHeight/2)-(dialogHeight/2);
		var dialogLeft=(screen.availWidth/2)-(dialogWidth/2);
		winbinary = window.open(dataPage,'winbinary', restrict + 'menubar=no,toolbar=no,scrollbars=yes,status=yes,width=450,height=300,left=' + dialogLeft + ',top=' + dialogTop);
		window.onfocus = function(){
			if(winbinary != null && !winbinary.closed){
				winbinary.focus();
				return false;
			}
		};
}

function closeModalWin(){
	if(winbinary != null && !winbinary.closed){
		winbinary.close();
	}
}

function makeWinModal(){
	if(winbinary != null && !winbinary.closed){
		winbinary.focus();
		return false;
	}
}


