/********************************************************************************************/
function popup(path, width, height, target) {
    if (target == "" || target == "undefined") target = "_blank";
    if (width == "" || width == "undefined") width = 500;
    if (height == "" || height == "undefined") height = 460;
    features = "width=" + width + ", height=" + height + ", scrollbars=1 status=1 resizable=no";

    sWidth = 1024;
    sHeight = 768;
    if (typeof (screen) == 'object') {
        sWidth = screen.width;
        sHeight = screen.height;
    }

    xPos = (sWidth - width) / 2;
    yPos = (sHeight - height) / 2;

    window_handle = window.open(path, target, features);
    //window_handle.moveTo(xPos, yPos);
    window_handle.focus();
}
/********************************************************************************************/

/********************************************************************************************/
function isemail(myemail) {
    Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    if (Filtro.test(myemail)) return true;
    else return false;
}
/********************************************************************************************/

/********************************************************************************************/
function guestbookSubmit() 
{
    document.formPage.fName.style.backgroundColor = "#FFFFFF";
    document.formPage.fEmail.style.backgroundColor = "#FFFFFF";
    document.formPage.fBody.style.backgroundColor = "#FFFFFF";
    document.formPage.fCaptcha.style.backgroundColor = "#FFFFFF";

    var error = "";

    if (document.formPage.fCaptcha.value == "") {
        error = "\n- Digitare i caratteri riportati nell'immagine di controllo"+error;
        document.formPage.fBody.style.backgroundColor = "#FFCC00";
        document.formPage.fBody.focus();
    }

    if (document.formPage.fBody.value == "") 
    {
        error = "\n- Testo del messaggio obbligatorio" + error;
        document.formPage.fBody.style.backgroundColor = "#FFCC00";
        document.formPage.fBody.focus();
    }

    if (document.formPage.fEmail.value == "" ||
    	!isemail(document.formPage.fEmail.value)) 
    {
        error = "\n- Email in formato non corretto" + error;
        document.formPage.fEmail.style.backgroundColor = "#FFCC00";
        document.formPage.fEmail.focus();
    }

    if (document.formPage.fName.value == "") {
        error = "\n- Nome obbligatorio" + error;
        document.formPage.fName.style.backgroundColor = "#FFCC00";
        document.formPage.fName.focus();
    }

    if (error != "") 
    {
        alert(error);
        return;
    }

    document.formPage.submit();
}
/********************************************************************************************/

/********************************************************************************************/
function guestbookReset() 
{
    document.formPage.fName.style.backgroundColor = "#FFFFFF";
    document.formPage.fEmail.style.backgroundColor = "#FFFFFF";
    document.formPage.fBody.style.backgroundColor = "#FFFFFF";

    document.formPage.fName.value = "";    
    document.formPage.fEmail.value = "";
    document.formPage.fBody.value = "";
}
/********************************************************************************************/

/********************************************************************************************/
function reserveSubmit() {
    document.formPage.fName.style.backgroundColor = "#FFFFFF";
    document.formPage.fSurname.style.backgroundColor = "#FFFFFF";
    document.formPage.fEmail.style.backgroundColor = "#FFFFFF";
    document.formPage.fTel.style.backgroundColor = "#FFFFFF";
    document.formPage.fDateFrom.style.backgroundColor = "#FFFFFF";
    document.formPage.fDateTo.style.backgroundColor = "#FFFFFF";
    document.formPage.fBeds.style.backgroundColor = "#FFFFFF";

    var error = "";

    if (document.formPage.fBeds.value == "") {
        error += "\n- Campo \"Numero posti\" obbligatorio";
        document.formPage.fBeds.style.backgroundColor = "#FFCC00";
        document.formPage.fBeds.focus();
    }

    if (document.formPage.fDateTo.value == "") {
        error += "\n- Campo \"Al giorno\" obbligatorio";
        document.formPage.fDateTo.style.backgroundColor = "#FFCC00";
        document.formPage.fDateTo.focus();
    }

    if (document.formPage.fDateFrom.value == "") {
        error += "\n- Campo \"Dal giorno\" obbligatorio";
        document.formPage.fDateFrom.style.backgroundColor = "#FFCC00";
        document.formPage.fDateFrom.focus();
    }
    if (document.formPage.fTel.value == "") {
        error += "\n- Campo \"Telefono\" obbligatorio";
        document.formPage.fTel.style.backgroundColor = "#FFCC00";
        document.formPage.fTel.focus();
    }

    if (document.formPage.fEmail.value == "" ||
    	!isemail(document.formPage.fEmail.value)) {
        error += "\n- Campo \"Email\" in formato non corretto";
        document.formPage.fEmail.style.backgroundColor = "#FFCC00";
        document.formPage.fEmail.focus();
    }

    if (document.formPage.fSurname.value == "") {
        error += "\n- Campo \"Cognome\" obbligatorio";
        document.formPage.fSurname.style.backgroundColor = "#FFCC00";
        document.formPage.fSurname.focus();
    }

    if (document.formPage.fName.value == "") {
        error += "\n- Campo \"Nome\" obbligatorio";
        document.formPage.fName.style.backgroundColor = "#FFCC00";
        document.formPage.fName.focus();
    }

    if (error != "") {
        alert(error);
        return;
    }

    document.formPage.submit();
}
/********************************************************************************************/
