//// VERSIONE 2.0 PROGETTO IDEAZIONE
// Wushu
/////////////////////////////////////////////////////////////////////////
//                                                                     //
//   (c) by josé marín  | www.mediopixel.com  | www.lolailonline.com   //
//            for                                                      //
//       chromeles.org                                                 //	ARCOSALD
/////////////////////////////////////////////////////////////////////////

function NewWindow(mypage, myname, w, h, scroll) {
/*
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2 - 25;
*/
	var winl = 40;
	var wint = 40;

	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//--- APRE LA FINESTRA CHROMELESS ---------------------------------------------------------
function openChromeless(url,winTitle,width,height,scrollbars) {
	NewWindow(url, 'zoom', width, height, scrollbars);
/*	features = 'width=100,height=100';
	winName = 'zoom';
	(width||height!=null)?openwin(url,winTitle,width,height,scrollbars,botClose,botClose_on,botMinimize,botMinimize_on,topBorder,botBorder,rightBorder,leftBorder,borderColor,borderColorOn,backGroundImage,titleImage,titleFontFamily,fontStyle,titleFontSize,titleFontColor,titleFontWeight,titleAlign,centered,xPos,yPos):window.open(url,winName,features);
*/
}

function openwin(path,winTitle,width,height,scrollbars,botClose,botClose_on,botMinimize,botMinimize_on,topBorder,botBorder,rightBorder,leftBorder,borderColor,borderColorOn,backGroundImage,titleImage,titleFontFamily,fontStyle,titleFontSize,titleFontColor,titleFontWeight,titleAlign,centered,xPos,yPos)
{
	var navVersion      = window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE") + 5,window.navigator.appVersion.indexOf ("MSIE") + 8);
    var navPlatformWin  = window.navigator.platform.indexOf("Win32");
	var navName         = window.navigator.appName;
	var chromelessVersion = 0;

	if(navName=="Microsoft Internet Explorer" && navPlatformWin>=0)  /// Define ChromelessVersion
	{
		if (navVersion >= 4.0)
		{
			chromelessVersion = 1;
			if (navVersion >= 5.5)
			{
			chromelessVersion = 1;
			var spVersion = window.navigator.appMinorVersion.indexOf(";SP");
			if (navVersion >= 6.0 && spVersion>=0)
				{
				var chromelessVersion = 2;
				}
			}
		}
	}
	
	var w = leftBorder+width+rightBorder;
	var h = topBorder+height+botBorder;
	
	if((scrollbars!=null)||((width||height)!=null)){w = leftBorder+width+rightBorder;h = topBorder+height+botBorder;}
	
	if(centered=="yes"){myXpos=(screen.width-w)/2;myYpos=(screen.height-h)/2}else{myXpos=xPos;myYpos=yPos}
	
	if(chromelessVersion == 0)
	{
	win = window.open(path, "popwin", "left="+myXpos+",top="+myYpos+",width="+width+",height="+height+",toolbar=0,scrollbars="+scrollbars+",resizable=yes");
	win.close();
	win = window.open(path, "popwin", "left="+myXpos+",top="+myYpos+",width="+width+",height="+height+",toolbar=0,scrollbars="+scrollbars+",resizable=yes");
	win.focus();
	}
	else
	{
	
	if(titleAlign=="bottom"){align=(h-20)}else{align=3}
	if(titleImage!=""){titleContent='<img src='+titleImage+'>'}else{titleContent=winTitle}
	
	if(chromelessVersion == 1)
	{
	suportPopup=0;
	hiddenShowDiv="hidden";
	myIframe="show";
	win=window.open("","",'fullscreen');
	win.resizeTo(w,h);
	win.moveTo(myXpos,myYpos);
	}
	
	if(chromelessVersion == 2)
	{
	var suportPopup=1;
	var hiddenShowDiv="show";
	var myIframe="hidden";
	
	var win=window.open("","popwin",'width=100,height=100,scrollbars='+scrollbars+',left=3000,top=3000');
	win.close();
	var win=window.open("","popwin",'width=100,height=100,scrollbars='+scrollbars+',left=3000,top=3000');
	}
	
	var secondChromelessCode=''+
	'<html><head><title>'+winTitle+'</title>'+
	'<script language="JavaScript" type="text/javascript"\>'+
	'iev='+suportPopup+';'+
	'g=1;'+
	'x='+myXpos+';'+
	'y='+myYpos+';'+
	'if(iev)'+
	'{'+
	'popup = window.createPopup();'+
	'}'+
	'popupCode =\'\'+'+
	'\'<html><head><title></title>\'+'+
	'\'<script language=\"JavaScript\" type=\"text/javascript\"\>\'+'+
	'\'iev='+suportPopup+';\'+'+
	'\'myX = \'+x+\';\'+'+
	'\'myY= \'+y+\';\'+'+
	'\'document.onselectstart=new Function(\"return false;\");\'+'+
	'\'document.ondragstart=new Function(\"return false;\");\'+'+
	'\'document.oncontextmenu=new Function(\"return false;\");\'+'+
	'\'document.onmousemove=move;\'+'+
	'\'estatus=\"up\";\'+'+
	'\'function move()\'+'+
	'\'{\'+'+
	'\'if(estatus==\"down\")\'+'+
	'\'{\'+'+
	'\'x=event.x;\'+'+
	'\'y=event.y;\'+'+
	'\'estatus=\"drag\";\'+'+
	'\'}\'+'+
	'\'else if(estatus==\"drag\")\'+'+
	'\'{\'+'+
	'\'myX=(event.screenX-x);\'+'+
	'\'myY=(event.screenY-y);\'+'+
	'\'if(iev)\'+'+
	'\'{\'+'+
	'\'parent.popup.show(myX,myY,'+w+','+h+');\'+'+
	'\'}\'+'+
	'\'else\'+'+
	'\'{\'+'+
	'\'self.moveTo(myX,myY,'+w+','+h+');\'+'+
	'\'}\'+'+
	'\'}\'+'+
	'\'else\'+'+
	'\'{\'+'+
	'\'top.window.x=myX;\'+'+
	'\'top.window.y=myY;\'+'+
	'\'estatus=\"up\";\'+'+
	'\'}\'+'+
	'\'}\'+'+
	'\'</script\\>\'+'+
	'\'<style type=\"text/css\">\'+'+
	'\'BODY{border:0px;}\'+'+
	'\'#pages{position:absolute;left:'+leftBorder+'px; top:'+topBorder+'px;visibility:'+hiddenShowDiv+';width:'+width+'px;height:'+(height+1)+'px;z-index:4;}\'+'+
	'\'#myIframe{position:absolute;left:'+leftBorder+'px; top:'+topBorder+'px;visibility:'+myIframe+';width:'+width+'px;height:'+(height+1)+'px;z-index:4;}\'+'+
	'\'#clos{position:absolute;left:'+(w-20)+'px;top:'+align+'px;width:14;height:14;border:0px;z-index:3;}\'+'+
	'\'#min{position:absolute;left:'+(w-38)+'px;top:'+align+'px;visibility:'+hiddenShowDiv+';width:14;height:14;border:0px;z-index:3;}\'+'+
	'\'#windowDrag{position:absolute;left:0px; top:0px; width:100%;height:100%;z-index:2;}\'+'+
	'\'#title{font-family:'+titleFontFamily+';font-style:'+fontStyle+';font-weight:'+titleFontWeight+';font-size:'+titleFontSize+'pt;color:'+titleFontColor+';position:absolute;left:8px; top:'+align+'px; width:550px;height:20px;z-index:1;}\'+'+
	'\'#backgroundImage{position:absolute;left:0px; top:0px; width:100%; background-image:url('+backGroundImage+');height:100%;z-index:0;}\'+'+
	'\'</style>\'+'+
	'\'</head>\'+'+
	'\'<body leftmargin=\"0\" bgcolor=\"'+borderColor+'\" topmargin=\"0\" scroll=\"no\">\'+'+
	'\'<div id=title>'+titleContent+'</div>\'+'+
	'\'<img id=clos src=\"'+botClose+'\" onmouseover=\"this.src=\\\''+botClose_on+'\\\'\" onmouseout=\"this.src=\\\''+botClose+'\\\'\" onclick=\"javascript:parent.window.close();\" />\'+'+
	'\'<img id=min src=\"'+botMinimize+'\" onmouseover=\"this.src=\\\''+botMinimize_on+'\\\'\" onmouseout=\"this.src=\\\''+botMinimize+'\\\'\" onmousedown=\"this.src=\\\''+botMinimize+'\\\'\;javascript:parent.popup.hide();\" />\'+'+
	'\'<img id=windowDrag onmousedown=\"estatus=\\\'down\\\';move();backgroundImage.style.backgroundColor=\\\''+borderColorOn+'\\\'" onmouseup=\"estatus=\\\'up\\\';move();backgroundImage.style.backgroundColor=\\\''+borderColor+'\\\'\" src=\"../js/img/shim.gif\" />\'+'+
	'\'<object type=text/html data=\"'+path+'\" id=pages></object\><iframe frameborder=0 src=\"'+path+'\" id=myIframe></iframe\>\'+'+
	'\'<div id=backgroundImage></div>\'+'+
	'\'</body>\'+'+
	'\'</html>\';'+
	'function showPopup()'+
	'{'+
	'if(iev)'+
	'{'+
	'popup.show(x,y,'+w+','+h+');'+
	'if(g)'+
	'{'+
	'popup.document.open();'+
	'popup.document.write(popupCode);'+
	'popup.document.close();'+
	'g=0;'+
	'}'+
	'}else{'+
	'document.open();'+
	'document.write(popupCode);'+
	'document.close();'+
	'}'+
	'}'+
	'onfocus = function(){if(g){showPopup();}else{showPopup();if(top.opener&&!top.opener.closed){top.opener.window.focus()};top.window.blur()}}'+
	'</script\>'+
	'</head>'+
	'<body>'+
	'</body>'+
	'</html>';

	function secondChromeless(){
	suportPopup=0;
	hiddenShowDiv="hidden";
	myIframe="show";
	win2=window.open("","popwin",'fullscreen');
	win2.resizeTo(w,h);
	win2.document.open();
	win2.document.write(secondChromelessCode);
	win2.document.close();
	win2.focus();
	}

	var parentCode=''+
	'<html><head><title>'+winTitle+'</title>'+
	'<script language="JavaScript" type="text/javascript"\>'+
	'iev='+suportPopup+';'+
	'g=1;'+
	'x='+myXpos+';'+
	'y='+myYpos+';'+
	'if(iev)'+
	'{'+
	'popup = window.createPopup();'+
	'}'+
	'popupCode =\'\'+'+
	'\'<html><head><title></title>\'+'+
	'\'<script language=\"JavaScript\" type=\"text/javascript\"\>\'+'+
	'\'iev='+suportPopup+';\'+'+
	'\'myX = \'+x+\';\'+'+
	'\'myY= \'+y+\';\'+'+
	'\'document.onselectstart=new Function(\"return false;\");\'+'+
	'\'document.ondragstart=new Function(\"return false;\");\'+'+
	'\'document.oncontextmenu=new Function(\"return false;\");\'+'+
	'\'document.onmousemove=move;\'+'+
	'\'estatus=\"up\";\'+'+
	'\'function move()\'+'+
	'\'{\'+'+
	'\'if(estatus==\"down\")\'+'+
	'\'{\'+'+
	'\'x=event.x;\'+'+
	'\'y=event.y;\'+'+
	'\'estatus=\"drag\";\'+'+
	'\'}\'+'+
	'\'else if(estatus==\"drag\")\'+'+
	'\'{\'+'+
	'\'myX=(event.screenX-x);\'+'+
	'\'myY=(event.screenY-y);\'+'+
	'\'if(iev)\'+'+
	'\'{\'+'+
	'\'parent.popup.show(myX,myY,'+w+','+h+');\'+'+
	'\'}\'+'+
	'\'else\'+'+
	'\'{\'+'+
	'\'self.moveTo(myX,myY,'+w+','+h+');\'+'+
	'\'}\'+'+
	'\'}\'+'+
	'\'else\'+'+
	'\'{\'+'+
	'\'top.window.x=myX;\'+'+
	'\'top.window.y=myY;\'+'+
	'\'estatus=\"up\";\'+'+
	'\'}\'+'+
	'\'}\'+'+
	'\'</script\\>\'+'+
	'\'<style type=\"text/css\">\'+'+
	'\'BODY{border:0px;}\'+'+
	'\'#pages{position:absolute;left:'+leftBorder+'px; top:'+topBorder+'px;visibility:'+hiddenShowDiv+';width:'+width+'px;height:'+(height+1)+'px;z-index:4;}\'+'+
	'\'#myIframe{position:absolute;left:'+leftBorder+'px; top:'+topBorder+'px;visibility:'+myIframe+';width:'+width+'px;height:'+(height+1)+'px;z-index:4;}\'+'+
	'\'#clos{position:absolute;left:'+(w-20)+'px;top:'+align+'px;width:14;height:14;border:0px;z-index:3;}\'+'+
	'\'#min{position:absolute;left:'+(w-38)+'px;top:'+align+'px;visibility:'+hiddenShowDiv+';width:14;height:14;border:0px;z-index:3;}\'+'+
	'\'#windowDrag{position:absolute;left:0px; top:0px; width:100%;height:100%;z-index:2;}\'+'+
	'\'#title{font-family:'+titleFontFamily+';font-style:'+fontStyle+';font-weight:'+titleFontWeight+';font-size:'+titleFontSize+'pt;color:'+titleFontColor+';position:absolute;left:8px; top:'+align+'px; width:550px;height:20px;z-index:1;}\'+'+
	'\'#backgroundImage{position:absolute;left:0px; top:0px; width:100%; background-image:url('+backGroundImage+');height:100%;z-index:0;}\'+'+
	'\'</style>\'+'+
	'\'</head>\'+'+
	'\'<body leftmargin=\"0\" bgcolor=\"'+borderColor+'\" topmargin=\"0\" scroll=\"no\" onUnload=\"if('+chromelessVersion+' == 1){'+secondChromeless()+';}\">\'+'+
	'\'<div id=title>'+titleContent+'</div>\'+'+
	'\'<img id=clos src=\"'+botClose+'\" onmouseover=\"this.src=\\\''+botClose_on+'\\\'\" onmouseout=\"this.src=\\\''+botClose+'\\\'\" onclick=\"javascript:parent.window.close();\" />\'+'+
	'\'<img id=min src=\"'+botMinimize+'\" onmouseover=\"this.src=\\\''+botMinimize_on+'\\\'\" onmouseout=\"this.src=\\\''+botMinimize+'\\\'\" onmousedown=\"this.src=\\\''+botMinimize+'\\\'\;javascript:parent.popup.hide();\" />\'+'+
	'\'<img id=windowDrag onmousedown=\"estatus=\\\'down\\\';move();backgroundImage.style.backgroundColor=\\\''+borderColorOn+'\\\'" onmouseup=\"estatus=\\\'up\\\';move();backgroundImage.style.backgroundColor=\\\''+borderColor+'\\\'\" src=\"../js/img/shim.gif\" />\'+'+
	'\'<object type=text/html data=\"'+path+'\" id=pages></object\><iframe frameborder=0 src=\"'+path+'\" id=myIframe></iframe\>\'+'+
	'\'<div id=backgroundImage></div>\'+'+
	'\'</body>\'+'+
	'\'</html>\';'+
	'function showPopup()'+
	'{'+
	'if(iev)'+
	'{'+
	'popup.show(x,y,'+w+','+h+');'+
	'if(g)'+
	'{'+
	'popup.document.open();'+
	'popup.document.write(popupCode);'+
	'popup.document.close();'+
	'g=0;'+
	'}'+
	'}else{'+
	'document.open();'+
	'document.write(popupCode);'+
	'document.close();'+
	'}'+
	'}'+
	'onfocus = function(){if(g){showPopup();}else{showPopup();if(top.opener&&!top.opener.closed){top.opener.window.focus()};top.window.blur()}}'+
	'</script\>'+
	'</head>'+
	'<body>'+
	'</body>'+
	'</html>';
	win.document.open();
	win.document.write(parentCode);
	win.document.close();
	win.focus();
	if(chromelessVersion == 1){win.close();}
	}
}