function lyChange( sId ) {
	var oNote = document.getElementById('nodo'+sId);
	if (oNote.style.display=="none") { oNote.style.display='' }
	else { oNote.style.display="none" }
}

function DelAuto(id, IdImg, stype, ImgType, action, page){
	if(confirm("Sei sicuro di voler eliminare?")){
	window.location = 'adminAutoEXEC.asp?sOp='+action+'&id='+id+'&page='+page+'&stype='+stype+'&ImgType='+ImgType+'&IdImg='+IdImg;
	}
}
function DelNews(id, idPlus, ImgType, action, page){
	if(confirm("Sei sicuro di voler eliminare?")){
	window.location = 'adminNewsEXEC.asp?sOp='+action+'&id='+id+'&page='+page+'&ImgType='+ImgType+'&idPlus='+idPlus;
	}
}

// consente la cancellazione di un record
function DelUser(id, lvl, action, page){
	if(confirm("Sei sicuro di voler eliminare?")){
	window.location = 'adminUsersEXEC.asp?sOp='+action+'&id='+id+'&lvl='+lvl+'&page='+page;
	}
}

// verifica la nuova password inserita
function checkpwd(){
	var testresults;
	var str = document.forms.password.pwdcheck.value;
	var str1 = document.forms.password.confpwdcheck.value;
	if (str == '' || str1 == '') {
		alert("ATTENZIONE!! Entrambi i campi devono essere compilati.");
		testresults=false;
	} else if (str == str1) {
		testresults=true ;
		document.forms.password.submit();
		}
	else{
		alert("ATTENZIONE!! I campi non corrispondono");
		testresults=false;
		}
	return (testresults);
}
	
/**********************************************************************
   Validazione di una data passata in un unico campo 
***********************************************************************/
	function isDateString(dateStr) {
	// The function returns true if a valid date, false if not.
		var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?
	
		if (matchArray == null) {
			return false;
		}
		
	// Vista la regExpr per accettare solamente mm/dd/yyyy oppure mm-dd-yyyy 
	// basta invertire gli indici del giorno e del mese settati qui sotto
	   day = matchArray[1]; // parse date into variables
	   month = matchArray[3]; 
	   year = matchArray[5];
	
		if (month < 1 || month > 12) { // check month range
			return false;
		}
		if (day < 1 || day > 31) {
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			return false;
		}
		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day > 29 || (day==29 && !isleap)) {
				return false;
			}
		}
		return true; // date is valid
	}
	
  function ValidatingHome ( oForm ) {
	if (oForm.bOccasione[1].checked) {
		disableHomeRadio ( oForm )
	} else {
		enableHomeRadio ( oForm )
	}
  }

  function enableHomeRadio ( oForm ) {
    oForm.bHome[0].disabled=false; 
    oForm.bHome[1].disabled=false; 
  }
  function disableHomeRadio ( oForm ) {
    oForm.bHome[0].disabled=true; 
    oForm.bHome[1].disabled=true; 
  }

  // Euro / Lire converter
	var cambio = 1936.27;
	var decimali = 2;
	function centesimi(o) {
	s = ""+o;
	p = s.indexOf('.');
	if (p!=-1) {
	s1 = s.substring(0,p);
	s2 = s.substring(p,p+decimali+1);
	} else {
	s1 = s;
	s2 = '.';
	for (i=1;i<=decimali;i++) {
	s2 = s2+'0';
	}
	}
	ris = s1 + s2;
	return ris;
	}
	function lireeuro( oFormLire, oFormEuro ) {
		s = oFormLire.value;
		if (!isNaN(s)) {
			l = parseFloat(s);
			e = l/cambio;
			var convertedValue = centesimi(e);
			oFormEuro.value = convertedValue;
		} else {
			oFormEuro.value = "0.00";
		}		
	}
	function eurolire( oFormLire, oFormEuro ) {
		s = oFormEuro.value;
		if (!isNaN(s)) {
			e = parseFloat(s);
			l = e*cambio;
			oFormLire.value = centesimi(l);
		} else {
			oFormLire.value = "0";
		}
	}
	
	// sostituisce , con .
	function replaceComma( oFormField ){
	   var r, re;                    
	   var ss = oFormField.value;
	   re = new RegExp(",");
	   oFormField.value = ss.replace(re, ".");    
	   return(oFormField.value);                   
	}

