function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function AVT_setStep(pString) {
	document.MainForm.AVT_Step.value=pString
}

var menuSemaPhore=false

function fwMenuLink(pLink, pArea, pML1, pML2, pML3) {
	document.MainForm.Page.value	= pLink
	document.MainForm.Area.value	= pArea
	document.MainForm.ML1.value		= pML1
	document.MainForm.ML2.value		= pML2
	document.MainForm.ML3.value		= pML3
	if (menuSemaPhore!=true) {
	    menuSemaPhore=true
//		document.MainForm.action		= document.MainForm.action + '?PAGEST=' + pLink;
		document.MainForm.action		= document.MainForm.action + '?Area=' + pArea +'&Page=' + pLink + '';
	}
	document.MainForm.submit()
}

function fwMenuLinkAnchor(pLink, pArea, pML1, pML2, pML3, pAnchor) {
	document.MainForm.Anchor.value	= pAnchor
	fwMenuLink(pLink, pArea, pML1, pML2, pML3)
}

function fwLink(pLink) {
	document.MainForm.Page.value	= pLink
	document.MainForm.action		= document.MainForm.action + '?Area=' + document.MainForm.Area.value +'&Page=' + pLink + '';
	document.MainForm.submit()
}

function fwFullLinkUpReset(l1, s1, l2, s2, l3, s3, link, lvl) {
	fwMenuLink(link,l1,l2,l3.substr(3,2),s3.substr(6,2))
}
function fwFullLink(l1, s1, l2, s2, l3, s3, link, lvl) {
	fwMenuLink(link,l1,l2,l3.substr(3,2),s3.substr(6,2))
}

function DIV_getStyle(tID) {
	if(document.getElementById)	return document.getElementById(tID).style;
	else if(document.all)		return document.all[tID].style;
	else if(document.layers)	return document.layers[tID];
	return false;
}
function DIV_show(pID) {
	var t		= DIV_getStyle(pID)
	t.display	= ''
	return		true
}
function DIV_hide(pID) {
	var t		= DIV_getStyle(pID)
	t.display	= 'none'
	return		true
}

// Roba da eliminare

function OpenFAQWindow(pSection) {
	tWin = window.open(JS_URL_PHP_INCLUDE + "Popup.php?PAGE=FAQView&FAQ_SECTION=" + pSection,"FAQ","scrollbars=no,toolbar=no,directories=no,menubar=no,width=428,height=450,resizable=no");
	tWin.focus();
}

function popupw(str, larg, alt) {
	PopUpWin = window.open(str,'PopUp', 'scrollbars=no,resizable=no,width=' + larg + ',height=' + alt + ',status=no,location=no,toolbar=no, menubar=no');
}

function popupzerow(str, larg, alt) {
	PopUpWin = window.open(str,'PopUp', 'scrollbars=no,resizable=no,width=' + larg + ',height=' + alt + ',status=no,location=no,toolbar=no, menubar=no, screenX=0, screenY=0');
}

function popupAbbo(str, larg, alt) {
	PopUpWin = window.open(str,'PopUp', 'scrollbars=no,resizable=no,width=' + larg + ',height=' + alt + ',status=yes,location=no,toolbar=no, menubar=no, screenX=0, screenY=0');
}

function popuptopleft(str, larg, alt) {
	PopUpWin = window.open(str,'PopUp', 'scrollbars=no,resizable=no,width=' + larg + ',height=' + alt + ',status=no, location=no, toolbar=no, menubar=no, top=0, left=0');
}

function ApriFinestraPdf(param) {
	if (param=="MA")
		nome=JS_URL + "pdf/popup_template_az.php";
	else
		nome=JS_URL + "pdf/popup_template_fam.php";
	
	msg=open(nome,"pdf","scrollbars=no,toolbar=no,directories=no,menubar=no,width=400,height=450,resizable=no");
}

function MailFriend() {
	var link = "";
	links = new Array();
	links[0]=(document.MainForm.Page.value	== '' ? 'xx' : document.MainForm.Page.value);
	links[1]=(document.MainForm.Area.value		== '' ? 'xx' : document.MainForm.Area.value);
	links[2]=(document.MainForm.ML1.value		== '' ? 'xx' : document.MainForm.ML1.value);
	links[3]=(document.MainForm.ML2.value		== '' ? 'xx' : document.MainForm.ML2.value);
	links[6]=(document.MainForm.ML3.value		== '' ? 'xx' : document.MainForm.ML3.value);
	for (i = 0; i < links.length; i++)
		link += links[i] + ":";
	
	msg=open("mail/popup_template.php?link="+link,"mail","scrollbars=no,toolbar=no,directories=no,menubar=no,width=400,height=300,resizable=no");
}

function PrintIt() {
window.print();
/*
	var NS = (navigator.appName == "Netscape");
	if (NS) {  window.print(); }
	else {
		var WebBrowser = '<object ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";
	}
*/	
}