	function fCheck(ObjCk)
	{
		var srcSave
		
		srcSave = "/ricInfo/saveElCheck.asp?IDCheck=" + ObjCk.value + "&TypeOp="
	
		if(ObjCk.checked)
		{
			IFRAMEsave.document.location = srcSave + "add";		//ADD IDCheck
		}
		else
		{
			IFRAMEsave.document.location = srcSave + "del";		//DEL IDCheck
		}
	}
	
	
	var nava = (document.layers);
	var dom = (document.getElementById);
	var iex = (document.all);


	function inStr(String1, String2)
	{
	    var a = 0;
    
	    if (String1 == null || String2 == null)
	        return (false);
    
	    String1 = String1.toLowerCase();
	    String2 = String2.toLowerCase();
    
	    a = String1.indexOf(String2);
	    if (a == -1)
	        return 0;
	    else
	        return a + 1;
	}

	function sendRicPubb()
	{
		var objForm = document.getElementById("mPubb");
		var check = true;
		
		/*if(objForm.Nome.value == "")
		{
			alert("Campo Nome obbligatorio.");
			objForm.Nome.focus(); 
			return;		
		}
		
		
		
		if(objForm.Cognome.value == "")
		{
			alert("Campo Cognome obbligatorio.");
			objForm.Cognome.focus(); 
			return;		
		}*/		

		if (!controlloData(objForm.arrivo.value)){
			alert("La data di arrivo inserita non è corretta. Il formato data deve essere gg/mm/aaaa");
			objForm.arrivo.focus(); 
			check = false;
			return;				
		}
		if (!controlloData(objForm.partenza.value)){
			alert("La data di partenza inserita non è corretta. Il formato data deve essere gg/mm/aaaa");
			objForm.partenza.focus();
			check = false; 
			return;
		}
		
		var data1 = objForm.arrivo.value;
		var data2 = objForm.partenza.value;
		if(data1!= "" && data2!= ""){
			data1str = data1.substr(6)+data1.substr(3, 2)+data1.substr(0, 2);
			data2str = data2.substr(6)+data2.substr(3, 2)+data2.substr(0, 2);
			//controllo se la seconda data è successiva alla prima        
			if (data2str-data1str<0) {            
				alert("La data iniziale deve essere precedente quella finale"); 
				check = false;
				return;   
			}			
		}


			
		
		if(objForm.Mail.value != "")
		{
			if(!check_email(objForm.Mail.value))
			{
				alert("Indirizzo Mail errato.");
				objForm.Mail.focus(); 
				objForm.Mail.select();
				check = false;
				return;
			}
		}
		else
		{
				alert("Indirizzo Mail obbligatorio.");
				objForm.Mail.focus(); 
				check = false;
				return;			
		}
		
		/*if(objForm.Indirizzo.value == "")
		{
			alert("Campo Indirizzo obbligatorio.");
			objForm.Indirizzo.focus(); 
			return;		
		}	
		
		if(objForm.Citta.value == "")
		{
			alert("Campo Citta obbligatorio.");
			objForm.Citta.focus(); 
			return;		
		}		
				
		
		if(objForm.Nazione.selectedIndex == 0)
		{
			alert("Campo Stato obbligatorio.");
			objForm.Nazione.focus(); 
			return;		
		}*/	
		
		if(objForm.Note.value == "")
		{
			alert("Campo \"Messaggio / note\" obbligatorio.");
			objForm.Note.focus(); 
			check = false;
			return;		
		}
		else
		{
			var Note = objForm.Note.value
			var nMaxChr = 200
		
			if(Note.length > nMaxChr)
			{
				alert("Numero massimo " + nMaxChr + " caratteri per \"Messaggio / note\".");
				objForm.Note.focus(); 
				objForm.Note.select();
				check = false;
				return;				
			}
			
			if(inStr(Note,'http://') > 0)
			{
				alert("Testo messaggio \"http\" non valido.");
				objForm.Note.focus(); 
				objForm.Note.select();
				return;				
			}
			
		}	
		
		if(!objForm.dati.checked)
		{
			alert("Per poter elaborare la sua richiesta è necessario autorizzare il trattamento dei suoi dati personali");
			check = false;
			return;
		}

		if (check){
			nascondiInvia();
			visAttendere();
	
			objForm.submit();
		}
	}
	
	
	
	function visAttendere()
	{
		if (nava) { cach = document.cache}
		else if (dom) {cach = document.getElementById("cache").style}
		else if (iex) {cach = cache.style}
		
		largeur = screen.width;
		cach.left = Math.round((largeur/2)-200);
		cach.visibility = "visible";	
	}
	
	function nascondiInvia()
	{
		var bottoneInvia
	
		if (nava) { bottoneInvia = document.cache}
		else if (dom) {bottoneInvia = document.getElementById("bottoneInvia").style}
		else if (iex) {bottoneInvia = bottoneInvia.style}
		
		bottoneInvia.visibility = "hidden";	
	}	
	
	
	// Email Validation.
		function check_email(e)
		{
			ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	
			for(i=0; i < e.length ;i++)
			{
				if(ok.indexOf(e.charAt(i))<0)
				{ 
					return (false);
				}	
			} 
	
			if (document.images)
			{
				re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
				re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
				if (!e.match(re) && e.match(re_two))
				{
					return (-1);		
				} 
	
			}
	
		}
		//Gran Baita Villa Mitzi	


		function controlloData(strData){
			if (strData != ''){				
				if (!isDate(strData)){
					return(false);			
				}else{
					return(true);						
				}
			}else{
				return(true);						
			}
		}		
		
		function isDate(str)
		{
			try
			{ 
				arr = str.split('/');		
				if(arr[2].length==2){
					arr[2] = "20" +arr[2]
				}			
				day = parseInt(removeLeadingZeros(arr[0]));
				month = parseInt(removeLeadingZeros(arr[1])) - 1;			
				year = parseInt(removeLeadingZeros(arr[2]));
				if (year.length == 1){
					year = '20' + year;
				}
				var d = new Date(year, month, day);
				if ((d.getMonth() == month) && (d.getFullYear() == year) && (d.getDate() == day) ){				
					return(true);
				}else{
					return(false);
				}
			}
				catch(err)
			{
				return false;
			}
		}
		
		function removeLeadingZeros(str)
		{
		  while (str.charAt(0) == '0')
		    str = str.substr(1);
		  return str;
		}
		
		
		var calData = new CalendarPopup("DIV_PopData", "1");
		calData.setCssPrefix("CALENDARIO");

