
$(document).ready(function(){
	$("#submit_remainder").click(function(){
		var valid = '';
		var isr = '';	
		// devo solo verificare la email
		var email = $("#oldEmail_ti").val();
		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			valid = 'Verifica il formato della mail';
		}
		
		if (valid!='') {
			document.getElementById("messaggioOldUser").style.backgroundColor = "#C00";
			document.getElementById("messaggioOldUser").style.color = "#FFF";
			$("#messaggioOldUser").fadeIn("slow");
			$("#messaggioOldUser").html(valid);
		}
		else {
			
			var datastr ='email=' + email;
			$("#messaggioOldUser").css("display", "block");
			document.getElementById("messaggioOldUser").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioOldUser").style.color = "#000";
			//$("#messaggioOldUser").html("Inoltro richiesta in corso .... ");
			$("#messaggioOldUser").html('<img src="immagini/move-spinner.gif" alt="Controllo Volume ID in corso.... " /> Inoltro richiesta in corso.... ');
			$("#messaggioOldUser").fadeIn("slow");
			
			setTimeout("recuperaPassword('"+datastr+"')",2000);
			
		}
		return false;
	});
	
	$("#submit_loginForm").click(function(){								  
		var valid = '';
		var isr = '';
		// non faccio controlli, se ne occuperà direttamente la pagina PHP
		var uname = $("#uname_ti").val();
		var passwd = $("#passwd_ti").val();
		
		var datastr ='uname=' + uname + '&passwd='+passwd;
		if (valid!='') {
			
		}else{
			
			setTimeout("controlloLogin('"+datastr+"')",500);
		}
		return false;
	});
	
	$("#submit_democrosscad").click(function(){	
		var interfacce = "";											 								 
		
		/*if($("#acis3dtoiges").attr('checked')) interfacce += "<br>" + $("#acis3dtoiges").val();
		if($("#acis3dtostep").attr('checked')) interfacce += "<br>" + $("#acis3dtostep").val();
		if($("#acis3dtoxmt").attr('checked')) interfacce += "<br>" + $("#acis3dtoxmt").val();
		if($("#cadds3dtoiges").attr('checked')) interfacce += "<br>" + $("#acis3dtoiges").val();
		if($("#catiav42dtodxf").attr('checked')) interfacce += "<br>" + $("#catiav42dtodxf").val();
		if($("#catiav43dtoiges").attr('checked')) interfacce += "<br>" + $("#catiav43dtoiges").val();
		if($("#catiav43dtostep").attr('checked')) interfacce += "<br>" + $("#catiav43dtostep").val();
		if($("#catiav43dtoxmt").attr('checked')) interfacce += "<br>" + $("#catiav43dtoxmt").val();
		if($("#catiav52dtodxf").attr('checked')) interfacce += "<br>" + $("#catiav52dtodxf").val();
		if($("#catiav52dtoiges").attr('checked')) interfacce += "<br>" + $("#catiav52dtoiges").val();
		if($("#catiav53dtoacis").attr('checked')) interfacce += "<br>" + $("#catiav53dtoacis").val();
		if($("#catiav53dtoiges").attr('checked')) interfacce += "<br>" + $("#catiav53dtoiges").val();
		if($("#catiav53dtoopen").attr('checked')) interfacce += "<br>" + $("#catiav53dtoopen").val();
		if($("#catiav53dtoxmt").attr('checked')) interfacce += "<br>" + $("#catiav53dtoxmt").val();
		if($("#catiav53dtostep").attr('checked')) interfacce += "<br>" + $("#catiav53dtostep").val();
		if($("#dxf2dtoiges").attr('checked')) interfacce += "<br>" + $("#dxf2dtoiges").val();
		if($("#iges3dtostl").attr('checked')) interfacce += "<br>" + $("#iges3dtostl").val();
		if($("#jttostl").attr('checked')) interfacce += "<br>" + $("#jttostl").val();
		if($("#jttovrml").attr('checked')) interfacce += "<br>" + $("#jttovrml").val();
		if($("#inventor3dtoiges").attr('checked')) interfacce += "<br>" + $("#inventor3dtoiges").val();
		if($("#micro2dtodxf").attr('checked')) interfacce += "<br>" + $("#micro2dtodxf").val();
		if($("#xmtto3dm").attr('checked')) interfacce += "<br>" + $("#xmtto3dm").val();
		if($("#xmt3dtoiges").attr('checked')) interfacce += "<br>" + $("#xmt3dtoiges").val();
		if($("#xmt3dtostep").attr('checked')) interfacce += "<br>" + $("#xmt3dtostep").val();
		if($("#xmt3dtostl").attr('checked')) interfacce += "<br>" + $("#xmt3dtostl").val();
		if($("#proe2dtodxf").attr('checked')) interfacce += "<br>" + $("#proe2dtodxf").val();
		if($("#proe3dtoiges").attr('checked')) interfacce += "<br>" + $("#proe3dtoiges").val();
		if($("#proe3dtostep").attr('checked')) interfacce += "<br>" + $("#proe3dtostep").val();
		if($("#sedge3dtoiges").attr('checked')) interfacce += "<br>" + $("#sedge3dtoiges").val();
		if($("#sedge3dtostep").attr('checked')) interfacce += "<br>" + $("#sedge3dtostep").val();
		if($("#sedge3dtoxmt").attr('checked')) interfacce += "<br>" + $("#sedge3dtoxmt").val();
		if($("#sedge3dtoiges3").attr('checked')) interfacce += "<br>" + $("#sedge3dtoiges3").val();
		if($("#sworks3dtoiges").attr('checked')) interfacce += "<br>" + $("#sworks3dtoiges").val();
		if($("#sworks3dtoxmt").attr('checked')) interfacce += "<br>" + $("#sworks3dtoxmt").val();
		if($("#step3dtoiges").attr('checked')) interfacce += "<br>" + $("#step3dtoiges").val();
		if($("#ug2dtodxf").attr('checked')) interfacce += "<br>" + $("#ug2dtodxf").val();
		if($("#ug2dtoiges").attr('checked')) interfacce += "<br>" + $("#ug2dtoiges").val();
		if($("#ug3dtoiges").attr('checked')) interfacce += "<br>" + $("#ug3dtoiges").val();
		if($("#ug3dto3dm").attr('checked')) interfacce += "<br>" + $("#ug3dto3dm").val();
		if($("#ug3dtostep").attr('checked')) interfacce += "<br>" + $("#ug3dtostep").val();
		if($("#ug3dtoxmt").attr('checked')) interfacce += "<br>" + $("#ug3dtoxmt").val();
		if($("#uni3dtoiges").attr('checked')) interfacce += "<br>" + $("#uni3dtoiges").val();
		if($("#ug3dtoxmt").attr('checked')) interfacce += "<br>" + $("#ug3dtoxmt").val();*/
		//var demo = interfacce.split("<br>");
		var demo = '';
		var validCrosscaddemo = '';
		var email = $("#CCnewEmail_ti").val();	
		var messaggio = $("#CCrichiesta_ta").val();	
		messaggio = messaggio.replace(/[\r\n]/g, " ");
		var serCM = $("#CCcodice_ta").val();
		serCM = serCM.replace(/[\r\n]/g, "-");
		
	
		
		//alert(serCM);
		
		//serCM = serCM.innerHTML;
		//alert(serCM);
		//exit;
		// 20 Maggio 2010
		//var computername = $("#computername").val();	
		//var hostid = $("#hostid").val();			
		var computername = "nd";	
		var hostid = "nd";
		
		//var serialCM = CKEDITOR.instances.editor.getData();
		
		//var serialCM = "TEST TECNICO";
		//alert(serCM);
		//exit;
		
		if( (hostid.length <1) || (computername.length<1) )  {
			validCrosscaddemo = 'La richiesta deve provenire da Crosscad!'; 
		}

		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			validCrosscaddemo = 'Verifica il formato della mail';
		}
		
		if (serCM.length < 1) {
			validCrosscaddemo = 'Devi inserire le informazioni salvate nel file di testo';
		}
		
	/*	if(demo.length > 5){
			validCrosscaddemo = 'Attenzione! Puoi selezionare al massimo 4 interfacce';
		}
	*/	
		
		/*if(demo.length <= 1){
			validCrosscaddemo = 'Attenzione! Devi selezionare almeno una interfaccia';
		}*/
		
		
		
		
		if (validCrosscaddemo !='') {
			document.getElementById("messaggioDemoCrosscad").style.backgroundColor = "#C00";
			document.getElementById("messaggioDemoCrosscad").style.color = "#FFF";
			$("#messaggioDemoCrosscad").fadeIn("slow");
			$("#messaggioDemoCrosscad").html(validCrosscaddemo);
		}else{
			// 20 Maggio 2010
			//var datastr ='interfacce=' + interfacce + '&email='+email + '&messaggio='+messaggio + '&computername='+computername + '&hostid='+hostid;
			var datastr ='interfacce=' + interfacce + '&email='+email + '&messaggio='+messaggio + '&serialCM=' + serCM ;
			
			$("#messaggioDemoCrosscad").css("display", "block");
			document.getElementById("messaggioDemoCrosscad").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioDemoCrosscad").style.color = "#000";
			//$("#messaggioDownload").html("Controllo Volume ID in corso.... ");
			$("#messaggioDemoCrosscad").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioDemoCrosscad").fadeIn("slow");
			
			setTimeout("richiestacrosscad('"+datastr+"')",850);
			
			
		}
		return false;
	 });
	
$("#submit_weightcalculus").click(function(){	
		var validWeightcalculus = '';
		var email = $("#WCnewEmail_ti").val();	
		var messaggio = $("#WCrichiesta_ta").val();	
		var computerid = $("#computerid").val();	
		var hostID = $("#hostID").val();	
		
		if( (computerid.length <1) || (hostID.length<1) )  {
			validWeightcalculus = 'La richiesta deve provenire da Crosscad!'; 
		}

		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			validWeightcalculus = 'Verifica il formato della mail';
		}
		
		if (validWeightcalculus !='') {
			document.getElementById("messaggioDemoWeight").style.backgroundColor = "#C00";
			document.getElementById("messaggioDemoWeight").style.color = "#FFF";
			$("#messaggioDemoWeight").fadeIn("slow");
			$("#messaggioDemoWeight").html(validWeightcalculus);
		}else{
			var datastr ='email='+email + '&messaggio='+messaggio + '&computerid='+computerid + '&hostID='+hostID;
			
			$("#messaggioDemoCrosscad").css("display", "block");
			document.getElementById("messaggioDemoWeight").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioDemoWeight").style.color = "#000";
			//$("#messaggioDownload").html("Controllo Volume ID in corso.... ");
			$("#messaggioDemoWeight").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioDemoWeight").fadeIn("slow");
			
			setTimeout("richiestaweightcalculus('"+datastr+"')",850);
			
			
		}
		return false;
	 });	
	

	$("#submit_downloadSpinfirePro").click(function(){
		var valid2 = 'aa';						
		/*var valid2 = '';
		var volumeID = $("#spinfirevolumeID_ti").val();	
		var lingua = $("#spinfirelinguaSW_cb").val();	
		var nome = $("#spinfireNome_ti").val();
		var cognome = $("#spinfireCognome_ti").val(); 
		var azienda = $("#spinfireAzienda_ti").val(); 
		var citta = $("#spinfireCitta_ti").val(); 
		var telefono = $("#spinfireTel_ti").val();  
		var email = $("#spinfireEmail_ti").val();
		var iva =  $("#spinfireNazione_ti").val();
		var prov =  $("#spinfirePROV_ti").val();
		var indirizzo =  $("#spinfireIndirizzo_ti").val();
		var cap =  $("#spinfireCAP_ti").val();	
		var ruolo = $("#spinfireRuolo_ti").val();	
		var nazione = $("#spinfireNazione_ti").val();
		var note = $("#spinfire_ta").val();

		if( (volumeID.length <1) || (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1)  || (prov.length<1)  || (indirizzo.length<1)   || (ruolo.length<1) || (nazione.length<1)  )  {
			valid2 = 'Verifica i dati inseriti'; 
		}

		*/
		if (valid2!='') {
			/*document.getElementById("messaggioDownload").style.backgroundColor = "#C00";
			document.getElementById("messaggioDownload").style.color = "#FFF";
			$("#messaggioDownload").fadeIn("slow");
			$("#messaggioDownload").html(valid2);*/
		}else {
			/*document.getElementById("messaggioDownload").style.backgroundColor = "#EABA28";	
			document.getElementById("messaggioDownload").style.color = "#000";
			$("#messaggioDownload").html("Inoltro richiesta in corso .... ");
			$("#messaggioDownload").fadeIn("slow");

			//var stringaActify ='email=' + email + '&volume_id=' + volumeID + '&note=' + note + '&lingua=' + lingua;
			var stringaActify ='email=' + email + '&volume_id=' + volumeID + '&note=' + note + '&lingua=' + lingua + '&sw=sfprof';
			
			//var stringaActify = 'stringaACTIFY = |sfp_trial|' + nome +'|' + cognome   +'|' + azienda +'|' + ruolo +'|' + telefono +'|' + email +'|' + indirizzo +'|' + citta +'|' + nazione +'|' + cap +'|' + note +'|' + lingua +'|2n5222fk' + volumeID;

			$("#messaggioDownload").css("display", "block");
			document.getElementById("messaggioDownload").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioDownload").style.color = "#000";
			//$("#messaggioDownload").html("Controllo Volume ID in corso.... ");
			$("#messaggioDownload").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioDownload").fadeIn("slow");
			*/
			setTimeout("controlloVolumeID('"+stringaActify+"')",20);
			
			}
		return false;
	});

$("#submit_downloadSpinfireReader").click(function(){							
		var validR = '';
		var volumeID = $("#spinfireRvolumeID_ti").val();	
		var lingua = $("#spinfireRlinguaSW_cb").val();	
		var nome = $("#spinfireRNome_ti").val();
		var cognome = $("#spinfireRCognome_ti").val(); 
		var azienda = $("#spinfireRAzienda_ti").val(); 
		var citta = $("#spinfireRCitta_ti").val(); 
		var telefono = $("#spinfireRTel_ti").val();  
		var email = $("#spinfireREmail_ti").val();
		var iva =  $("#spinfireRNazione_ti").val();
		var prov =  $("#spinfireRPROV_ti").val();
		var indirizzo =  $("#spinfireRIndirizzo_ti").val();
		var cap =  $("#spinfireRCAP_ti").val();	
		var ruolo = $("#spinfireRRuolo_ti").val();	
		var nazione = $("#spinfireRNazione_ti").val();
		var note = $("#spinfireR_ta").val();


		if( (volumeID.length <1) || (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1)  || (prov.length<1)  || (indirizzo.length<1)   || (ruolo.length<1) || (nazione.length<1)  )  {
			validR = 'Verifica i dati inseriti'; 
		}

		
		if (validR!='') {
			document.getElementById("messaggioDownloadR").style.backgroundColor = "#C00";
			document.getElementById("messaggioDownloadR").style.color = "#FFF";
			$("#messaggioDownloadR").fadeIn("slow");
			$("#messaggioDownloadR").html(valid2);
		}else {
			document.getElementById("messaggioDownloadR").style.backgroundColor = "#EABA28";	
			document.getElementById("messaggioDownloadR").style.color = "#000";
			$("#messaggioDownloadR").html("Inoltro richiesta in corso .... ");
			$("#messaggioDownloadR").fadeIn("slow");

			var stringaActify ='email=' + email + '&volume_id=' + volumeID + '&note=' + note + '&lingua=' + lingua + '&sw=sfread';
			//var stringaActify = 'stringaACTIFY = |sfp_trial|' + nome +'|' + cognome   +'|' + azienda +'|' + ruolo +'|' + telefono +'|' + email +'|' + indirizzo +'|' + citta +'|' + nazione +'|' + cap +'|' + note +'|' + lingua +'|2n5222fk' + volumeID;

			$("#messaggioDownloadR").css("display", "block");
			document.getElementById("messaggioDownloadR").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioDownloadR").style.color = "#000";
			//$("#messaggioDownload").html("Controllo Volume ID in corso.... ");
			$("#messaggioDownloadR").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioDownloadR").fadeIn("slow");
			
			//alert(stringaActify);
			setTimeout("controlloVolumeIDSR('"+stringaActify+"')",2000);
			
			}
		return false;
	});


	$("#submit_upgradeSpinfirePRO").click(function(){	
		
		var richiestaValida = '';		
		var nome = $("#upgradeNome_ti").val();
		var cognome = $("#upgradeCognome_ti").val(); 
		var azienda = $("#upgradeAzienda_ti").val(); 
		var email = $("#upgradeMail_ti").val();
		var note =  $("#upgradeNote_ta").val();
		var seatid1 = $("#seatID_ti1").val();
		var seatid2 = $("#seatID_ti2").val();
		var seatid3 = $("#seatID_ti3").val();
		
		var seatid = seatid1 + '-' + seatid2 + '-' + seatid3;
		
		if( (nome.length<1)  || (cognome.length<1)  || (azienda.length<1) || (seatid1.length<2) || (seatid2.length<3) || (seatid3.length<8) )  {
			richiestaValida = 'Verifica i dati inseriti';
		}
		

		
		if (richiestaValida!='') {
			document.getElementById("messaggioAggLicenza").style.backgroundColor = "#C00";
			document.getElementById("messaggioAggLicenza").style.color = "#FFF";
			$("#messaggioAggLicenza").fadeIn("slow");
			$("#messaggioAggLicenza").html(richiestaValida);
		}
		else {
			
			var datastr ='seatid=' + seatid + '&note=' + note;
			$("#messaggioAggLicenza").css("display", "block");
			document.getElementById("messaggioAggLicenza").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioAggLicenza").style.color = "#000";
			$("#messaggioAggLicenza").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioAggLicenza").fadeIn("slow");
			
			setTimeout("aggiornamentoLicenza('"+datastr+"')",2000);
			
		}
		return false;
	});			
	
	$("#submit_aggiornaProfilo").click(function(){
		var aggValido = '';
		var nome = $("#APnewNome_ti").val();
		var cognome = $("#APnewCognome_ti").val(); 
		var azienda = $("#APnewAzienda_ti").val(); 
		var citta = $("#APnewCitta_ti").val(); 
		var telefono = $("#APnewTel_ti").val();  
		var email = $("#APnewEmail_ti").val();
		var nazione =  $("#APnewNazione_ti").val();
		var prov =  $("#APnewPROV_ti").val();
		var indirizzo =  $("#APnewIndirizzo_ti").val();
		var cap =  $("#APnewCAP_ti").val();	
		var ruolo = $("#APnewRuolo_ti").val();	
		var passwd = $("#APvecchiaPasswd_ti").val();
		var nuovaPasswd = $("#APnuovaPasswd_ti").val();

		if( (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1)   || (prov.length<1)  || (indirizzo.length<1)  || (cap.length<1)  || (ruolo.length<1) || (nazione.length<1)  )  {
			aggValido = 'Verifica i dati inseriti';
		}
		
		//alert(aggValido);
		
		if (aggValido!='') {
			document.getElementById("messaggioUpdUser").style.backgroundColor = "#C00";
			document.getElementById("messaggioUpdUser").style.color = "#FFF";
			$("#messaggioUpdUser").fadeIn("slow");
			$("#messaggioUpdUser").html(aggValido);
		}
		else {
			
			var datastr ='nome=' + nome + '&email=' + email + '&cognome=' + cognome + '&azienda=' + azienda + '&ruolo=' + ruolo + '&citta=' + citta+ '&telefono=' + telefono + '&nazione=' + nazione+ '&indirizzo=' + indirizzo+ '&prov=' + prov+ '&cap=' + cap + '&nuovaPwd=' + nuovaPasswd;
			$("#messaggioNewUser").css("display", "block");
			document.getElementById("messaggioUpdUser").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioUpdUser").style.color = "#000";
			//$("#messaggioUpdUser").html("Aggiornamento in corso .... ");
			$("#messaggioUpdUser").html('<img src="immagini/move-spinner.gif" alt="Aggiornamento in corso.... " /> Aggiornamento in corso.... ');
			$("#messaggioUpdUser").fadeIn("slow");
			
			setTimeout("sendUpdateUser('"+datastr+"')",2000);
			
		}
		return false;
	});
	
	$("#submit_newsletter").click(function(){
		var Newslettervalid = '';
		var Newsletternome = $("#newsletterNome_ti").val();
		var Newsletteremail = $("#newsletterEmail_ti").val();	
		if(Newsletternome.length<1) {
			Newslettervalid = 'Verifica i dati inseriti';
		}
		
		if (!Newsletteremail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			Newslettervalid = 'Verifica i dati inseriti';
		}
		
		if (Newslettervalid!='') {
			document.getElementById("messaggioNewsletter").style.backgroundColor = "#C00";
			document.getElementById("messaggioNewsletter").style.color = "#FFF";
			$("#messaggioNewsletter").fadeIn("slow");
			$("#messaggioNewsletter").html(Newslettervalid);
		}else {
			
			var datastr ='nome=' + Newsletternome + '&email=' + Newsletteremail;
			$("#messaggioNewsletter").css("display", "block");
			document.getElementById("messaggioNewsletter").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioNewsletter").style.color = "#000";
			//$("#messaggioNewUser").html("Inoltro richiesta in corso .... ");
			$("#messaggioNewsletter").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioNewsletter").fadeIn("slow");
			
			setTimeout("iscrizioneNewsletter('"+datastr+"')",2000);
			
		}
		return false;
	});		
		
	$("#submit_registrazione").click(function(){
		var valid = '';
		var isr = '';	
		var nome = $("#newNome_ti").val();
		var cognome = $("#newCognome_ti").val(); 
		var azienda = $("#newAzienda_ti").val(); 
		var citta = $("#newCitta_ti").val(); 
		var telefono = $("#newTel_ti").val();  
		var email = $("#newEmail_ti").val();
		var nazione =  $("#newNazione_ti").val();
		var prov =  $("#newPROV_ti").val();
		var indirizzo =  $("#newIndirizzo_ti").val();
		var cap =  $("#newCAP_ti").val();	
		var ruolo = $("#newRuolo_ti").val();	
		
		if( (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1)  || (prov.length<1)  || (indirizzo.length<1)  || (cap.length<1)  || (ruolo.length<1) || (nazione.length<1)  )  {
			valid = 'Verifica i dati inseriti';
		}
		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			valid = 'Verifica i dati inseriti';
		}
		
		if (valid!='') {
			document.getElementById("messaggioNewUser").style.backgroundColor = "#C00";
			document.getElementById("messaggioNewUser").style.color = "#FFF";
			$("#messaggioNewUser").fadeIn("slow");
			$("#messaggioNewUser").html(valid);
		}
		else {
			
			var datastr ='nome=' + nome + '&email=' + email + '&cognome=' + cognome + '&azienda=' + azienda + '&ruolo=' + ruolo + '&citta=' + citta+ '&telefono=' + telefono + '&nazione=' + nazione+ '&indirizzo=' + indirizzo+ '&prov=' + prov+ '&cap=' + cap;
			$("#messaggioNewUser").css("display", "block");
			document.getElementById("messaggioNewUser").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioNewUser").style.color = "#000";
			//$("#messaggioNewUser").html("Inoltro richiesta in corso .... ");
			$("#messaggioNewUser").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioNewUser").fadeIn("slow");
			
			setTimeout("send('"+datastr+"')",2000);
			
		}
		return false;
	});
	
	$("#submit_richiestaAssistenza").click(function(){
		var validAss = '';
		var nome = $("#ATnewNome_ti").val();
		var cognome = $("#ATnewCognome_ti").val(); 
		var azienda = $("#ATnewAzienda_ti").val(); 
		var citta = $("#ATnewCitta_ti").val(); 
		var telefono = $("#ATnewTel_ti").val();  
		var email = $("#ATnewEmail_ti").val();
		var nazione =  $("#ATnewNazione_ti").val();
		var prov =  $("#ATnewPROV_ti").val();
		var indirizzo =  $("#ATnewIndirizzo_ti").val();
		var cap =  $("#ATnewCAP_ti").val();	
		var ruolo = $("#ATnewRuolo_ti").val();	
		var sw = $("#cbSw").val();
		var note = $("#richiesta_ta").val();

		if( (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1) || (note.length<1)   || (prov.length<1)  || (indirizzo.length<1)  || (cap.length<1)  || (ruolo.length<1) || (nazione.length<1)  )  {
			validAss = 'Verifica i dati inseriti';
		}

		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			validAss = 'Verifica i dati inseriti';
		}
		
		if (validAss !='') {
			document.getElementById("messaggioAssistenza").style.backgroundColor = "#C00";
			document.getElementById("messaggioAssistenza").style.color = "#FFF";
			$("#messaggioAssistenza").fadeIn("slow");
			$("#messaggioAssistenza").html(validAss);
		
		}else {
			
		var richAss ='nome=' + nome + '&email=' + email + '&cognome=' + cognome + '&azienda=' + azienda + '&ruolo=' + ruolo + '&citta=' + citta+ '&telefono=' + telefono + '&nazione=' + nazione+ '&indirizzo=' + indirizzo+ '&prov=' + prov+ '&cap=' + cap + '&sw=' + sw + '&note=' + note;
			$("#messaggioAssistenza").css("display", "block");
			document.getElementById("messaggioAssistenza").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioAssistenza").style.color = "#000";
			//$("#messaggioNewUser").html("Inoltro richiesta in corso .... ");
			$("#messaggioAssistenza").html('<img src="immagini/move-spinner.gif" alt="Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioAssistenza").fadeIn("slow");
			
			setTimeout("richiediAssistenza('"+richAss+"')",2000);

		}
		return false;
	});	
	
	$("#submit_richiestaInfo").click(function(){
		var validAss = '';
		var nome = $("#ATnewNome_ti").val();
		var cognome = $("#ATnewCognome_ti").val(); 
		var azienda = $("#ATnewAzienda_ti").val(); 
		var citta = $("#ATnewCitta_ti").val(); 
		var telefono = $("#ATnewTel_ti").val();  
		var email = $("#ATnewEmail_ti").val();
		var nazione =  $("#ATnewNazione_ti").val();
		var prov =  $("#ATnewPROV_ti").val();
		var indirizzo =  $("#ATnewIndirizzo_ti").val();
		var cap =  $("#ATnewCAP_ti").val();	
		var ruolo = $("#ATnewRuolo_ti").val();	
		var sw = "informazioni generiche";
		var note = $("#messaggioinfo_ta").val();

		if( (nome.length<1)  || (cognome.length<1)  || (azienda.length<1)  || (citta.length<1)  || (telefono.length<1) || (note.length<1)   || (prov.length<1)  || (indirizzo.length<1)  || (cap.length<1)  || (ruolo.length<1) || (nazione.length<1)  )  {
			validAss = 'Verifica i dati inseriti';
		}

		
		if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			validAss = 'Verifica i dati inseriti';
		}
		
		if (validAss !='') {
			document.getElementById("messaggioAssistenza").style.backgroundColor = "#C00";
			document.getElementById("messaggioAssistenza").style.color = "#FFF";
			$("#messaggioAssistenza").fadeIn("slow");
			$("#messaggioAssistenza").html(validAss);
		
		}else {
			
		var richInf ='nome=' + nome + '&email=' + email + '&cognome=' + cognome + '&azienda=' + azienda + '&ruolo=' + ruolo + '&citta=' + citta+ '&telefono=' + telefono + '&nazione=' + nazione+ '&indirizzo=' + indirizzo+ '&prov=' + prov+ '&cap=' + cap + '&sw=' + sw + '&note=' + note;
			$("#messaggioAssistenza").css("display", "block");
			document.getElementById("messaggioAssistenza").style.backgroundColor = "#FFF";	
			document.getElementById("messaggioAssistenza").style.color = "#000";
			//$("#messaggioNewUser").html("Inoltro richiesta in corso .... ");
			$("#messaggioAssistenza").html('<img src="immagini/move-spinner.gif" alt=" Invio richiesta in corso.... " /> Invio richiesta in corso.... ');
			$("#messaggioAssistenza").fadeIn("slow");
			
			setTimeout("richiediInfo('"+richInf+"')",2000);

		}
		return false;
	});		
	
});

function sendUpdateUser(datastr){
	$.ajax({	
		type: "POST",
		url: "aggiornaDatiAzienda.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'Aggiornamento avvenuto'){
				document.getElementById("messaggioUpdUser").style.backgroundColor = "#43C36E";	
				document.getElementById("messaggioUpdUser").style.color = "#000";		
				$("#messaggioUpdUser").fadeIn("slow");
				$("#messaggioUpdUser").html(html);
				$('.window').hide();
				apriPopupAggiornamentoUserAvvenuto();
			}else{
				document.getElementById("messaggioUpdUser").style.backgroundColor = "#C00";	
				document.getElementById("messaggioUpdUser").style.color = "#FFF";	
				$("#messaggioUpdUser").fadeIn("slow");
				$("#messaggioUpdUser").html(html);		
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});
}

function send(datastr){
	$.ajax({	
		type: "POST",
		url: "registraAzienda.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'Registrazione inoltrata correttamente'){
				document.getElementById("messaggioNewUser").style.backgroundColor = "#43C36E";	
				document.getElementById("messaggioNewUser").style.color = "#000";		
				$("#messaggioNewUser").fadeIn("slow");
				$("#messaggioNewUser").html(html);
				$('.window').hide();
				apriPopupRegistrazioneAvvenuta();
			}else{
				document.getElementById("messaggioNewUser").style.backgroundColor = "#C00";	
				document.getElementById("messaggioNewUser").style.color = "#FFF";	
				$("#messaggioNewUser").fadeIn("slow");
				$("#messaggioNewUser").html(html);		
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});
}

function iscrizioneNewsletter(datastr){
	$.ajax({	
		type: "POST",
		url: "iscrizioneNewsletter.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'Registrazione inoltrata correttamente'){
				document.getElementById("messaggioNewsletter").style.backgroundColor = "#43C36E";	
				document.getElementById("messaggioNewsletter").style.color = "#000";		
				$("#messaggioNewsletter").fadeIn("slow");
				$("#messaggioNewsletter").html(html);
				$('.window').hide();
				clear_form_elements('#formRegistrazioneNewsletter');
				apriPopupRegistrazioneNewsletterAvvenuta();
			}
			if(html == 'PRESENTE'){
				var msgTmp = "Email già registrata al servizio newsletter";
				document.getElementById("messaggioNewsletter").style.backgroundColor = "#C00";
				document.getElementById("messaggioNewsletter").style.color = "#FFF";
				$("#messaggioNewsletter").fadeIn("slow");
				$("#messaggioNewsletter").html(msgTmp);
				clear_form_elements('#formRegistrazioneNewsletter');
			}else{
				document.getElementById("messaggioNewsletter").style.backgroundColor = "#C00";	
				document.getElementById("messaggioNewsletter").style.color = "#FFF";	
				$("#messaggioNewsletter").fadeIn("slow");
				$("#messaggioNewsletter").html(html);		
				clear_form_elements('#formRegistrazioneNewsletter');
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});
}

function richiediAssistenza(datastr){
	$.ajax({	
		type: "POST",
		url: "richiediAssistenza.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'ok'){
				location.href="richiestaInviata.php";
			}else{
				document.getElementById("messaggioAssistenza").style.backgroundColor = "#C00";	
				document.getElementById("messaggioAssistenza").style.color = "#FFF";	
				$("#messaggioAssistenza").fadeIn("slow");
				$("#messaggioAssistenza").html(html);		
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});
}

function richiediInfo(datastr){
	$.ajax({	
		type: "POST",
		url: "richiediInfo.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'ok'){
				location.href="richiestaInviata2.php";
			}else{
				document.getElementById("messaggioAssistenza").style.backgroundColor = "#C00";	
				document.getElementById("messaggioAssistenza").style.color = "#FFF";	
				$("#messaggioAssistenza").fadeIn("slow");
				$("#messaggioAssistenza").html(html);		
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});	
}

function recuperaPassword(datastr){
	$.ajax({	
		type: "POST",
		url: "recuperaPassword.php",
		data: datastr,
		cache: false,
		success: function(html){
			
			if(html == 'Dati inviati'){
				var msg = "Ti è stata inviata una mail con i tuoi dati";
				document.getElementById("messaggioOldUser").style.backgroundColor = "#43C36E";	
				document.getElementById("messaggioOldUser").style.color = "#000";		
				$("#messaggioOldUser").fadeIn("slow");
				$("#messaggioOldUser").html(msg);
				$('.window').hide();
				apriPopupRecuperoPassword();
			}else{
				document.getElementById("messaggioOldUser").style.backgroundColor = "#C00";	
				document.getElementById("messaggioOldUser").style.color = "#FFF";	
				$("#messaggioOldUser").fadeIn("slow");
				$("#messaggioOldUser").html(html);		
			}
			//setTimeout('$("#messaggioNewUser").fadeOut("slow")',2000);
		}
	});
}

function controlloLogin(datastr){
	$.ajax({	
		type: "POST",
		url: "controlloLogin.php",
		data: datastr,
		cache: false,
		success: function(html){
			if(html == 'ok'){
				location.reload(); 
				// logga utente e ricarica la pagina
			}else{
				apriPopupDatiErrati();
			}
		}
	});
}

function controlloVolumeIDSR(stringaActify){
	$.ajax({	
		type: "POST",
		url: "connectionActify.php",
		//url: "testConnectionActify.php",
		data: stringaActify,
		cache: false,
		success: function(html){
		//alert(html);			
		
		if(html == 'verificato'){
				clear_form_elements('#formRegistrazione');
				$('#mask').hide();
				$('.window').hide();
				location.href="spinfireReaderDownload.php";
			}else{	
				$("#messaggioDownloadR").css("display", "block");
				document.getElementById("messaggioDownloadR").style.backgroundColor = "#C00";	
				document.getElementById("messaggioDownloadR").style.color = "#FFF";	
				$("#messaggioDownloadR").html(html);	
				$("#messaggioDownloadR").fadeIn("slow");		
				clear_form_elements('#formRegistrazione');
			}
			
		}

	});
}

function controlloVolumeID(stringaActify){
	//alert("http://www.actify.com/license_requestor/sf.php" + stringaActify);
	/*type=sfp_trial' + '&first_name=' + nome +  '&last_name=' + cognome+ '&company=' + azienda + '&title=' + ruolo + '&phone=' + telefono + '&email=' + email + '&address1=' + indirizzo+ '&address2=none' + '&city=' + citta + '&country=' + nazione+ '&state=_&zip_code=' + cap+'&salutation=Mr&comments=' + note  + '&language=' + lingua + '&partner_id=2n5222fk&volume_id=' + volumeID*/
	/*$.ajax({	
		type: "POST",
		url: "connectionActify.php",
		//url: "testConnectionActify.php",
		data: stringaActify,
		cache: false,
		success: function(html){
		//alert(html);			
		
		if(html == 'verificato'){
				clear_form_elements('#formRegistrazione');
				$('#mask').hide();
				$('.window').hide();
				location.href="spinfireDownloads.php";
			}else{	
				$("#messaggioDownload").css("display", "block");
				document.getElementById("messaggioDownload").style.backgroundColor = "#C00";	
				document.getElementById("messaggioDownload").style.color = "#FFF";	
				$("#messaggioDownload").html(html);	
				$("#messaggioDownload").fadeIn("slow");		
				clear_form_elements('#formRegistrazione');
			}
			
		}

	});*/
	location.href="spinfireProDownload.php";
}

function aggiornamentoLicenza(datastr){
	$.ajax({	
		type: "POST",
		url: "aggiornamentoLicenzaSpinfire.php",
		data: datastr,
		cache: false,
		success: function(html){
			if(html == 'ok'){
				clear_form_elements('#formRegistrazione');
				//e.preventDefault();
				$('#mask').hide();
				$('.window').hide();
				//alert("Scarica quello che vuoi!");
				location.href="spinfireDownloads.php";
			}else{
				clear_form_elements('#formRegistrazione');
				//e.preventDefault();
				$('#mask').hide();
				$('.window').hide();
				alert("Problema di acceso al server");
			}
		}
	});
}

function richiestacrosscad(datastr){
	$.ajax({	
		type: "POST",
		url: "reqDemoStep2.php",
		data: datastr,
		cache: false,
		success: function(html){
			if(html == 'ok'){
				clear_form_elements('#formAssistenzaTecnica');
				//e.preventDefault();
				$('#mask').hide();
				$('.window').hide();
				//alert("Scarica quello che vuoi!");
				location.href="reqDemoCompletata.php";
			}else{
				$("#messaggioDemoCrosscad").css("display", "block");
				document.getElementById("messaggioDemoCrosscad").style.backgroundColor = "#C00";	
				document.getElementById("messaggioDemoCrosscad").style.color = "#FFF";	
				$("#messaggioDemoCrosscad").html(html);	
				$("#messaggioDemoCrosscad").fadeIn("slow");		
				clear_form_elements('#formAssistenzaTecnica');
			}
		}
	});
}

function richiestaweightcalculus(datastr){
	$.ajax({	
		type: "POST",
		url: "reqWeightStep2.php",
		data: datastr,
		cache: false,
		success: function(html){
			if(html == 'ok'){
				clear_form_elements('#formAssistenzaTecnica');
				//e.preventDefault();
				$('#mask').hide();
				$('.window').hide();
				//alert("Scarica quello che vuoi!");
				location.href="reqWeightCompletata.php";
			}else{
				$("#messaggioDemoWeight").css("display", "block");
				document.getElementById("messaggioDemoWeight").style.backgroundColor = "#C00";	
				document.getElementById("messaggioDemoWeight").style.color = "#FFF";	
				$("#messaggioDemoWeight").html(html);	
				$("#messaggioDemoWeight").fadeIn("slow");		
				clear_form_elements('#formAssistenzaTecnica');
			}
		}
	});
}




function salvataggioDownload(datastr){
	$.ajax({	
		type: "POST",
		url: "salvaDownload.php",
		data: datastr,
		cache: false,
		success: function(html){
			if(html == 'ok'){
				
			}else{
				e.preventDefault();
				alert("Problema di acceso al server");
			}
		}
	});
}