//
// JavaScript Utilities
// Copyright (c) 2003 Gulliver S.r.L.
// All Rights Reserved.
//
//-------------------------------------------------------------------
  
function preloadImg() {
    MM_preloadImages('controllo_remoto/controllo_remoto_pc.gif',	
					 'controllo_remoto/gservice_03_1.jpg', 
					 'controllo_remoto/gservice_05_1.jpg', 
					 'controllo_remoto/gservice_07_1.jpg', 
					 'controllo_remoto/gservice_13_1.jpg', 
					 'controllo_remoto/gservice_15_1.jpg', 
					 'controllo_remoto/gservice_17_1.jpg',
					 'controllo_remoto/gservice_19_1.jpg',					 
                     'controllo_remoto/gservice_39_1.gif');                             
}

//-------------------------------------------------------------------
// Funzione login GService
function loginGService() {
	var userValue 		  = document.logonForm.userTextCtrl.value;
	var passwordValue 	  = document.logonForm.passwordCtrl.value;
	this.browserName 	  = navigator.appName;
	
	var showAlert = false;
  	if (userValue == '') {
		showAlert = true;
		document.logonForm.userTextCtrl.focus();
  	} else if (passwordValue == '') {
		showAlert = true;
		document.logonForm.passwordCtrl.focus();
	}
	
  	if (showAlert) {
		alert("User e Password sono obbligatori.");
  	} else if(browserName != "Microsoft Internet Explorer") {
		alert("GService al momento è abilitato solo per Microsoft Internet Explorer.");
	} else {
		document.LoginForm.USER.value 		= userValue;
		document.LoginForm.PASSWORD.value 	= passwordValue;
		document.LoginForm.submit();
	}
	
}

//-------------------------------------------------------------------
// Funzione registrazione newsletter GService
function newsletterGService() {
	var emailValue 		  = document.couponForm.email.value;

	var showAlert = false;
	  if (emailValue == '') {
		showAlert = true;
		document.couponForm.email.focus();
	  }

	  if (showAlert) {
		alert("Hai omesso uno o più campi obbligatori.");
	  } else if (isValidEmailAddrs(emailValue)) {
			 document.sendMailForm.email.value 		= emailValue;			 
			 document.sendMailForm.submit();
	  } else {
		alert("Hai scritto l'indirizzo di posta elettronica in modo errato.");
		document.couponForm.email.select();
		document.couponForm.email.focus();
	  }
}

//-------------------------------------------------------------------
// Funzione richiesta demo GService
function demoGService() {
	var nomeValue 		  = document.couponForm2.nome.value;
	var cognomeValue 	  = document.couponForm2.cognome.value;
	var aziendaValue 	  = document.couponForm2.azienda.value;
	var cityValue    	  = document.couponForm2.city.value;
	var telefonoValue 	  = document.couponForm2.telefono.value;
	var emailValue 		  = document.couponForm2.email.value;
	var privacyValue 	  = getCheckedValue(document.couponForm2.privacy);

	var showAlert = false;
	  if (aziendaValue == '') {
		showAlert = true;
		document.couponForm2.azienda.focus();
	  } else if (cityValue == '') {
		showAlert = true;
		document.couponForm2.city.focus();
	  } else if (nomeValue == '') {
		showAlert = true;
		document.couponForm2.nome.focus();
	  } else if (cognomeValue == '') {
		showAlert = true;
		document.couponForm2.cognome.focus();
	  } else if (emailValue == '') {
		showAlert = true;
		document.couponForm2.email.focus();
	  } else if (telefonoValue == '') {
		showAlert = true;
		document.couponForm2.telefono.focus();
	  }

	  if (showAlert) {
		alert("Hai omesso uno o più campi obbligatori.");
	  } else if (privacyValue != 'si') {
		alert("Devi autorizzare il trattamento dei dati personali.");
	  } else if (isValidEmailAddrs(emailValue)) {

		 document.sendMailForm2.nome.value 			= nomeValue;
		 document.sendMailForm2.cognome.value 		= cognomeValue;
		 document.sendMailForm2.city.value 			= cityValue;
		 document.sendMailForm2.azienda.value 		= aziendaValue
		 document.sendMailForm2.telefono.value 		= telefonoValue;
		 document.sendMailForm2.email.value 		= emailValue;
		 document.sendMailForm2.testo.value 		= "Vorrei avere la possibilià di provare gratuitamente GService per 15 gg.";		 
		 document.sendMailForm2.submit();
						 
	  } else {
		alert("Hai scritto l'indirizzo di posta elettronica in modo errato.");
		document.couponForm2.email.select();
		document.couponForm2.email.focus();
	  }
}

//-------------------------------------------------------------------
// Funzione contatti GService
function contattiGService() {
	var nomeValue 		  = document.couponForm3.nome.value;
	var cognomeValue 	  = document.couponForm3.cognome.value;
	var aziendaValue 	  = document.couponForm3.azienda.value;
	var cityValue    	  = document.couponForm3.city.value;
	var telefonoValue 	  = document.couponForm3.telefono.value;
	var emailValue 		  = document.couponForm3.email.value;
	var testoValue		  = document.couponForm3.testo.value;	
	var privacyValue 	  = getCheckedValue(document.couponForm3.privacy);

	var showAlert = false;
	  if (aziendaValue == '') {
		showAlert = true;
		document.couponForm3.azienda.focus();
	  } else if (cityValue == '') {
		showAlert = true;
		document.couponForm3.city.focus();
	  } else if (nomeValue == '') {
		showAlert = true;
		document.couponForm3.nome.focus();
	  } else if (cognomeValue == '') {
		showAlert = true;
		document.couponForm3.cognome.focus();
	  } else if (emailValue == '') {
		showAlert = true;
		document.couponForm3.email.focus();
	  } else if (telefonoValue == '') {
		showAlert = true;
		document.couponForm3.telefono.focus();
	  } else if (testoValue == '') {
		showAlert = true;
		document.couponForm3.testo.focus();
	  }

	  if (showAlert) {
		alert("Hai omesso uno o più campi obbligatori.");
	  } else if (privacyValue != 'si') {
		alert("Devi autorizzare il trattamento dei dati personali.");
	  } else if (isValidEmailAddrs(emailValue)) {

		 document.sendMailForm3.nome.value 			= nomeValue;
		 document.sendMailForm3.cognome.value 		= cognomeValue;
		 document.sendMailForm3.city.value 			= cityValue;
		 document.sendMailForm3.azienda.value 		= aziendaValue
		 document.sendMailForm3.telefono.value 		= telefonoValue;
		 document.sendMailForm3.email.value 		= emailValue;
		 document.sendMailForm3.testo.value 		= testoValue;		 		 
		 document.sendMailForm3.submit();
						 
	  } else {
		alert("Hai scritto l'indirizzo di posta elettronica in modo errato.");
		document.couponForm3.email.select();
		document.couponForm3.email.focus();
	  }
}

