// JavaScript Document

function dlgWindow(w, h, titolo, contenuto)
{	
	var maxw ;
	var maxh ;
	if (!window.innerWidth)
	{
		maxw = document.documentElement.clientWidth;
		maxh = document.documentElement.clientHeight;
	}
	else
	{
		maxw = window.innerWidth;
		maxh = window.innerHeight;
	}
	
	var left = (maxw - w) / 2;
	var top  = (maxh - h) / 2;
	
	/* Background */
	objSfondo = document.createElement('div');
	objSfondo.setAttribute('id', 'elSfondo');
	objSfondo.style.position 		= "absolute";
	objSfondo.style.zIndex 			= "100";
	objSfondo.style.backgroundColor = "#000000";
	objSfondo.style.left 			= "0px";
	objSfondo.style.top 			= "0px";
	objSfondo.style.width  	 		= maxw + 'px';
	objSfondo.style.height 	 		= maxh + 'px';
	objSfondo.style.filter			= "alpha(opacity=50)";
	objSfondo.style.MozOpacity		= "0.7";
	
	/* window main container */
	objWin = document.createElement('div');
	objWin.setAttribute('id','elContainer');
	objWin.style.width  		 = w 	+ "px";
	objWin.style.height 		 = h 	+ "px";
	objWin.style.left   		 = left + "px";
	objWin.style.top    		 = top  + "px";
	objWin.style.position 		 = "absolute";
	objWin.style.border			 ="3px solid #ff9600";
	objWin.style.visibility      = "visible";
	objWin.style.filter			 = "alpha(opacity=100)";
	objWin.style.MozOpacity		 = "1";
	objWin.style.zIndex 		 = "110";
	objWin.style.backgroundColor ="#ffffff";
	
	/* title div */
	objTitle = document.createElement('div');
	objTitle.style.float		 = "left";
	objTitle.style.fontFamily	 = "Arial";
	objTitle.style.fontSize		 = "12px";
	objTitle.style.color		 = "#ffffff";
	objTitle.style.textAlign 	 = "center";
	objTitle.style.position 	 = "absolute";
	objTitle.style.left 		 = "1px";
	objTitle.style.top			 = "1px";
	objTitle.style.width  		 = (w-56) + "px";
	objTitle.style.height 		 = "20px";
	objTitle.style.visibility    = "visible";
	objTitle.style.filter		 = "alpha(opacity=100)";
	objTitle.style.MozOpacity	 = "1";
	objTitle.style.zIndex 		 = "110";
	objTitle.style.backgroundColor ="#e26201";
	objTitle.style.paddingTop	 = "3px";
	objTitle.innerHTML 			 = titolo;
	objWin.appendChild(objTitle);
	
	/* div close button */
	objClose = document.createElement('div');
	objClose.style.float		 = "left";
	objClose.style.fontFamily	 = "Arial";
	objClose.style.fontSize		 = "12px";
	objClose.style.color		 = "#DDDDDD";
	objClose.style.textAlign 	 = "center";
	objClose.style.position 	 = "absolute";
	objClose.style.left 		 = (w - 54) + "px";
	objClose.style.top			 = "1px";
	objClose.style.width  		 = "53px";
	objClose.style.height 		 = "20px";
	objClose.style.visibility    = "visible";
	objClose.style.filter		 = "alpha(opacity=100)";
	objClose.style.MozOpacity	 = "1";
	objClose.style.zIndex 		 = "110";
	objClose.style.backgroundColor ="#e26201";
	objClose.style.paddingTop	 = "3px";
	objWin.appendChild(objClose);

	/* link per chiudere */
	objHREF = document.createElement("a");
	objHREF.href = "javascript:dlgClose();";
	objHREF.innerHTML = "CHIUDI";
	objHREF.className = "win_admin_close";
	objClose.appendChild(objHREF);
	
	/* div per il contenuto */
	objContent = document.createElement('div');
	objContent.style.float		 		= "left";
	objContent.style.fontFamily	 		= "Arial";
	objContent.style.fontSize	 		= "12px";
	objContent.style.color		 		= "#000000";
	//objContent.style.textAlign 	 		= "center";
	objContent.style.position 	 		= "absolute";
	objContent.style.left 		 		= "1px";
	objContent.style.top		 		= "25px";
	objContent.style.width  	 		= (w - 4) + "px";
	objContent.style.height 	 		= (h - 28) + "px";
	objContent.style.visibility   		= "visible";
	objContent.style.filter		 		= "alpha(opacity=100)";
	objContent.style.MozOpacity	 		= "1";
	objContent.style.zIndex 		 	= "110";
	objContent.style.border 			= "1px solid #990000";
	//objContent.style.padding	 		= "2px";
	objContent.innerHTML				= contenuto;
	objWin.appendChild(objContent);
	
	objBody = document.getElementById('placeholder');
	//objBody.appendChild(objSfondo);
	objBody.appendChild(objWin);
}

function dlgTopWindow(win_top, w, h, titolo, contenuto)
{	
	var maxw ;
	var maxh ;
	if (!window.innerWidth)
	{
		maxw = document.documentElement.clientWidth;
		maxh = document.documentElement.clientHeight;
	}
	else
	{
		maxw = window.innerWidth;
		maxh = window.innerHeight;
	}
	
	var left = (maxw - w) / 2;
	var top  = win_top; //(maxh - h) / 2;
	
	/* Background */
	objSfondo = document.createElement('div');
	objSfondo.setAttribute('id', 'elSfondo');
	objSfondo.style.position 		= "absolute";
	objSfondo.style.zIndex 			= "100";
	objSfondo.style.backgroundColor = "#000000";
	objSfondo.style.left 			= "0px";
	objSfondo.style.top 			= "0px";
	objSfondo.style.width  	 		= maxw + 'px';
	objSfondo.style.height 	 		= maxh + 'px';
	objSfondo.style.filter			= "alpha(opacity=50)";
	objSfondo.style.MozOpacity		= "0.7";
	
	/* window main container */
	objWin = document.createElement('div');
	objWin.setAttribute('id','elContainer');
	objWin.style.width  		 = w 	+ "px";
	objWin.style.height 		 = h 	+ "px";
	objWin.style.left   		 = left + "px";
	objWin.style.top    		 = top  + "px";
	objWin.style.position 		 = "absolute";
	objWin.style.border			 ="3px solid #ff9600";
	objWin.style.visibility      = "visible";
	objWin.style.filter			 = "alpha(opacity=100)";
	objWin.style.MozOpacity		 = "1";
	objWin.style.zIndex 		 = "110";
	objWin.style.backgroundColor ="#ffffff";
	
	/* title div */
	objTitle = document.createElement('div');
	objTitle.style.float		 = "left";
	objTitle.style.fontFamily	 = "Arial";
	objTitle.style.fontSize		 = "12px";
	objTitle.style.color		 = "#ffffff";
	objTitle.style.textAlign 	 = "center";
	objTitle.style.position 	 = "absolute";
	objTitle.style.left 		 = "1px";
	objTitle.style.top			 = "1px";
	objTitle.style.width  		 = (w-46) + "px";
	objTitle.style.height 		 = "20px";
	objTitle.style.visibility    = "visible";
	objTitle.style.filter		 = "alpha(opacity=100)";
	objTitle.style.MozOpacity	 = "1";
	objTitle.style.zIndex 		 = "110";
	objTitle.style.backgroundColor ="#e26201";
	objTitle.style.paddingTop	 = "3px";
	objTitle.innerHTML 			 = titolo;
	objWin.appendChild(objTitle);
	
	/* div close button */
	objClose = document.createElement('div');
	objClose.style.float		 = "left";
	objClose.style.fontFamily	 = "Arial";
	objClose.style.fontSize		 = "12px";
	objClose.style.color		 = "#DDDDDD";
	objClose.style.textAlign 	 = "center";
	objClose.style.position 	 = "absolute";
	objClose.style.left 		 = (w - 44) + "px";
	objClose.style.top			 = "1px";
	objClose.style.width  		 = "43px";
	objClose.style.height 		 = "20px";
	objClose.style.visibility    = "visible";
	objClose.style.filter		 = "alpha(opacity=100)";
	objClose.style.MozOpacity	 = "1";
	objClose.style.zIndex 		 = "110";
	objClose.style.backgroundColor ="#e26201";
	objClose.style.paddingTop	 = "3px";
	objWin.appendChild(objClose);

	/* link per chiudere */
	objHREF = document.createElement("a");
	objHREF.href = "javascript:dlgClose();";
	objHREF.innerHTML = "CHIUDI";
	objHREF.className = "win_admin_close";
	objClose.appendChild(objHREF);
	
	/* div per il contenuto */
	objContent = document.createElement('div');
	objContent.style.float		 		= "left";
	objContent.style.fontFamily	 		= "Arial";
	objContent.style.fontSize	 		= "12px";
	objContent.style.color		 		= "#000000";
	//objContent.style.textAlign 	 		= "center";
	objContent.style.position 	 		= "absolute";
	objContent.style.left 		 		= "1px";
	objContent.style.top		 		= "25px";
	objContent.style.width  	 		= (w - 4) + "px";
	objContent.style.height 	 		= (h - 28) + "px";
	objContent.style.visibility   		= "visible";
	objContent.style.filter		 		= "alpha(opacity=100)";
	objContent.style.MozOpacity	 		= "1";
	objContent.style.zIndex 		 	= "110";
	objContent.style.border 			= "1px solid #990000";
	//objContent.style.padding	 		= "2px";
	objContent.innerHTML				= contenuto;
	objWin.appendChild(objContent);
	
	objBody = document.getElementById('placeholder');
	objBody.appendChild(objSfondo);
	objBody.appendChild(objWin);
}

function dlgTopAttesa(win_top, w, h, messaggio, immagine)
{	
	var maxw ;
	var maxh ;
	if (!window.innerWidth)
	{
		maxw = document.documentElement.clientWidth;
		maxh = document.documentElement.clientHeight;
	}
	else
	{
		maxw = window.innerWidth;
		maxh = window.innerHeight;
	}
	
	var left = (maxw - w) / 2;
	var top  = win_top; //(maxh - h) / 2;
	
	/* Background */
	
	objSfondo = document.createElement('div');
	objSfondo.setAttribute('id', 'elSfondo');
	objSfondo.style.position 		= "absolute";
	objSfondo.style.zIndex 			= "100";
	objSfondo.style.backgroundColor = "#000000";
	objSfondo.style.left 			= "0px";
	objSfondo.style.top 			= "0px";
	objSfondo.style.width  	 		= maxw + 'px';
	objSfondo.style.height 	 		= maxh + 'px';
	objSfondo.style.filter			= "alpha(opacity=50)";
	objSfondo.style.MozOpacity		= "0.7";
	
	/* window main container */
	objWin = document.createElement('div');
	objWin.setAttribute('id','elContainer');
	objWin.style.width  		 = w 	+ "px";
	objWin.style.height 		 = h 	+ "px";
	objWin.style.left   		 = left + "px";
	objWin.style.top    		 = top  + "px";
	objWin.style.position 		 = "absolute";
	objWin.style.border			 ="3px solid #ff9600";
	objWin.style.visibility      = "visible";
	objWin.style.filter			 = "alpha(opacity=100)";
	objWin.style.MozOpacity		 = "1";
	objWin.style.zIndex 		 = "110";
	objWin.style.backgroundColor ="#ffffff";
	
	/* div per il contenuto */
	objContent = document.createElement('div');
	objContent.style.float		 		= "left";
	objContent.style.fontFamily	 		= "Arial";
	objContent.style.fontSize	 		= "12px";
	objContent.style.color		 		= "#000000";
	//objContent.style.textAlign 	 		= "center";
	objContent.style.position 	 		= "absolute";
	objContent.style.left 		 		= "1px";
	objContent.style.top		 		= "1px";
	objContent.style.width  	 		= (w - 4) + "px";
	objContent.style.height 	 		= (h - 28) + "px";
	objContent.style.visibility   		= "visible";
	objContent.style.filter		 		= "alpha(opacity=100)";
	objContent.style.MozOpacity	 		= "1";
	objContent.style.zIndex 		 	= "110";
	//objContent.style.border 			= "1px solid #990000";
	//objContent.style.padding	 		= "2px";
	objContent.innerHTML				= '<center>' +
										  '<br /><br /><br />' +
										  '<img src="'+immagine+'" border="0" />' +
										  '<br /><br />' +
										  messaggio +
										  '</center>';
	objWin.appendChild(objContent);
	
	objBody = document.getElementById('placeholder');
	objBody.appendChild(objSfondo);
	objBody.appendChild(objWin);
}

function dlgClose()
{
	/* elemento contenitore */
	objBody = document.getElementById('placeholder');
	/* elementi da rimuovere */
	objSfondo = document.getElementById('elSfondo');
	objWin    = document.getElementById('elContainer');
	/* rimozione */
	objBody.removeChild(objWin);
	objBody.removeChild(objSfondo);
}

function dlgImage(w, h, titolo, url)
{
	var tag = '<img src="'+url+'" border="0" width="'+w+'" height="'+h+'" />';
	var win_w = w + 8;
	var win_h = h + 8 + 26;
	dlgWindow(win_w, win_h, titolo, tag);
}

function dlgFrame(w, h, titolo, url)
{
	var tag = '<iframe width="'+w+'" height="'+h+'" scrolling="yes" frameborder="0" src="'+url+'"></iframe>';
	var win_w = w + 8;
	var win_h = h + 8 + 26;
	dlgWindow(win_w, win_h, titolo, tag);
}

function dlgTopFrame(win_top, w, h, titolo, url)
{
	var tag = '<iframe width="'+w+'" height="'+h+'" scrolling="yes" frameborder="0" src="'+url+'"></iframe>';
	var win_w = w + 8;
	var win_h = h + 8 + 26;
	dlgTopWindow(win_top, win_w, win_h, titolo, tag);
}

function dlgFlash(w, h, titolo, url)
{
	var tag = 	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="flashobj" width="'+w+'" height="'+h+'" '+
              	'codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> '+
					'<param name="movie" value="'+url+'" /> '+
					'<param name="quality" value="high" /> '+
					'<param name="bgcolor" value="#869ca7" /> '+
					'<param name="allowScriptAccess" value="sameDomain" /> '+
					'<embed src="'+url+'" quality="high" bgcolor="#869ca7" '+
					'	width="'+w+'" height="'+h+'" name="idea_player" align="middle" '+
					'	play="true" '+
					'	loop="true" '+
					'	quality="high" '+
					'	allowScriptAccess="sameDomain" '+
					'	type="application/x-shockwave-flash" '+
					'	pluginspage="http://www.adobe.com/go/getflashplayer"> '+
					'</embed> '+
			'</object> ';
	var win_w = w + 8;
	var win_h = h + 8 + 26;
	dlgWindow(win_w, win_h, titolo, tag);
}

function dlgVideo(w, h, titolo, url)
{
	if (!window.innerWidth)
	{
		var tag = '<OBJECT id="VIDEO" width="'+w+'" height="'+h+'" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">'+
		'<PARAM NAME="URL" VALUE="'+url+'">'+
		'<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">'+
		'<PARAM NAME="AutoStart" VALUE="True">'+
		'<PARAM name="uiMode" value="none">'+
		'<PARAM name="PlayCount" value="9999">'+
		'</OBJECT>';
	}
	else
	{
		var tag = '<OBJECT TYPE="application/x-ms-wmp" id="VIDEO" width="'+w+'" height="'+h+'">'+
					 '<PARAM name="url" value="'+url+'">'+
					 '<PARAM NAME="AutoStart" VALUE="True">'+
					 '<PARAM name="uiMode" value="none">'+
					 '<PARAM name="PlayCount" value="9999">'+
					 '</OBJECT>';

	}
	var win_w = w + 8;
	var win_h = h + 8 + 26;
	dlgWindow(win_w, win_h, titolo, tag);
}

