function PopUpWindow( url )
{ 
	window.open( url, null, "width=700,height=580,location=no,menubar=no,scrollbars=no,toolbar=no,resizable=yes", "true"); 
}

function PopUpPrintWindow(  )
{
	var argv = PopUpPrintWindow.arguments;	
	var argc = argv.length;
	
	if ( (argc == 0) || (argc != 1 && (((argc - 1) % 2) != 0)) )
	{
		alert('PopUpPrintWindow( page [ , parametername1, parametervalue1 [ , ... ] ] )');
		return;
	}
	
	var link = "/Print/Print.aspx?Page=" + argv[0];
	
	for (var i = 1; i < argc; i += 2)
		link += "&" + argv[i] + "=" + argv[i + 1];
    PopUpWindow( link );
}

//**************************PopUp Image*************************

function PopUpImageCenter(imageURL, imageTitle, autoClose)
{
		var xposition = (screen.width - 200) / 2;
		var yposition = (screen.height - 200) / 2;
		
		var args =  "width=" + 200 + "," 
    			+ "height=" + 200 + "," 
				+ "location=0," 
				+ "menubar=" + 0 + ","
				+ "resizable="+ 1 +","
				+ "scrollbars=" + 0 + ","
				+ "status=" + 0 + "," 
				+ "titlebar=" + 0 + ","
				+ "toolbar=" +  0 + ","
				+ "hotkeys=0,"
				+ "screenx=" + xposition + ","  //NN Only
				+ "screeny=" + yposition + ","  //NN Only
				+ "left=" + xposition + ","     //IE Only
				+ "top=" + yposition;           //IE Only

				PopUpImage(imageURL, imageTitle, args, true);
}

function PopUpImage(imageURL, imageTitle, args, autoClose)
{
	var imgWin = window.open('','_blank', args);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
	    'var NS = (navigator.appName=="Netscape")?true:false;\n' +
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		//for popup to fit in the screen and img in the popup
		'var mH = screen.availHeight-130, mW = screen.availWidth-40;\n'+
        'if( oH > mH || oW > mW ) {\n'+
        'mH = mH \/ oH; mW = mW \/ oW;\n'+
        'var zoomFactor = ( mH < mW ) ? mH : mW;\n'+
        'oH = Math.floor( oH * zoomFactor );\n'+
        'oW = Math.floor( oW * zoomFactor );\n'+
        'document.images[0].height = oH;\n'+
        'document.images[0].width = oW;\n'+
        '}\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { window.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'iWidth = (NS)?window.innerWidth:document.body.clientWidth;' +
        'iHeight = (NS)?window.innerHeight:document.body.clientHeight;' +
        'iWidth = oW - iWidth;' +
        'iHeight = oH - iHeight;' +
        'window.resizeBy(iWidth, iHeight);' +
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(autoClose?' onblur="self.close();"':'')+
		'style="padding:0 0 0 0;margin:0 0 0 0;"' + '>'+
		//img preLoad recomended !!!
		'<div style="position:static; width:100%;height:100%;background:white url(/admin/images/spinner.gif) no-repeat center center;">' +
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<img src="'+imageURL+'" alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+
         '<\/div>'   +
        '<\/body><\/html>'
        );
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

function OnInfoPrint(InfoURL, AdditionalUrlParam)
{
	OnDescription("/Print/Print.aspx?Page=" + InfoURL + "&" + AdditionalUrlParam);
}

function OnDescription( url )
{ 
	h = 700;
	w = 700;
	if (screen) {
		leftPos = screen.width/2-w/2
		topPos = screen.height/2-h/2
	}
	photoWin =  window.open( url, null, "width="+w+",height="+h+",top="+topPos+",left="+leftPos+",location=no,menubar=no,scrollbars=no,toolbar=no,resizable=no", "true"); 
	photoWin.focus();
}