function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) 
		with (navigator) {
			if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
				document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
			}
		}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  alert(innerWidth + ' - ' + innerHeight);
}

//MM_reloadPage(true);

// Submit Login
function SubmitLogin(txtLoginPage,intIDPage,intIDSezione){	
		document.form.action = txtLoginPage;
		document.form.elements["intIDPage"].value = intIDPage;
		document.form.elements["intIDSezione"].value = intIDSezione;
		document.form.submit();
	}
//-->

// Submit Logout
function SubmitLogout(txtPage,intIDPage,intIDSezione){	
		document.form.action = txtPage;
		document.form.elements["intIDPage"].value = intIDPage;
		document.form.elements["intIDSezione"].value = intIDSezione;
		document.form.elements["txtCodRif"].value = 'logout';
		document.form.submit();
	}
//-->

// Submit Link
function SubmitLink(intIDPage,intIDSezione){	
		document.form.action = MyPage;
		document.form.elements["intIDPage"].value = intIDPage;
		document.form.elements["intIDSezione"].value = intIDSezione;
		document.form.submit();
	}
//-->

// Submit Link Parent
function SubmitLinkP(intIDPage,intIDSezione){	
		window.parent.document.form.action = MyPage;
		window.parent.document.form.elements["intIDPage"].value = intIDPage;
		window.parent.document.form.elements["intIDSezione"].value = intIDSezione;
		window.parent.document.form.submit();
	}
//-->

// Submit Link Opener
function SubmitLinkOP(intIDPage,intIDSezione){	
		window.opener.document.form.action = 'mainpage.asp';
		window.opener.document.form.elements["intIDPage"].value = intIDPage;
		window.opener.document.form.elements["intIDSezione"].value = intIDSezione;
		window.opener.document.form.submit();
	}
//-->

// Submit Link Parent 2
function SubmitLinkP2(intIDPage,intIDSezione, sCodice){	
		window.parent.document.form.action = MyPage;
		window.parent.document.form.elements["intIDPage"].value = intIDPage;
		window.parent.document.form.elements["intIDSezione"].value = intIDSezione;
		window.parent.document.form.elements["txtCodRif"].value = sCodice;
		window.parent.document.form.submit();
	}
//-->

// Submit Link Parent x Posizioni Aperte
function SubmitLinkPos(intIDPage,intIDSezione, sCodRif){
		window.parent.document.form.action = MyPage;
		window.parent.document.form.elements["intIDPage"].value = intIDPage;
		window.parent.document.form.elements["intIDSezione"].value = intIDSezione;
		window.parent.document.form.elements["txtCodRif"].value = sCodRif;
		window.parent.document.form.submit();
	}
//-->

// Submit LinkMS
function SubmitLinkMS(sPage){	
		document.form.action = sPage;
		//document.form.elements["intIDPage"].value = intIDPage;
		document.form.submit();
	}
//-->

// Open BR Window
function MMopenBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);
}
//-->



// Submit Link SpPage (pagina contatti)
//function SubmitLinkSpPage(intIDPage,intIDSezione,txtSpecialPage){	
//		document.form.action = MyPage;
//		document.form.elements["intIDPage"].value = intIDPage;
//		document.form.elements["intIDSezione"].value = intIDSezione;
//		document.form.elements["txtSpecialPage"].value = txtSpecialPage;
//		document.form.submit();
//	}
//-->

///////////////////////////////////////////////////////////////////////////////////////////////////
// Submit Link SpPage (form1 x selezione regione)
///////////////////////////////////////////////////////////////////////////////////////////////////
function SubmitLinkSpPageReg(intIDPage,intIDSezione,txtSpecialPage,txtCodReg){	
		document.form1.action = MyPage;
		document.form1.elements["intIDPage"].value = intIDPage;
		document.form1.elements["intIDSezione"].value = intIDSezione;
		document.form1.elements["txtCodRegione"].value = txtCodReg;
		document.form1.submit();
	}
//-->

///////////////////////////////////////////////////////////////////////////////////////////////////
// Open PopUp
///////////////////////////////////////////////////////////////////////////////////////////////////
function OpenPage(sCodSk, txtCodTest, intWidth, intHeight, sPagina ) {
var oWin;
var leftpos;
	leftpos= 785 - intWidth;
  oWin = window.open( sPagina + "?CodTest=" + txtCodTest + "&Dim=" + intWidth + "&Height=" + intHeight + "&CodSK=" + sCodSk ,sCodSk,"width=" + intWidth + ",height=" + intHeight + ",scrollbars=yes,resizable=no,left=" + leftpos + ",top=50,");
  oWin.focus();
           
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Open PopUp
///////////////////////////////////////////////////////////////////////////////////////////////////
function OpenPagePartner(txtCodProv, intFrecce, intWidth, intHeight, sPagina ) {
var oWin1;
var leftpos1;
	leftpos1= 785 - intWidth;
 oWin1 = window.open( sPagina + "?CodProv=" + txtCodProv + "&Scroll=" + intFrecce + "&Dim=" + intWidth + "&Height=" + intHeight ,txtCodProv,"width=" + intWidth + ",height=" + intHeight + ",scrollbars=yes,resizable=no,left=" + leftpos1 + ",top=50,");
 oWin1.focus();
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Open PopUp
///////////////////////////////////////////////////////////////////////////////////////////////////
function OpenPageCom(sPagina, sName, nID, nWidth, nHeight, nIDPage, nIDSezione ) {
var oWin1;
var nLeft;
var nTop;
	if( screen.width>nWidth ) {
		nLeft = (screen.width-nWidth) / 2;
	} else {
		nLeft = 0;
	}
	if( screen.height>nHeight ) {
		nTop = (screen.height-nHeight) / 2;
	} else {
		nTop = 0;
	}
	//alert( 'nTop<' + nTop + '>\nnLeft<' + nLeft + '>\nnWidth<' + nWidth + '>\nnHeight<' + nHeight + '>' );
	//oWin1 = window.open( sPagina + "?id=" + nID + "&width=" + nWidth + "&Height=" + nHeight + "&idpage=" + nIDPage + "&idsezione=" + nIDSezione ,'popupCom',"width=" + nWidth + ",height=" + nHeight + ",scrollbars=yes,resizable=no,left=" + nLeft + ",top=" + nTop);
	oWin1 = window.open( sPagina + "?id=" + nID + "&idpage=" + nIDPage + "&idsezione=" + nIDSezione ,sName,"width=" + nWidth + ",height=" + nHeight + ",scrollbars=yes,resizable=no,left=" + nLeft + ",top=" + nTop);
	oWin1.focus();
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Apre una pagina solo con i bordi
///////////////////////////////////////////////////////////////////////////////////////////////////
function OpenWindow( pURL, pName, pFeaturs ) {
var oWin;
	//alert('pURL=<' + pURL + '>\npName=<' + pName + '>\npFeaturs=<' + pFeaturs +'>');
	oWin =  window.open( pURL, pName, pFeaturs );
	oWin.focus();
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Apertura Popup Help una pagina solo con i bordi
///////////////////////////////////////////////////////////////////////////////////////////////////
function OpenHelp( pAnchor ) {
var oWin;
	//alert('pURL=<' + pAnchor + '>');
	oWin =  window.open( 'help.asp#'+ pAnchor, 'HelpAdmin', 'scrollbars=yes,width=480,height=600' );
	oWin.focus();
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Estrae l'estensione da una nome di file
///////////////////////////////////////////////////////////////////////////////////////////////////
function getFileExtension(filePath) { //v1.0
  fileName = (filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length);
  return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Verifica il file per Upload ha un'estensione consentita
///////////////////////////////////////////////////////////////////////////////////////////////////
function checkFileUpload(form,extensions) { //v1.0
  document.MM_returnValue = true;
  if (extensions && extensions != '') {
    for (var i = 0; i<form.elements.length; i++) {
      field = form.elements[i];
      if (field.type.toUpperCase() != 'FILE') continue;
      //if (field.value == '') {
      //  alert('File is required!');
      //  document.MM_returnValue = false;field.focus();break;
      //}
      if (extensions.toUpperCase().indexOf(getFileExtension(field.value).toUpperCase()) == -1) {
        alert('Tipo di file non valido per l\'invio!');
        document.MM_returnValue = false;
        field.focus();
        break;
			}
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// Formatta l'inserimento di una data
///////////////////////////////////////////////////////////////////////////////////////////////////
function FormatDate(i, delKey,direction) {
  if( i.value.length < 10 ) {
		if (delKey!=9 && delKey!=11 && delKey!=13) { //tab e invio
			if(delKey!=8 && delKey!=46 && delKey!=16 &&  !(delKey>36 && delKey<41)){ //if the delete, backspace, shift, are not the keys that caused the keyup event.
				var fieldLen = i.value.length
        if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105)) {
					if (fieldLen == 2 || fieldLen == 5) {
						i.value = i.value + "/";             
          }
        } else { 
					i.value = i.value.substring(0,i.value.length - 1)
        }
        i.focus()
      }
    } 
	}
}

// ///////////////////////////////////////////////////////////////////////////////// //
// ALTERNA                                                                           //
// ///////////////////////////////////////////////////////////////////////////////// //
/*function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
	 if(i % 2 == 0){ 
	   rows[i].className = "even"; 
	 }else{ 
	   rows[i].className = "odd"; 
	 }       
   } 
 } 
}
*/