/*

mettere nella pagina questi due frame

<div id='z_BlockScreen_' style="display:none"></div>
<div id='z_BlockScreen_html_' style="display:none;"></div>

*/

function simulateClick(elm)
{
	if (document.all)
	{
		elm.fireEvent("onclick");
	}
	else
	{
		var evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
		var canceled = !elm.dispatchEvent(evt);
		if(canceled)
		{
			// A handler called preventDefault
			// uh-oh, did some XSS hack your site?
		} else {
			// None of the handlers called preventDefault
			// do stuff
		}
	}
}

function blockDiv(divName, abilita, altMessage, color, alfaDec)
{

	TheBox = document.getElementById(divName);
	if (TheBox)
	{
		if (abilita)
		{

//			var newdiv = document.createElement('div');
//			newdiv.setAttribute('name','z_blockDiv_');
//			TheBox.appendChild(newdiv);

			parentObj = TheBox.parentNode;
			newdiv = TheBox;
			newdiv.innerHTML = 'aaaaaaaaaa';
			newdiv.style.position	= "fixed";
			newdiv.style.width		= parentObj.clientWidth;
			newdiv.style.height		= parentObj.clientHeight;
			newdiv.style.opacity	= "."+alfaDec;
			newdiv.style.filter		= "alpha(opacity="+(alfaDec*10)+")";
			newdiv.style.background	= color;
			newdiv.style.display	= "block";
			newdiv.title			= altMessage;

		//	TheBox.appendChild(newdiv);

		}
		else
		{
		//	TheBox.style.display	= "none";
		}
	}
}

function BlockScreen_custom(divName, abilita, altMessage, color, alfaDec)
{
	TheBox = document.getElementById(divName);
	if (TheBox)
	{
		if (abilita)
		{
			TheBox.style.position	= "fixed";
			TheBox.style.top		= "0px";
			TheBox.style.right		= "0px";
			TheBox.style.width		= "100%";
			TheBox.style.height		= '100%';
			TheBox.style.opacity	= "."+alfaDec;
			TheBox.style.filter		= "alpha(opacity="+(alfaDec*10)+")";
			TheBox.style.background	= color;
			TheBox.style.display	= "block";
			TheBox.title			= altMessage;
		} else {
			TheBox.style.display	= "none";
		}
	}
}

function BlockScreen_simple(abilita)
{
	BlockScreen_custom('z_BlockScreen_', abilita, '', 'yellow', 20);
}

function BlockScreen(testo)
{
	if (testo)
		testo = '<br />'.testo;
	else
		testo = '';

	TheBox = document.getElementById('z_BlockScreen_');
	TheBox.style.position	= "absolute";
	TheBox.style.top		= "0px";
	TheBox.style.width		= "100%";
	TheBox.style.height		= document.body.scrollHeight;
	TheBox.style.opacity	= ".3";
	TheBox.style.filter		= "alpha(opacity=30)";
	TheBox.style.background	= "blue";
	TheBox.style.display	= "block";

	TheBox = document.getElementById('z_BlockScreen_html_');
	TheBox.style.position	= "absolute";
	TheBox.style.top		= "0px";
	TheBox.style.width		= "100%";
	TheBox.style.height		= "100%";
	TheBox.style.display	= "block";
	TheBox.innerHTML		= "<div style='border-width: 1px; border-style: solid; background-color: white; position:absolute; height:20%; top:40%; width:40%; left:30%;'><table cellpadding='0' cellspacing='0' style='height:100%; width:100%;'><tr><td style='text-align:center; vertical-align: middle;'><img src='"+_fwz_layoutUrl_+"/img/spinner.gif' width='16' height='16' border='0' alt='caricamento in corso...' />"+testo+"</td></tr></table></div>";
}

function openOver(filename, divName)
{
	if (divName == null){ divName = 'z_BlockScreen_'; }

	TheBox = document.getElementById(divName);
	TheBox.style.position	= "fixed";
	TheBox.style.top		= "0px";
	TheBox.style.width		= "100%";
	TheBox.style.height		= '100%';
	TheBox.style.opacity	= ".3";
	TheBox.style.filter		= "alpha(opacity=30)";
	TheBox.style.background	= "blue";
	TheBox.style.display	= "block";
	TheBox.onclick			= BlockScreen_close;

	TheBox = document.getElementById('z_BlockScreen_html_');
	TheBox.style.position	= "fixed";
	TheBox.style.top		= "5%";
	TheBox.style.left		= "5%";
	TheBox.style.width		= "90%";
	TheBox.style.height		= "90%";
	TheBox.style.display	= "block";
	TheBox.style.borderWidth= "1px 2px 2px 1px";
	TheBox.style.borderStyle= "solid";
	TheBox.style.borderColor= "black";
	TheBox.style.backgroundColor = "white";

	addToDiv_filename('z_BlockScreen_html_', filename);
}

function BlockScreen_close()
{
	TheBox = window.parent.document.getElementById('z_BlockScreen_');
	if (TheBox)
	{
		TheBox.style.display	= "none";
	}
	TheBox = window.parent.document.getElementById('z_BlockScreen_html_');
	if (TheBox)
	{
		TheBox.style.display	= "none";
	}
}

function zDocumentReload()
{
	BlockScreen_simple(true);
	document.location.reload();
	return false;
}
