var fInvio =  {
		click: function(){
				var check = true;
				var info = document.getElementById('info');

				if(info.richiesta.value == "")
				{
					check = false;
					alert("Inserire Richiesta");
					info.richiesta.focus();
					return;		
				}
			
				if(info.nome.value == "")
				{
					check = false;
					alert("Inserire Nome");
					info.nome.focus();
					return;		
				}
				
				if(info.cognome.value == "")
				{
					check = false;
					alert("Inserire Cognome");
					info.cognome.focus();
					return;		
				}	
			
				if(info.mail.value == "")
				{		
					check = false;
					alert("Inserire E-Mail");
					info.mail.focus();
					return;		
				}
				
				if(!info.mail.value == "")
				{
			    	if(!fInvio.check_email(info.mail.value))
			    	{
			    		alert("E-MAIL non valida");
			    		info.mail.focus();
			    		check = false;	
			    		return;			
			    	}	
				}
			
				if(check)
				{
					check = fInvio.check(info.check_Alb);	
				}
					
				if(check)
				{
					if(!info.privacy.checked)
					{
						check = false;
						alert("Per poter proseguire accettare il trattamento dei dati persinali");
						info.privacy.focus();
						return;
					}
				}
				
				if(check)
				{
					fInvio.send()
				}
		
		},
		
		check: function(field){
				
				var formInfo = document.getElementById('info');
				
				formInfo.mailTo.value = '';
				
				formInfo.mailTo.value = field.value +";";  
				
				/*
				if (isNaN(field.length)){      	
					if (field.checked){
						formInfo.mailTo.value = field.value +";";  
					}
				}else{  		  
					  for (i = 0; i < field.length; i++)
					  {
					  	if(field[i].checked)
					  	{
							formInfo.mailTo.value = formInfo.mailTo.value + field[i].value +";";
					  	}
					  }	
				}
				*/
				
				if(formInfo.mailTo.value == "0;")
				{
					alert("ATTENZIONE! \nSelezionare un Hotel!");
					return false;
				}else{
					return true;
				}
		},
		

		check_email: function(v){
					
				ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

				for(i=0; i < v.length ;i++)
				{
					if(ok.indexOf(v.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 (!v.match(re) && v.match(re_two))
					{
						return (true);		
					} 
			
				}
		},
		
		
		send: function(){
				var offertaInfo = document.getElementById('info');
				var params;
				
				if ($("idOffRic")){
					params = 'idOffRic='+offertaInfo.idOffRic.value+'&mailTo='+offertaInfo.mailTo.value+'&oggetto='+offertaInfo.oggetto.value+'&richiesta='+offertaInfo.richiesta.value+'&nome='+offertaInfo.nome.value+'&cognome='+offertaInfo.cognome.value+'&via='+offertaInfo.via.value+'&n='+offertaInfo.numero.value+'&citta='+offertaInfo.citta.value+'&cap='+offertaInfo.CAP.value+'&stato='+offertaInfo.stato.value+'&tel='+offertaInfo.tel.value+'&fax='+offertaInfo.fax.value+'&mail='+offertaInfo.mail.value+'&newsl='+offertaInfo.newsl.checked;
				}else{
					params = 'idOffRic=0&mailTo='+offertaInfo.mailTo.value+'&oggetto='+offertaInfo.oggetto.value+'&richiesta='+offertaInfo.richiesta.value+'&nome='+offertaInfo.nome.value+'&cognome='+offertaInfo.cognome.value+'&via='+offertaInfo.via.value+'&n='+offertaInfo.numero.value+'&citta='+offertaInfo.citta.value+'&cap='+offertaInfo.CAP.value+'&stato='+offertaInfo.stato.value+'&tel='+offertaInfo.tel.value+'&fax='+offertaInfo.fax.value+'&mail='+offertaInfo.mail.value+'&newsl='+offertaInfo.newsl.checked;				
				}

				$('Wait').style.display = 'block';

				new Ajax.Request('/lib/info/invio_offerta.asp?'+params, {parameters:params,onSuccess:function(requester){
																	$('boxPop').style.display='none';
																	$('Wait').style.display='none';
																	showTheSelect();
																	$('TotalFade').style.display = 'none';
																}, onFailure:function(){
																	$('boxPop').style.display='none';
																	$('Wait').style.display='none';
																	showTheSelect();
																	$('TotalFade').style.display = 'none';
																}} );
		}

}