var PopUpWindow = {};

PopUpWindow.PopUp = function (PopUpTitle, Image, sWidth, sHeight, bPrint, PrintButton, PrintStyle , bClose , CloseButton, CloseStyle){
	var winl = (screen.width-sWidth)/2;
	var wint = (screen.height-sHeight)/2;			
	win3 = window.open('','win3','width='+sWidth+',height='+sHeight+',top='+ wint+ ',left='+ winl+ 'scrollbars=auto');
		
	if(bPrint == true){	   
	    sPrintMouseOver = "this.style.cursor='pointer';this.title='отпечатай';";
	    sPrintMouseOver += "this.src='"+ ( PrintButton.substr(0,(PrintButton.length - 4 )) ) +"2."+ (PrintButton.substr(PrintButton.length- 3, PrintButton.length) ) +"';";
	    sPrintMouseOut="this.style.cursor='arrow';";	    
	    sPrintMouseOut += "this.src='"+PrintButton+"';";
	    sPrint = "<div style=\""+PrintStyle+"; width:150px;float:left\"><img id='PrintButton' src='"+PrintButton+"' border=0 onmouseover=\""+sPrintMouseOver+"\" onmouseout=\""+sPrintMouseOut+"\" onclick=\"PopUpWindow.PrintWindowContent();\"></div>";
	}else{
	    sPrint = "";
	}
	
	
	if(bClose == true){	   
	    sCloseMouseOver = "this.style.cursor='pointer';this.title='затвори';";
	    sCloseMouseOver += "this.src='"+ ( CloseButton.substr(0,(CloseButton.length - 4 )) ) +"2."+ (CloseButton.substr(CloseButton.length- 3, CloseButton.length) ) +"';";
	    sCloseMouseOut="this.style.cursor='arrow';";	    
	    sCloseMouseOut += "this.src='"+CloseButton+"';";
	    sClose = "<div style=\""+CloseStyle+"; width:150px;float:right\"><img id='PrintButton' src='"+CloseButton+"' border=0 onmouseover=\""+sCloseMouseOver+"\" onmouseout=\""+sCloseMouseOut+"\" onclick=\"window.close()\"></div>";
	}else{
	    sClose = "";
	}	
	sFooter = "<div id=\"DisplayFooter\" style=\"margin-top:20px;margin-bottom:20px;visibility:visible;\">"+sPrint+sClose+"</div>"
	
	sBase = window.parent.document.getElementsByTagName('base').item(0).href;
	
	sHeadContent = '<title>'+PopUpTitle+'</title>';
	sHeadScript = '<base href="'+sBase+'"></base><script type="text/javascript" src="ApplicationFiles/Script/PopUpWindow.js"></script>';
	sHeadStyle = '<style>@media print{ #DisplayFooter{display:none;}} @media screen {#DisplayFooter{display:block;}}</style>';
	sHead = '<head>'+sHeadContent+sHeadScript+sHeadStyle+'</head>';
	
	sContent = '<div style=\"position:relative\" title=\"'+PopUpTitle+'\"><img id=\"ImageContainer\" src=\"'+Image+'\" border=0 alt=\"'+PopUpTitle+'\"></div>'+sFooter;
	sStyle = 'style=\"margin:0px; text-align:center\" ';
	sBody = '<body '+sStyle+'>'+sContent+'</body>';
	
	sHtml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'+sHead+sBody+'</html>';								
	win3.document.writeln(sHtml); 
}

PopUpWindow.PrintWindowContent = function(){   
  window.location.reload(); 
  window.print();
}

