//
// JavaScript Utilities
// Copyright (c) 2003 Gulliver S.r.L.
// All Rights Reserved.
//
//----------------------------------------------------------------------------------------------------

function cOn(td){
    if(document.getElementById||(document.all && !(document.getElementById))){
        td.style.backgroundColor="#D8EAFF";
    }
}

function cOut(td){
    if(document.getElementById||(document.all && !(document.getElementById))){
        td.style.backgroundColor="#FFFFFF";
    }
}

function cOnServizi(td){
    if(document.getElementById||(document.all && !(document.getElementById))){
        td.style.backgroundColor="#88cfff";
    }
}

function cOutServizi(td){
    if(document.getElementById||(document.all && !(document.getElementById))){
        td.style.backgroundColor="#e6e7e8";
    }
}

//----------------------------------------------------------------------------------------------------

function gespiReference(img) {
	var subMenu1 = document.getElementById('gespiBig');
	subMenu1.innerHTML = '<img src="stampa_digitale/fotogallery/' + img + '" width="435" height="325" alt="manifestazioni sciistiche, cartellonistica e stampa digitale" border="1"/>';
}

function openbrex(lang) {
	var lingua = lang;

	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 if (lingua == "DE" || lingua == "FR"){
		alert("Lingua al momento non disponibile. ");
	} else {
        document.brexForm.USER.value = userTextCtrlValue;
        document.brexForm.PWD.value  = passwordCtrlValue;
		document.brexForm.LANG.value = lingua;
    	document.brexForm.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 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 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 (phoneTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.phoneTextCtrl.focus();
	} else if (emailTextCtrlValue == '') {
		showAlert = true;
		document.couponForm.emailTextCtrl.focus();
	} else if (textareaCtrlValue == '') {
		showAlert = true;
		document.couponForm.textareaCtrl.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 = "Gespi";
		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 Telefono:        " + phoneTextCtrlValue +
						"\r\n E-mail:          " + emailTextCtrlValue +
						"\r\n========================================================\r\n" +
						"\r\n\r\n" +
					    textareaCtrlValue;
		showSendMailDlgBox(to, from, "-COUPON- Contatto da web", body, emailTextCtrlValue);
	} else {
		alert("Hai scritto l'indirizzo di posta elettronica in modo errato. ");
		document.couponForm.emailTextCtrl.select();
		document.couponForm.emailTextCtrl.focus();
	}
}

    function loadSearchResultsPage() {
        var searchTextCtrl = document.searchForm.searchCtrl;
    	var searchTextCtrlValue = searchTextCtrl.value;
     	if (searchTextCtrlValue == '') {
      	  alert("Devi specificare qualcosa da cercare prima di avviare una ricerca.");
            document.searchForm.searchCtrl.focus();
    	} else {
      	    document.searchResultsPageForm.searchText.value = searchTextCtrlValue;
            document.searchResultsPageForm.submit();
    	}
    }

    function loadCataloguePage(pageIndex, sectionCode, subsection1Code, subsection2Code,
        subsection3Code, subsection4Code) {
        document.cataloguePageForm.pageIndex.value = pageIndex;
        document.cataloguePageForm.sectionCode.value = sectionCode;
        document.cataloguePageForm.subsection1Code.value = subsection1Code;
        document.cataloguePageForm.subsection2Code.value = subsection2Code;
        document.cataloguePageForm.subsection3Code.value = subsection3Code;
        document.cataloguePageForm.subsection4Code.value = subsection4Code;
        document.cataloguePageForm.submit();
    }

	function showGotoPageDlgBox(lastPageIndex) {
	    oLastPageIndex = lastPageIndex;
	    openBrWindow("dlgbox-gotopg.htm", "gotoPageDlgBoxWin", "width=280,height=165");
	}

    function loadSearchResultsPageByText(pageIndex, newSearchFlag, searchText) {
        if (newSearchFlag) {
      	    document.searchResultsPageForm.pageIndex.value = pageIndex;
            document.searchResultsPageForm.searchText.value = searchText;
            document.searchResultsPageForm.submit();
        } else {
      	    document.searchResultsPageForm.pageIndex.value = pageIndex;
            document.searchResultsPageForm.submit();
        }
    }

	function servizi(cod) {
		document.cataloguePageForm.sectionCode.value = cod;
		document.cataloguePageForm.submit();
	}
