// JavaScript Document

$(document).ready(function(){

	$("#submit").click(function(){
									
			var country = document.getElementById('country').options[document.getElementById('country').selectedIndex].value;
			
			if($("#first_name").attr('value')==''){			
				alert('Please, insert your First Name');
				$("#first_name").focus();
				return false;
			}
			if($("#last_name").attr('value')==''){			
				alert('Please, insert your Last Name');
				$("#last_name").focus();
				return false;
			}			
			if($("#company").attr('value')==''){			
				alert('Please, insert your company name');
				$("#company").focus();
				return false;
			}						
			if($("#email").attr('value')==''){			
				alert("Please, insert your Email address");
				$("#email").focus();
				return false;
			}
			if($("#phone").attr('value')==''){			
				alert("Please, insert your phone number");
				$("#phone").focus();
				return false;
			}
			if (country=="") {
				alert("Please, select your country");
				$("#country").focus();
				return false;
			}
			if($("#website").attr('value')==''){			
				alert("Please, insert your website url");
				$("#website").focus();
				return false;
			}
			if($("#pw1").attr('value')==''){			
				alert("Please, insert your password");
				$("#pw1").focus();
				return false;
			}
			if($("#pw2").attr('value')==''){			
				alert("Please, repeat your password");
				$("#pw2").focus();
				return false;
			}
			if($("#pw1").attr('value')!=$("#pw2").attr('value')){			
				alert("Password does not match");
				$("#pw1").focus();
				return false;
			}
			if($("#terms").attr('checked')!=true){			
				alert("Please, accept the terms and conditions");
				$("#terms").focus();
				return false;
			}
			if($("#auth").attr('checked')!=true){			
				alert("Please, accept our privacy policy");
				$("#auth").focus();
				return false;
			}
			
			// copy selected country into hidden field
			document.getElementById('hdn_country').value = document.getElementById('country').options[document.getElementById('country').selectedIndex].value;
									
			$("#signup_form").submit();
			return false;
	 });
	
	return false;

});

$(document).ready(function(){

	$("#submit_ita").click(function(){
									
			if($("#first_name").attr('value')==''){			
				alert('Inserisci il tuo nome');
				$("#first_name").focus();
				return false;
			}
			if($("#last_name").attr('value')==''){			
				alert('Inserisci il tuo cognome');
				$("#last_name").focus();
				return false;
			}			
			if($("#company").attr('value')==''){			
				alert('Inserisci il nome della tua azienda');
				$("#company").focus();
				return false;
			}						
			if($("#email").attr('value')==''){			
				alert("Inserisci il tuo indirizzo di email");
				$("#email").focus();
				return false;
			}
			if($("#phone").attr('value')==''){			
				alert("Inserisci il tuo numero di telefono");
				$("#phone").focus();
				return false;
			}
			if($("#website").attr('value')==''){			
				alert("Inserisci la url del tuo sito web");
				$("#website").focus();
				return false;
			}
			if($("#pw1").attr('value')==''){			
				alert("Inserisci la password");
				$("#pw1").focus();
				return false;
			}
			if($("#pw2").attr('value')==''){			
				alert("Ripeti la password");
				$("#pw2").focus();
				return false;
			}
			if($("#pw1").attr('value')!=$("#pw2").attr('value')){			
				alert("Le password non coincidono");
				$("#pw1").focus();
				return false;
			}
			if($("#terms").attr('checked')!=true){			
				alert("Accetta le condizioni di utilizzo del servizio");
				$("#terms").focus();
				return false;
			}
			if($("#auth").attr('checked')!=true){			
				alert("Acconsenti al trattamento dei dati personali");
				$("#auth").focus();
				return false;
			}
			if($("#nomina").attr('checked')!=true){			
				alert("Acconsenti alla nominia del responsabile al trattamento");
				$("#nomina").focus();
				return false;
			}
			
			// copy selected country into hidden field
			document.getElementById('hdn_country').value = document.getElementById('country').options[document.getElementById('country').selectedIndex].value;
									
			$("#signup_form").submit();
			return false;
	 });
	
	return false;

});