/* funtions.js
*/
function openNaplesLinksWin(popURL,windowName){
    popOpts = "height=500,width=890,top=10,left=60,location=yes,menubar=yes,";
    popOpts += "resizable=yes,scrollbars=yes,status=yes,toolbar=yes,titlebar=yes";
    popWin = window.open(popURL, "", popOpts);
    popWin.opener = self;
    popWin.focus();
}

function openFloorPlanWin(popURL,windowName){
    popOpts = "height=650,width=500,top=1,left=242,location=no,menubar=no,";
    popOpts += "resizable=yes,scrollbars=yes,status=no,toolbar=no,titlebar=no";
    popWin = window.open(popURL, "", popOpts);
    popWin.opener = self;
    popWin.focus();
}

function openScorecardWin(popURL,windowName){
    popOpts = "height=650,width=925,top=1,left=45,location=no,menubar=no,";
    popOpts += "resizable=yes,scrollbars=yes,status=no,toolbar=no,titlebar=no";
    popWin = window.open(popURL, "", popOpts);
    popWin.opener = self;
    popWin.focus();
}

function openMapWin(popURL,windowName){
    popOpts = "height=500,width=980,top=100,left=25,location=no,menubar=no,";
    popOpts += "resizable=yes,scrollbars=yes,status=no,toolbar=no,titlebar=no";
    popWin = window.open(popURL, "", popOpts);
    popWin.opener = self;
    popWin.focus();
}

/*
    var yearStartTot = Number((yearStart.concat(monthStart)).concat(dayStart));
    var yearEndTot   = Number((yearEnd.concat(monthEnd)).concat(dayEnd));
    alert("start year index: " + yearStartIX + " end year index: " + yearEndIX);
    alert("start year value: " + document.forms[0].year_start.options[yearStartIX].value);
    alert("end year value: " + document.forms[0].year_end.options[yearEndIX].value);
    alert("start year: " + yearStart + " end year: " + yearEnd);
    alert(yearStart + monthStart + dayStart + " " + yearEnd + monthEnd + dayEnd);
    alert("yearStartTot: " + yearStartTot);
    alert("yearEndTot: " + yearEndTot);
    alert("Start = " + ((((Date.parse(dateStart)/1000)/60)/60)/24) + " End = " + ((((Date.parse(dateEnd)/1000)/60)/60)/24) +     alert("dateDiff = " + dateDiff);
" difference = " + Math.round((((((Date.parse(dateEnd)/1000)/60)/60)/24) - ((((Date.parse(dateStart)/1000)/60)/60)/24))));
*/
function checkvalue(){
    var dayStartIX   = document.forms[0].day_start.selectedIndex;
    var monthStartIX = document.forms[0].month_start.selectedIndex;
    var yearStartIX  = document.forms[0].year_start.selectedIndex;
    var dayEndIX     = document.forms[0].day_end.selectedIndex;
    var monthEndIX   = document.forms[0].month_end.selectedIndex;
    var yearEndIX    = document.forms[0].year_end.selectedIndex;
    var dayStart     = document.forms[0].day_start.options[dayStartIX].value;
    var monthStart   = document.forms[0].month_start.options[monthStartIX].value;
    var yearStart    = document.forms[0].year_start.options[yearStartIX].value;
    var dayEnd       = document.forms[0].day_end.options[dayEndIX].value;
    var monthEnd     = document.forms[0].month_end.options[monthEndIX].value;
    var yearEnd      = document.forms[0].year_end.options[yearEndIX].value;
    dateStart = new Date();
    dateStart.setMonth(monthStart - 1);
    dateStart.setDate(dayStart);
    dateStart.setYear(yearStart);
    dateEnd = new Date();
    dateEnd.setMonth(monthEnd - 1);
    dateEnd.setDate(dayEnd);
    dateEnd.setYear(yearEnd);
    millisecStart = dateStart.getTime();
    millisecEnd = dateEnd.getTime();
    if (document.forms[0].name.value == '') {
        alert("Please enter your name.");
        return false;
    }
    else
    if (document.forms[0].phone.value == '' && document.forms[0].email.value == '') {
       alert("Please enter either your phone number or email address.");
        return false;
    }
    else
/*
Arrival Date and Departure Date have been converted to dateStart and dateEnd.  Each date is converted to the number of
milliseconds since 1/1/1970.
*/
    if (dateStart.getTime() > dateEnd.getTime()) {
        alert("Arrival date must preceed departure date.");
        return false;
    }
    else
/*
The two converted dates are then converted to seconds, minutes, hours , and then days.  The rounded difference plus 1 day between the two dates is then calculated.  The extra day is added because, for example, March 31 - March 1 should be 31 days, not 30.
*/
    dateDiff = Math.round( ((((Date.parse(dateEnd)/1000)/60)/60)/24) - ((((Date.parse(dateStart)/1000)/60)/60)/24) ) + 1;
    if (dateDiff < 28) {
        alert("We require a one month minimum stay.");
        return false;
    }
    else
       return true;
}