/*
+-----------------------------------------+
| stopBack(event)                         |
+-----------------------------------------+
| Questa funzione inibisce la possibilità |
| di navigare a ritroso tramite backspace |
| nell'history delle pagine visitate.     |
+-----------------------------------------+
*/

function stopBack(e) {
	if (event.srcElement.id.toUpperCase() == "BODY" || event.srcElement.id == "")
		{
        if (window.event.keyCode == 8)
        	{
        	return false;
        	}
        }
    }
    
//document.onkeydown=stopBack;

/*
+-----------------------------------------+
| lockRMB(event)                          |
+-----------------------------------------+
| Questa funzione inibisce il popup-menu  |
| normalmente accessibile tramite il      |
| pulsante destro del mouse.              |
+-----------------------------------------+
*/

function lockRMB(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
		
		return false;
	}
}

document.onmousedown=lockRMB;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=lockRMB;


// funzione per caricare il giusto style sheet a secondo del tipo di browser
function DetectBrowser (){

	var browser     = '';
	var version     = '';
	var entrance    = '';
	var cond        = '';
	// BROWSER?
	if (browser == ''){
	if (navigator.appName.indexOf('Microsoft') != -1)
	browser = 'IE'
	else if (navigator.appName.indexOf('Safari') != -1)
	browser = 'Netscape'
	else browser = 'Safari';
	}
	if (version == ''){
	version= navigator.appVersion;
	paren = version.indexOf('(');
	whole_version = navigator.appVersion.substring(0,paren-1);
	version         = parseInt(whole_version);
	}
	if (browser == 'IE' && version >= 4) document.write("<LINK rel='stylesheet' href='presentation/css/zuritel_ie.css' type='text/css' >");
	if (browser == 'Safari' && version >= 2.02) document.write("<LINK rel='stylesheet' href='presentation/css/zuritel_ie_safari.css' type='text/css' >");

}




//


//***************
// createOverlayLayer()
// Raffaele Sgherri - Avanade Italy
// 19/11/2002
//***************
//
//Crea un layer trasparente grande quanto tutta la pagina e lo inserisce nella pagina HTML
//Con questo layer visibile si disattiva l'accesso ad ogni elemento della pagina stessa (drop-down escluse)
//
function createOverlayLayer()
{
	var nL;
	var left = 1;
	var top = 1;
	var name = "overlay";
	var html = "";

	var width = document.body.scrollWidth - 2;
	var height = document.body.scrollHeight - 2;
	var divhtml = '<div  id=' + name + ' style="z-index:999;visibility:visible;left:' + left +
		'px;top:' + top + 'px;width:' + width +
		'px;height:' + height + 'px;position:absolute; background: url(/eSIGIppPortale/Imgs/eSIGI-transoverlay.gif) repeat">' +
		html + '</div>';
	document.body.insertAdjacentHTML('beforeEnd', divhtml);
	nL = document.all[name].style;

	return nL;
}

//***************
// DisableAll()
// Raffaele Sgherri - Avanade Italy
// 19/11/2002
//***************
//
// mette la clessidra su tutti i controlli della pagina
function DisableAll()
{
	document.body.style.cursor = "wait";
	for (var i= 0; i < document.all.length ;i++)
	{
		sTagName =  document.all.item(i).tagName;
		if (sTagName == "INPUT" || sTagName == "SELECT" || sTagName == "TEXTAREA")
		document.all.item(i).style.cursor = 'wait';		
	}

	// Disabilita i controlli inserendo un layer trasparente sopra tutta la pagina
	// NOTA: non vengono disabilitate le drop-down (in IE) a causa di un baco conosciuto
	var layer;	
	if (!layer)
	{	
		layer = createOverlayLayer();
	}
	
	return true;	
}
var popUp; 
//
//	
//
function OpenCalendar(idname, postBack)
{
	document.getElementById(idname).focus();
	popUp = window.open('default.aspx?Target=Calendar&formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=250,height=240,left=200,top=250');
}
//
//	
//
function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	//if (postBack)
	//	__doPostBack(id,'');
}		
