// 
// Copyright (c) 2004 Gulliver S.r.L.
// All Rights Reserved.
//
// DATE: 17-03-2004
// AUTORE: Fabio Pierani
//
//----------------------------------------------------------------------------------------------------
//
// Variabili
//
		
		var oCopy;  
		var oTo;
		var oFrom;
		var oSubject;
		var oBody;   
		var oEmail;
        
//
//----------------------------------------------------------------------------------------------------
// 
// Funzione di preload immagini
// 

function preloadImg() {
    MM_preloadImages('lettori_barcode/spacer.gif',	
					 'lettori_barcode/rilevazione_presenze_38_2.jpg',
                     'lettori_barcode/rilevazione_presenze_23_2.jpg',
                     'lettori_barcode/rilevazione_presenze_25_2.jpg',
                     'lettori_barcode/rilevazione_presenze_27_2.jpg',
                     'lettori_barcode/rilevazione_presenze_29_2.jpg',
                     'lettori_barcode/rilevazione_presenze_31_2.jpg',
                     'lettori_barcode/rilevazione_presenze_33_2.jpg',					 
                     'lettori_barcode/rilevazione_presenze_35_2.jpg',					 
                     'lettori_barcode/rilevazione_presenze_38_1.jpg',
                     'lettori_barcode/rilevazione_presenze_23_1.jpg',
                     'lettori_barcode/rilevazione_presenze_25_1.jpg',
                     'lettori_barcode/rilevazione_presenze_27_1.jpg',
                     'lettori_barcode/rilevazione_presenze_29_1.jpg',
                     'lettori_barcode/rilevazione_presenze_31_1.jpg',
                     'lettori_barcode/rilevazione_presenze_33_1.jpg',					 
                     'lettori_barcode/rilevazione_presenze_35_1.jpg');                             
}

function doLogon() {
  var userTextCtrlValue = document.logonForm.userTextCtrl.value;
  var passwordCtrlValue = document.logonForm.passwordCtrl.value;

  if (userTextCtrlValue == '') {
    alert("Devi specificare un nome utente ed una password per l'accesso. ");
    document.logonForm.userTextCtrl.focus();
  } else if (passwordCtrlValue == '') {
    alert("Devi specificare un nome utente ed una password per l'accesso. ");
    document.logonForm.passwordCtrl.focus();
  } else {        
        document.brexForm.USER.value = userTextCtrlValue;
        document.brexForm.PWD.value = passwordCtrlValue;
    	document.brexForm.submit();
  }
}

//----------------------------------------------------------------------------------------------------
//
// Funzioni di apertura pagina
//

		function menu() {
			// NON FA NULLA
		}
		
		function prodotti() {
			document.pageForm.GB_TYPER.value = "CODICE_A_BARRE_PRODOTTI";
		  	document.pageForm.submit();
		}
		
		function loadCataloguePage(sectionCode) {
          document.cataloguePageForm.sectionCode.value = sectionCode;
          document.cataloguePageForm.submit();
        } 		
		
        function showSchedaTecnica(scheda) {
		    var url = scheda;
		    var parametri="resizable=yes, width = 640, height = 480, location=no, top = 0, left = 0";
		    window.open( url, "SchedaTecnica", parametri);
		} 

//----------------------------------------------------------------------------------------------------
//
// Funzioni ricerca
//
		        
	function loadSearchResultsPageAll() {
	  var searchTextCtrl = document.searchForm.searchTextCtrl;
	  var searchTextCtrlValue = searchTextCtrl.value;

	  if (searchTextCtrlValue == '') {
		alert("Devi specificare qualcosa da cercare prima di avviare una ricerca. ");
		document.searchForm.searchTextCtrl.focus();
	  } else {
		document.searchResultsPageForm.searchText.value = searchTextCtrlValue;
		document.searchResultsPageForm.submit();
	  }
	}


		
// contatti

	function doOk() {
	  var nameTextCtrlValue = document.couponForm.nameTextCtrl.value;
	  var textareaCtrlValue = document.couponForm.textareaCtrl.value;
	  var surnameTextCtrlValue = document.couponForm.surnameTextCtrl.value;
	  var companyTextCtrlValue = document.couponForm.companyTextCtrl.value;
	  var activityTextCtrlValue = document.couponForm.activityTextCtrl.value;
	  var phoneTextCtrlValue = document.couponForm.phoneTextCtrl.value;
	  var emailTextCtrlValue = document.couponForm.emailTextCtrl.value;            	  
	  var viaTextCtrlValue = document.couponForm.viaTextCtrl.value;
	 var capTextCtrlValue = document.couponForm.capTextCtrl.value;
	 var cityTextCtrlValue = document.couponForm.cityTextCtrl.value;
	 var sectorTextCtrlValue = document.couponForm.sectorTextCtrl.value;
	 var tipoTextCtrlValue = document.couponForm.tipoTextCtrl.value;
	 var faxTextCtrlValue = document.couponForm.faxTextCtrl.value;
	 var privacyTextCtrlValue = getCheckedValue(document.couponForm.privacyTextCtrl);
	 
	  var body;
	  var to;
	  var from;

	  var showAlert = false;

	  if (nameTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.nameTextCtrl.focus();
	  } else if (surnameTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.surnameTextCtrl.focus();
	  } else if (companyTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.companyTextCtrl.focus();
	  } else if (viaTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.viaTextCtrl.focus();
	  } else if (capTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.capTextCtrl.focus();
	  } else if (cityTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.cityTextCtrl.focus();
	  } else if (sectorTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.sectorTextCtrl.focus();
	  } else if (activityTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.activityTextCtrl.focus();
	  } else if (phoneTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.phoneTextCtrl.focus();
	  } else if (faxTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.faxTextCtrl.focus();
	  } else if (emailTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.emailTextCtrl.focus();
	  } else if (textareaCtrlValue == '') {
		showAlert = true;
		document.couponForm.textareaCtrl.focus();
	  } else if (tipoTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.tipoTextCtrl.focus();
	  }

	  if (showAlert) {
		alert("Hai omesso uno o pił campi obbligatori. ");
	  } else if (privacyTextCtrlValue != 'autorizzo') {
		alert("Devi autorizzare il trattamento dei dati personali secondo la legge sulla privacy 675. ");
	  } else if (isValidEmailAddrs(emailTextCtrlValue)) {		
		to = "info@progetto6.it";
		from = nameTextCtrlValue + " " + surnameTextCtrlValue;		 
		body = 
					  "\r\n\r\n====================== INFO UTENTE ======================" +
						"\r\n Cognome:         " + surnameTextCtrlValue +
						"\r\n Nome:            " + nameTextCtrlValue +
						"\r\n Azienda:         " + companyTextCtrlValue +
						"\r\n Via:             " + viaTextCtrlValue +
						"\r\n Cap:             " + capTextCtrlValue +
						"\r\n Cittą:           " + cityTextCtrlValue +
						"\r\n Settore merc.:   " + sectorTextCtrlValue +
						"\r\n Ruolo aziendale: " + activityTextCtrlValue +
						"\r\n Telefono:        " + phoneTextCtrlValue +
						"\r\n Fax:             " + faxTextCtrlValue +
						"\r\n E-mail:          " + emailTextCtrlValue +
						"\r\n Cliente:         " + tipoTextCtrlValue +
						"\r\n========================================================\r\n" +
						"\r\n\r\n" + 
					  textareaCtrlValue;
		document.sendMailForm.nominativo.value 	= from;
		document.sendMailForm.to.value 			= to;
		document.sendMailForm.servizio.value 	= emailTextCtrlValue;
		document.sendMailForm.from.value 		= emailTextCtrlValue;
		document.sendMailForm.subject.value 	= "-COUPON- Contatto da web";
		document.sendMailForm.body.value 		= body;
		document.sendMailForm.submit();
	  } else {
		alert("Hai scritto l'indirizzo di posta elettronica in modo errato. ");
		document.couponForm.emailTextCtrl.select();
		document.couponForm.emailTextCtrl.focus();
	  }
	}