/**
 * Funzioni_JScript 21 Feb 2004
 * M.D'Aristotile
 * J-Script Function del codice ASP per la Verifica Culturale Beni Immobili: DGBAP/Cartolarizzazione
 **/

/*** FUNZIONI GENERICHE ***/
/**
 * COMMENTI
 **/
function TableSetShow(tableid, initshow)
{
	if (document.all) { //ie
		if (initshow)  {
			document.all(tableid).style.height = "";
			document.all(tableid).style.width = "100%";
			document.all(tableid).style.display = "block";
			document.all(tableid).style.visibility = "visible";
		} else  {
			document.all(tableid).style.height = "0";
			document.all(tableid).style.display = "none";
			document.all(tableid).style.visibility = "hidden";
		} 

	} else { //ns
		if (initshow)  {
			document.getElementById(tableid).style.height = "";
			document.getElementById(tableid).style.width = "100%";
			document.getElementById(tableid).style.display = "block";
			document.getElementById(tableid).style.visibility = "visible";
		} else  {
			document.getElementById(tableid).style.height = "0";
			document.getElementById(tableid).style.display = "none";
			document.getElementById(tableid).style.visibility = "hidden";
		} 	
	}
}

function ShowHide(tableid, inithidden)
{
	if (document.all) { //ie
		if (document.all(tableid).style.visibility == "hidden") {
			document.all(tableid).style.height = "";
			document.all(tableid).style.width = "100%";
			document.all(tableid).style.display = "block";
			document.all(tableid).style.visibility = "visible";
		} else if (document.all(tableid).style.visibility == "visible" ) {
			document.all(tableid).style.height = "0";
			document.all(tableid).style.display = "none";
			document.all(tableid).style.visibility = "hidden";
		} else if (inithidden)  {
			document.all(tableid).style.height = "";
			document.all(tableid).style.width = "100%";
			document.all(tableid).style.display = "block";
			document.all(tableid).style.visibility = "visible";
		} else  {
			document.all(tableid).style.height = "0";
			document.all(tableid).style.display = "none";
			document.all(tableid).style.visibility = "hidden";
		} 

	} else { //ns
		if (document.getElementById(tableid).style.visibility == "hidden") {
			document.getElementById(tableid).style.height = "";
			document.getElementById(tableid).style.width = "100%";
			document.getElementById(tableid).style.display = "block";
			document.getElementById(tableid).style.visibility = "visible";
		} else if (document.getElementById(tableid).style.visibility == "visible" ) {
			document.getElementById(tableid).style.height = "0";
			document.getElementById(tableid).style.display = "none";
			document.getElementById(tableid).style.visibility = "hidden";
		} else if (inithidden)  {
			document.getElementById(tableid).style.height = "";
			document.getElementById(tableid).style.width = "100%";
			document.getElementById(tableid).style.display = "block";
			document.getElementById(tableid).style.visibility = "visible";
		} else  {
			document.getElementById(tableid).style.height = "0";
			document.getElementById(tableid).style.display = "none";
			document.getElementById(tableid).style.visibility = "hidden";
		} 	
	}
}

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
} 
 
function CheckData(giorno,mese,anno){
	if(isNaN(giorno)){
		return false
	}
	if(isNaN(mese)){
		return false
	}
	if(isNaN(anno)){
		return false
	}
	
	giorno=Number(giorno);
	mese=Number(mese);
	anno=Number(anno);
	
	if((giorno>31)||(giorno<1)){
		return false
	}
	if((mese>12)||(mese<1)){
		return false
	}
	if(anno<1900){
		return false
	}
	if(anno>3078){
		return false
	}
	if((anno%4!=0)&&(mese==2)&&(giorno>28)){
		return false
	}
	if((anno%4==0)&&(mese==2)&&(giorno>29)){
		return false
	}
	if(((mese==1)||(mese==3)||(mese==5)||(mese==7)||(mese==8)||(mese==10)||(mese==12))&&(giorno>31)){
		return false
	}
	if(((mese==4)||(mese==6)||(mese==9)||(mese==11))&&(giorno>30)){
		return false
	}
	return true
}

function CheckDataUni(data_oggi){
	var giorno;
	var mese;
	var anno;

	var mytool_array=data_oggi.split("/");
	giorno = Number(mytool_array[0]);
	mese = Number(mytool_array[1]);
	anno = Number(mytool_array[2]);
	
	return (CheckData(giorno,mese,anno));
}

/** GENERICHE  END Function **/



/*** FUNZIONI all'interno di DEFAULT.ASP ***/
/**
 * COMMENTI
 **/

	function Accedi(eng_version)
	{
		if (eng_version == 1)
		{
			strUrl="login_eng.asp"
		}
		else
		{
			strUrl="login.asp?Type="+eng_version
		}
		window.self.location.replace(strUrl);
	}

	function Accedi_Autorizzati(eng_version)
	{
		if (eng_version == 1)
		{
			strUrl="page/login_eng.asp"
		}
		else
		{
			strUrl="page/login.asp?Type="+eng_version
		}

		window.open(strUrl,"VerificaInteresseCulturale","toolbar=no,menubar=no,resizable=yes,location=no,Status=yes,scrollbars=yes,width=800,height=600");
	}

	function Accedi_Registrazione()
	{
		strUrl="page/menu_registrazione.asp";
		window.open(strUrl,"VerificaInteresseCulturale","toolbar=no,menubar=no,resizable=yes,location=no,Status=yes,scrollbars=yes");
	}
	
	function OpenDemo(eng_version)
	{
		if (eng_version == 1)
		{
			strUrl="http://www.benitutelati.it/benidemo/page/login_eng.asp"
			/*strUrl="http://localhost/benidemo/page/login_eng.asp" */
			/*strUrl="http://www.benitutelati.it/benidemo/default_en.asp"*/
		}
		else
		{
			strUrl="http://www.benitutelati.it/benidemo/page/login.asp"
			/*strUrl="http://localhost/benidemo/page/login.asp" */
			/*strUrl="http://www.benitutelati.it/benidemo" */
		}
		window.open(strUrl,"DemoVerificaInteresse","toolbar=no,menubar=no,resizable=yes,location=no,Status=yes,scrollbars=yes");
	}
	
	function OpenDemoSismico()
	{
		strUrl="http://www.benitutelati.it/benidemo/page/login_redirect.asp"
		/*strUrl="http://localhost/benidemo/page/login_redirect.asp"*/
		window.open(strUrl,"DemoVerificaInteresse","toolbar=no,menubar=no,resizable=yes,location=no,Status=yes,scrollbars=yes");
	}

	function AdminSite()
	{
		strURL = "page/login_gest.asp"
		window.open(strURL,"Area_Riservata","width=188,height=133,top=200,left=15,toolbar=no,menubar=no,resizable=no,location=no,Status=no,scrollbars=no");
	}


	function OpenGesmoHelp(strUrl)
	{
		window.open(strUrl,"GesMoHelp","toolbar=no,menubar=no,scrollbars=yes,resizable=yes ,status=yes");
	}
	
/** DEFAULT.ASP  END Function **/


/*** FUNZIONI all'interno di LOGIN_GEST.ASP ***/
/**
 * COMMENTI
 **/
 
 	function Controlla(){
				
		//-------------CHECK DATI-----------------------------------------
		if ((document.fAreaRiservata.txtUserName.value == "") ||
				(document.fAreaRiservata.txtPassword.value == "")) 
			{
				alert("Definire UTENTE e/o PASSWORD");
				return;
			}
		//-------------FINE CHECK DATI------------------------------------
	
		document.fAreaRiservata.action = "login_gest_verify.asp"
		document.fAreaRiservata.submit()
	}


	

/** _________.ASP  END Function **/

/***************************VERIFICA BROWSER **********/
function verifica_browser()
{
if (document.all)
	{
	 alert("Si sta usando Internet Explorer");
	}

else if (document.layers) 
	{
	alert("Si sta usando Netscape 4");
	} 

else if (document.getElementById) 
	{
	alert("Si sta usando Netscape 6, o un browser di nuova generazione");
	} 

else
	 {
	prompt ("Si sta usando un browser sconosciuto"); 
	}

}


function InfoComandi(id_coded)
{
	strUrl1="aa_info_comandi.asp?code="+id_coded;
	window.open(strUrl1,"InfoComandi","top=20,left=20,width=500,height=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes ,status=no");
}

//script per la lunghezza max della textarea
//function LenTextArea(areaName,counter,limit)
function LenTextArea(areaName,counter,limit)
{
	if (areaName.value.length>limit)
	{
		areaName.value=areaName.value.substring(0,limit);
	}
	/*else*/

	//counter.value = areaName.value.length;
	// **** 30 luglio 2007 il COUNTER non serve (MAU)
}
//

/*aggiungere al codice asp html

onKeyDown="LenTextArea(this.form.text_,this.form.leftChars,255);" onKeyUP="LenTextArea(this.form.text_,this.form.leftChars,255);"

<input type=hidden name=leftChars readonly size=3 maxlength=3 value="255">

*/







