var oneDayMilli = 1000 * 60 * 60 * 24;

function addfav() {
    if (document.all)
        window.external.AddFavorite(bookmarkurl, bookmarktitle)
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function MM_openBrWindow(theURL, winName, features) { //v1.2
    window.open(theURL, winName, features);
}


function Form_Validator(theForm) {
    if (theForm.state.value == "none") {
        if (theForm.City.value == "") {
            if (theForm.motelnumber.value == "") {
            	alert("Please enter required fields.");
                theForm.City.focus();
                return (false);
            }
        }
    }
    return (theForm.submit());
}

function Date_valid(arrivalYearName, departureYearName, arrivalMonthName, departureMonthName, arrivalDayName, departureDayName) {
    var pass, tDateY1, tDateY2, tDateM1, tDateM2, tDateD1, tDateD2, today, thisDay, testAdate, testDdate, tmpAmo, tmpDmo;
    var errStr = ""
    if (arrivalYearName.value > 0 || departureYearName.value > 0 || arrivalMonthName.value > 0 || departureMonthName.value > 0 || arrivalDayName.value > 0 || departureDayName.value > 0) {
        if (arrivalYearName.value == "" || departureYearName.value == "" || arrivalMonthName.value == "" || departureMonthName.value == "" || arrivalDayName.value == "" || departureDayName.value == "") {
            pass = false;
            errStr = errStr + "Please enter a valid date.\n";
        } else {
            today = new Date();
            thisDay = new Date();
            testAdate = new Date(arrivalYearName.value, arrivalMonthName.value - 1, arrivalDayName.value, 0, 0, 0, 0);
            testDdate = new Date(departureYearName.value, departureMonthName.value - 1, departureDayName.value, 0, 0, 0, 0);
            thisDay.setYear(today.getFullYear());
            thisDay.setMonth(today.getMonth());
            thisDay.setDate(today.getDate());
            thisDay.setHours(0);
            thisDay.setMinutes(0);
            thisDay.setSeconds(0);
            thisDay.setMilliseconds(0);
            testAdateTime = testAdate.getTime();
            testDdateTime = testDdateTime;
            if (thisDay.getTime() > testAdateTime) {
                pass = false;
                errStr = errStr + "Arrival date cannot be a past date.\n";
            } else {
                diff = Number(testAdateTime - today.getTime());
                diff = Math.floor(diff / oneDayMilli);
                if (diff > 364) {
                    pass = false;
                    errStr = errStr + "Reservations may only be made 364 days in advance. Please select an earlier arrival date.\n";
                }
            }
            if (testAdateTime >= testDdateTime) {
                pass = false;
                errStr = errStr + "Please enter a departure date that falls after the arrival date.\n";
            }
            if (Math.floor((testDdateTime - testAdateTime) / oneDayMilli) > 28) {
                errStr = errStr + "A maximum of 28 days may be confirmed for an online reservation.  If request is for more than 28 days, please call 1-800-466-8356 for assistance.";
                pass = false;
            }
        }
    }
    if (pass == false) {
        return errStr;
    } else {
        return true;
    }
}

function Date_valid(arrivalMonthName, departureMonthName, arrivalDayName, departureDayName) {
    var pass, tDateY1, tDateY2, tDateM1, tDateM2, tDateD1, tDateD2, today, thisDay, testAdate, testDdate, tmpAmo, tmpDmo;
    var errStr = ""
    var arrivalMonthVal, arrivalDayVal, departureMonthVal, departureDayVal
    var departureMonthStrLen
    var arrivalMonthStrLen

    arrivalMonthVal = arrivalMonthName.value;
    arrivalDayVal = arrivalDayName.value;
    departureMonthVal = departureMonthName.value;
    departureDayVal = departureDayName.value;
    departureMonthStrLen = departureMonthVal.length;
    arrivalMonthStrLen = arrivalMonthVal.length;

    if (arrivalMonthVal > 0 || departureMonthVal > 0 || arrivalDayVal > 0 || departureDayVal > 0) {
        if (arrivalMonthVal == "" || departureMonthVal == "" || arrivalDayVal == "" || departureDayVal == "") {
            pass = false;
            errStr = errStr + "Please enter a valid date.\n";
        } else {
            today = new Date();
            thisDay = new Date();
            testAdate = new Date(arrivalMonthVal.substr(arrivalMonthStrLen - 4, 4), arrivalMonthVal.substr(0, arrivalMonthStrLen - 4) - 1, arrivalDayVal, 0, 0, 0, 0);
            testDdate = new Date(departureMonthVal.substr(departureMonthStrLen - 4, 4), departureMonthVal.substr(0, departureMonthStrLen - 4) - 1, departureDayVal, 0, 0, 0, 0);
            thisDay.setYear(today.getFullYear());
            thisDay.setMonth(today.getMonth());
            thisDay.setDate(today.getDate());
            thisDay.setHours(0);
            thisDay.setMinutes(0);
            thisDay.setSeconds(0);
            thisDay.setMilliseconds(0);
            testAdateTime = testAdate.getTime();
            testDdateTime = testDdate.getTime();

            if (thisDay.getTime() > testAdateTime) {
                pass = false;
                errStr = errStr + "Arrival date cannot be a past date.\n";
            } else {
                diff = Number(testAdateTime - today.getTime());
                diff = Math.floor(diff / oneDayMilli);
                if (diff > 364) {
                    pass = false;
                    errStr = errStr + "Reservations may only be made 364 days in advance. Please select an earlier arrival date.\n";
                }
            }
            if (testAdateTime >= testDdateTime) {
                pass = false;
                errStr = errStr + "Please enter a departure date that falls after the arrival date.\n";
            }
            if (Math.floor((testDdateTime - testAdateTime) / oneDayMilli) > 28) {
                errStr = errStr + "A maximum of 28 days may be confirmed for an online reservation.  If request is for more than 28 days, please call 1-800-466-8356 for assistance.";
                pass = false;
            }
        }
    }
    if (pass == false) {
        return errStr;
    } else {
        return true;
    }
}
function basic_Valid(theForm, errStr) {
    var pass = true;
    var errStr, thisMatch;
    var noSelect = -1;
    var arrYrNm = -1;
    var arrMoNm = -1;
    var arrDaNm = -1;
    var depYrNm = -1;
    var depMoNm = -1;
    var depDaNm = -1;
    var ATNm = -1;
    var addNm = -1;
    var addSch = 0;
    var cityNm = -1;
    var stateNm = -1;
    var zipNm = -1;
    var coNm = -1;
    var stateOK = 0;
    var zipOK = 0;
    var datesOK = 0;
    var ATOK = 0;
    var ADOK = 0;
    var RTfOK = 0;
    var RTdOK = 0;
    var propNumOK = 0;
    var justNumNLet = new RegExp('^[0-9]|[a-z]|[A-Z]');
    var dateErr = "";
    var hasValues = 0;
    var APATok = 0;
    var req = "required";
    var dotNETid = "mycontrol_"
    var dotNETname = "mycontrol:"
    var addressfield = "addy$";
    var attractionfield = "atttype$";
    var cityfield = "city$";
    var statefield = "state$";
    var zipfield = "zip$";
    var countryfield = "co$";
    var idfield = "num$";
    var routefrom = "from";
    var routeto = "destine";
    var adult = "numberofadults";
    var dateDirection1 = "arrival";
    var dateDirection2 = "departure";
    var dateY = "year";
    var dateM = "month";
    var dateD = "day";
    var adultNm = "";
    if (document.images) {
        for (i = 0; i < theForm.length; i++) {
            var tempobj = theForm.elements[i];
            if (tempobj != undefined) {
                var tempObjID = tempobj.id.toLowerCase();
                if (tempObjID != "__viewstate" && (tempObjID.match(addressfield) || tempObjID.match(attractionfield) || tempObjID.match(cityfield) || tempObjID.match(statefield) || tempObjID.match(zipfield) || tempObjID.match(countryfield) || tempobj.name.toLowerCase().match(dateDirection1) || tempObjID.match(dateDirection2) || tempobj.name.toLowerCase().match(adult) || tempobj.name.toLowerCase().match(idfield))) {
                    // Don't check the stuff if they are the extra .NET params
                    if (tempobj.name.toLowerCase().match(req)) {
                        // If a field is required, checks to make sure it is there
                        if (((tempobj.type == "text" || tempobj.type == "textarea") && tempobj.value == '') || ((tempobj.type.toString().charAt(0) == "s" && tempobj.selectedIndex == 0) && (tempobj.value == '' || tempobj.value == "none" || tempobj.value == "any"))) {
                            pass = false;
                            shortFieldName = tempobj.name;
                            shortFieldName = shortFieldName.replace(/required/i, "");
                            errStr = errStr + "Please make sure the " + shortFieldName + " field was properly completed.\n";
                        }
                    }

										// Determines if motel number is numeric
                    if (tempobj.id.toLowerCase().match(idfield)) {
                    	if (tempobj.value != "" && isNaN(tempobj.value)) {
                    		propNumOK = 1;
                    	}
                    }
                    
                    if (tempobj.id.toLowerCase().match(attractionfield)) {
                        // Determines if an attraction search is being done
                        ATOK = 1;
                        if (tempobj.value != "Any") {
                            ATNm = 1;
                        }
                    }

                    if (tempobj.id.toLowerCase().match(addressfield)) {
                        // Determines if an attraction search is being done
                        ADOK = 1;
                        if (tempobj.value != "") {
                            // Determines if data was entered into this box
                            addNm += 1;
                            APATok = 1;
                            // Validate route data entry
                            if (tempobj.id.toLowerCase().match(routefrom)) {
                                RTfOK += 1;
                            } else if (tempobj.id.toLowerCase().match(routeto)) {
                                RTdOK += 1;
                            }
                        }
                        else {
                            APATok = -1;
                        }
                    }

                    if (tempobj.id.toLowerCase().match(cityfield)) {
                        // Determines if the field exists on the form for address purposes
                        addSch = 1;
                        if (tempobj.value != "") {
                            // Determines if data was entered into this box
                            cityNm += 1;
                            // Validate route data entry
                            if (tempobj.id.toLowerCase().match(routefrom)) {
                                RTfOK += 1;
                            } else if (tempobj.id.toLowerCase().match(routeto)) {
                                RTdOK += 1;
                            }
                        }
                    }
                    if (tempobj.id.toLowerCase().match(statefield)) {
                        // state is also used on an attraction search, but it is optional
                        // so we're going to check for it seperately for route search
                        stateOK = 1;
                        if (tempobj.value != "" && tempobj.value != "none") {
                            // Determines if data was entered into this box
                            stateNm += 1;
                        }
                    }
                    if (tempobj.id.toLowerCase().match(zipfield)) {
                        // Determines if the field exists on the form for address purposes
                        addSch = 1;
                        if (tempobj.value != "" && tempobj.value != "none") {
                            // Determines if data was entered into this box
                            zipNm += 1;
                            // Validate route data entry
                            if (tempobj.id.toLowerCase().match(routefrom)) {
                                RTfOK += 1;
                            } else if (tempobj.id.toLowerCase().match(routeto)) {
                                RTdOK += 1;
                            }
                            if (!justNumNLet.test(tempobj.value)) {
                                //It is not a letter or a number and is not valid
                                zipOK = 1;
                            }
                            //						if(isNaN(escape(tempobj.value))){
                            //							if(isNaN(tempobj.value)){
                            //								// It is a letter
                            //								zipOK = 1;
                            //							}else{
                            //								// It is some unseen value that we can not use
                            //								theForm.elements[tempobj.name].value = "";
                            //							}
                            //						}
                        }
                    }
                    if (tempobj.id.toLowerCase().match(countryfield)) {
                        if (tempobj.value != "") {
                            // Determines if data was entered into this box
                            coNm += 1;
                        }
                    }
                    // Matches required and non-required
                    if (tempobj.name.toLowerCase().match(dateDirection1)) {
                        // Determines if it is an Arrival date field entry
                        if (tempobj.name.toLowerCase().match(dateM)) {
                            // Determines if this data is the month section of a date 
                            // and stores the form field index
                            arrMoNm = i;
                        }
                        if (tempobj.name.toLowerCase().match(dateD)) {
                            // Determines if this data is the day section of a date 
                            // and stores the form field index
                            arrDaNm = i;
                        }
                    }
                    if (dateDirection2.match(dateDirection2)) {
                        // Determines if it is an Departure date field entry
                        if (tempobj.name.toLowerCase().match(dateM)) {
                            // Determines if this data is the month section of a date 
                            // and stores the form field index
                            depMoNm = tempobj.name;
                        }
                        if (tempobj.name.toLowerCase().match(dateD)) {
                            // Determines if this data is the day section of a date 
                            // and stores the form field index
                            depDaNm = tempobj.name;
                        }
                    }
                    if (tempobj.name.toLowerCase().match(adult)) {
                        // Assigned the number of adults selected. If dates have been entered, 
                        // this field can NOT be empty
                        // And if this field is filled out, the dates can NOT be empty
                        adultNm = tempobj.value;
                    }

                    //Checks to see if all the fields are empty
                    if (tempobj.value != " " && tempobj.value != "" && tempobj.value.toLowerCase() != "any" && tempobj.value.toLowerCase() != "none") {
                        // We got a value
                        // But we don't want to count the default country value
                        if (tempobj.id.toLowerCase().match(countryfield) != "co") {
                            // We got a hit
                            noSelect = 1;
                            if (datesOK != 2) {
                                // If we've already determined that we have a date, 
                                // we don't want to wipe out that info
                                datesOK = 1;
                            }
                            hasValues += 1;
                            if (tempobj.name.toLowerCase().match(dateM) || tempobj.name.toLowerCase().match(dateD) || tempobj.name.toLowerCase().match(adult)) {
                                // It's a date
                                datesOK = 2;
                                hasValues -= 1;
                            }
                        }
                    }
                }
            }
        }
    }
    if (datesOK == 2) {
        //dateErr = Date_valid(theForm.elements[arrYrNm], theForm.elements[depYrNm], theForm.elements[arrMoNm], theForm.elements[depMoNm], theForm.elements[arrDaNm], theForm.elements[depDaNm]);
        dateErr = Date_valid(theForm.elements[arrMoNm], theForm.elements[depMoNm], theForm.elements[arrDaNm], theForm.elements[depDaNm]);
    }

    //DATE
    if (dateErr != true) {
        errStr = errStr + dateErr;
        pass = false;
    } else {
        if (errStr == "") {
            // Dates comparison checks out
            if (datesOK == 2) {
                // and they had valid values
                datesOK = 3;
            } else {
                // The dates comparison checked out, but was based on invalid values
                datesOK = -1;
            }
        }
    }
    //NO INFORMATION
    if (noSelect < 0) {
        // No information at all was entered
        pass = false;
        errStr = errStr + "Please enter required fields.\n";
    }

    //ADULTS
    if ((adultNm == "" || adultNm == "none") && datesOK > 2) {
        // Dates were entered without selecting the number of adults
        pass = false;
        errStr = errStr + "Please select how many adults will be staying.\n";
    } else if (adultNm >= 1 && datesOK > 2 && hasValues <= 0) {
        // Only Dates were entered
        pass = false;
        errStr = errStr + "Please search using more information than just the dates.\n";
    } else if (adultNm >= 1 && datesOK < 2) {
        // Number of adults was selected without entering any dates
        pass = false;
        errStr = errStr + "Please enter the dates the adult(s) will be arriving and departing.\n";
    }

    //AIRPORT/ATTRACTION
    if (APATok > 0 && ATOK==0 && (cityNm < 0 && stateNm < 0 && zipNm < 0) && addNm >= 0 && addSch > 0 && ADOK >= 1) {
        // .NET requirement
        pass = false;
        errStr = errStr + "Please enter either a City, State or Zip Code in addition to the address.\n";
       }
       if (ATOK > 0 && stateNm < 0) {
       	pass = false;
       	errStr = errStr + "Please select a State.\n";
       }
    if (ATOK > 0 && ATNm < 0 && noSelect > 0) {
        pass = false;
        errStr = errStr + "Please select an attraction type.\n";
    }
    if (ATOK > 0 && APATok < 0 && noSelect > 0) {
        pass = false;
        errStr = errStr + "Please select an attraction name.\n";
    }
    if ((ATOK <= 0 && APATok <= 0 && addNm < 0 && addSch <= 0) && noSelect >= 0 && ADOK >= 1) {
        pass = false;
        errStr = errStr + "Please enter an airport to search on.\n";
    }
    if (theForm.name == "LocateRoute" && stateOK > 0 && (RTfOK <= 0 || RTdOK <= 0)) {
        pass = false;
        errStr = errStr + "Please enter either an Address, City, or Zip Code in addition to the state.\n";
    }
    if (zipOK > 0 && noSelect > 0) {
        pass = false;
        errStr = errStr + "Please enter a valid postal code.\n";
    }
    if (propNumOK > 0) {
    	pass = false;
    	errStr = errStr + "Motel # must be a numeric value.\n";
    }

    if (pass == false) {
        return errStr;
    }
}

function act(imgName) {
    if (document.images)
        document[imgName].src = eval(imgName + "_on.src");
}

function inact(imgName) {
    if (document.images)
        document[imgName].src = eval(imgName + "_off.src");
}

function topWindow() {
    popup = window.open("/includes/Content/click6_terms.html", "", "height=400,width=450,scrollbars=yes,resizable=yes");
}

function checkDate(firstDate, secondDate) {
    alert("HI")
    if ((firstDate.value != "") && (secondDate.value != "")) {
        tDate1 = new Date(firstDate.value)
        tDate2 = new Date(secondDate.value)
        alert(tDate)
        alert(tDate2)
        if (tDate >= tDate2) {
            alert(tDate)
        }
    }
}
function checkrequired(which) {
    var pass = true;
    var errStr = "";
    if ((which.required_Arrival_Date.value != "") && (which.required_Departure_Date.value != "")) {
        tDate1 = new Date(which.required_Arrival_Date.value);
        tDate2 = new Date(which.required_Departure_Date.value);
        if (tDate1 >= tDate2) {
            pass = false;
            errStr = errStr + "Please enter a departure date that falls after the arrival date.\n";
        }
    }
    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name.substring(0, 8) == "required") {
                if (((tempobj.type == "text" || tempobj.type == "textarea") &&
					tempobj.value == '') || (tempobj.type.toString().charAt(0) == "s" &&
					tempobj.selectedIndex == 0)) {
                    pass = false;
                    shortFieldName = tempobj.name.substring(9, 30).toLowerCase();
                    errStr = errStr + "Please make sure the " + shortFieldName + " field was properly completed.\n";
                }
            }
        }
        if (which.destination_State[which.destination_State.selectedIndex].value == 0) {
            pass = false;
            errStr = errStr + "Please enter a state for your destination.\n";
        }
        if (which.destination_City.value == 0) {
            pass = false;
            errStr += "Please enter a property for your destination.\n";
        }
        if (isNaN(which.corporate_plus.value)) {
            pass = false;
            errStr = errStr + "Please enter a number for the Corporate Plus number.\n"
        }
        else if (isNaN(which.required_Zip.value)) {
            pass = false;
            errStr = errStr + "Please enter a number for the Zipcode.\n"
        }
        else if (isNaN(which.required_Adult_guests.value)) {
            pass = false;
            errStr = errStr + "Please enter a number for the number of Adults in group.\n"
        }
        else if (isNaN(which.Child_guests.value)) {
            pass = false;
            errStr = errStr + "Please enter a number for the number of Children 17 and under in group.\n"
        }
        else if (isNaN(which.required_Num_rooms.value)) {
            pass = false;
            errStr = errStr + "Please enter a number for the number of rooms needed.\n"
        }
        else if (which.required_Num_rooms.value < 10 && roomtype != "youth") {
            pass = false;
            errStr = errStr + "Please enter at least 10 rooms.";
        }
        else if (which.required_Num_rooms.value < 5 && roomtype == "youth") {
            pass = false;
            errStr = errStr + "Please enter at least 5 rooms.";
        }
        if (!pass) {
            alert(errStr);
            //which.action='group_sendmail.asp';
            return false;
        }
        else if (pass) {
            //alert("true");
            which.action = 'group_sendmail.asp';
            return (which.submit());
        }
    }
}
function checkrequired2(which) {
    var pass = true;
    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name.substring(0, 8) == "required") {
                if (((tempobj.type == "text" || tempobj.type == "textarea") &&
tempobj.value == '') || (tempobj.type.toString().charAt(0) == "s" &&
tempobj.selectedIndex == 0)) {
                    pass = false;
                    break;
                }
            }
        }
    }
    if (!pass) {
        shortFieldName = tempobj.name.substring(8, 30).toUpperCase();
        alert("Please make sure the " + shortFieldName.replace("_", " ") + " field was properly completed.");
        if (tempobj.focus)
            tempobj.focus();
        return false;
    }
    else
        return (which.submit());
}

function keyCheck(eventObj, obj) {
    var keyCode
    // Check For Browser Type
    if (document.all) {
        keyCode = eventObj.keyCode
    }
    else {
        keyCode = eventObj.which
    }
    var str = obj.value
    if (keyCode == 46) {
        if (str.indexOf(".") > 0) {
            return false
        }
    }
    if ((keyCode < 48 || keyCode > 58) && (keyCode != 46)) { // Allow only integers and decimal points
        return false
    }
    return true
}

function maxLength(obj, i) {
    if (obj.value.length >= i) {
        obj.value = obj.value.slice(0, i);
    }
}

function validate_it(which) {
    if (which.First_Name.value == "") {
        alert('Please complete the First Name field. Thank You\!');
        which.First_Name.focus();
        return false;
    } else {
        var fname = trimString(which.First_Name)
        if (fname == "") {
            alert('Please complete the First Name field. Thank You\!');
            which.First_Name.focus();
            return false;
        }
    }
    if (which.Last_Name.value == "") {
        alert('Please complete the Last Name field. Thank You\!');
        which.Last_Name.focus();
        return false;
    } else {
        var lname = trimString(which.Last_Name)
        if (lname == "") {
            alert('Please complete the Last Name field. Thank You\!');
            which.Last_Name.focus();
            return false;
        }
    }
    if (which.email.value == "") {
        alert('Please complete the email field. Thank You\!');
        which.email.focus();
        return false;
    } else {
        if (!isEmail(which.email.value)) {
            which.email.focus();
            return false;
        }
    }

    if (which.address.value == "") {

        alert('Please complete the Address field. Thank You\!');
        which.address.focus();
        return false;
    }
    if (which.city.value == "") {
        alert('Please complete the City field. Thank You\!');
        which.city.focus();
        return false;
    }
    if (which.state.value == "") {
        alert('Please complete the State field. Thank You\!');
        which.state.focus();
        return false;
    }
    if (which.zip_code.value == "") {
        alert('Please complete the Zip Code field. Thank You\!');
        which.zip_code.focus();
        return false;
    }
    if (which.country.value == "") {
        alert('Please complete the Country field. Thank You\!');
        which.country.focus();
        return false;
    }
    if ((which.work_phone.value != "") && (isNaN(which.work_phone.value))) {
        alert('Please complete the Work Phone field with numbers only. Thank You\!');
        which.work_phone.focus();
        return false;
    }
    if (which.home_phone.value != "" && (isNaN(which.home_phone.value))) {

        alert('Please complete the Home Phone field with numbers only. Thank You\!');
        which.home_phone.focus();
        return false;
    }
    if (which.dates.value == "") {


        alert('Please complete the Date field. Thank You\!');
        which.dates.focus();
        return false;
    } else {
        if (!CheckDate2(which.dates)) {
            return false;
        }
    }
    if (which.nights.value != "" && (isNaN(which.nights.value))) {
        alert('Please complete the Nights field with numbers only. Thank You\!');
        which.nights.focus();
        return false;
    }
    if (which.property_state.value == "") {//which.property_state.value == "880" || 
        alert('Please complete the Location State field. Thank You\!');
        which.property_state.focus();
        return false;
    } else {
        if (which.property_city.value == "") {//which.property_city.value == "880" || 
            alert('Please complete the Location field. Thank You\!');
            which.property_city.focus();
            return false;
        }
    }

    if (which.comm.value == "") {

        alert('Please complete the Comment field. Thank You\!');
        which.comm.focus();
        return false;
    } else {
        return true;
    }
}

function trim(strg) {
    var str = strg.value;
    if (str != "") {
        while (str.charAt(0) == ' ')
            str = str.substring(1);
        while (str.charAt(str.length - 1) == ' ')
            str = str.substring(0, str.length - 1);
        strg.value = str;
    }
    return str;
}

function trimString(strg) {
    var str = strg.value;
    while (str.charAt(0) == ' ')
        str = str.substring(1);
    while (str.charAt(str.length - 1) == ' ')
        str = str.substring(0, str.length - 1);
    strg.value = str;

}

//Date Validation - formatting
function FormatDate(i, delKey, direction) {
    if (i.value.length < 10) {
        if (delKey != 9) { //tab
            if (delKey != 8 && delKey != 46 && delKey != 16 && !(delKey > 36 && delKey < 41)) { //if the delete, backspace, shift, are not the keys that caused the keyup event.
                var fieldLen = i.value.length
                if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <= 105)) {
                    if (fieldLen == 2 || fieldLen == 5) {
                        i.value = i.value + "/";
                    }
                } else {
                    if (direction == "up") {
                        if (i.value.length == 0) {
                            i.value = ""
                        } else {
                            i.value = i.value.substring(0, i.value.length - 1)
                        }
                    }
                }
                i.focus()
            }
        } else {
            if (direction == "down") {
                CheckDate2(i)
            }
        }
    }
}

function CheckDate2(THISDATE) {
    var err = 0
    a = THISDATE.value
    if (a.length != 10) err = 1
    b = a.substring(0, 2)// month
    c = a.substring(2, 3)// '/'
    d = a.substring(3, 5)// day
    e = a.substring(5, 6)// '/'
    f = a.substring(6, 10)// year
    if (b < 1 || b > 12) err = 1
    if (d < 1 || d > 31) err = 1
    if (f < 1900) err = 1
    if (b == 4 || b == 6 || b == 9 || b == 11) {
        if (d == 31) err = 1
    }
    if (b == 2) {
        var g = parseInt(f / 4)
        if (isNaN(g)) {
            err = 1
        }
        if (d > 29) err = 1
        if (d == 29 && ((f / 4) != parseInt(f / 4))) err = 1
    }
    if (err == 1) {
        alert(THISDATE.value + ' is not a valid date. Please re-enter.');
        THISDATE.value = "";
        THISDATE.focus();
        return false;
    } else {
        return true;
    }
}

function isEmail(argvalue) {
    if (argvalue.indexOf(" ") != -1) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }
    else if (argvalue.indexOf("@") == -1) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }
    else if (argvalue.indexOf("@") == 0) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }
    else if (argvalue.indexOf("@") == (argvalue.length - 1)) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }

    arrayString = argvalue.split("@");
    // var retSize = customSplit(argvalue, "@", "arrayString");

    if (arrayString[1].indexOf(".") == -1) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }
    else if (arrayString[1].indexOf(".") == 0) {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }
    else if (arrayString[1].charAt(arrayString[1].length - 1) == ".") {
        alert("Please format your email like yourname@yourisp.com or yourscreenname@aol.com");
        return false;
    }

    return true;

}

function keyCheck2(objEvent) {
    var iKeyCode;
    iKeyCode = objEvent.keyCode;
    if (iKeyCode >= 48 && iKeyCode <= 57) return true;
    return false;
}
function checkrequired3(which) {
    var pass = true;
    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name.substring(0, 8) == "required") {
                if (((tempobj.type == "text" || tempobj.type == "textarea") &&
				tempobj.value == '') || (tempobj.type.toString().charAt(0) == "s" &&
				tempobj.selectedIndex == 0)) {
                    pass = false;
                    break;
                }
                if (tempobj.name == "requiredemail") {
                    if (tempobj.value != document.theForm.email2.value) {
                        alert("Your email addresses do not match.");
                        if (document.theForm.email2.focus)
                            document.theForm.email2.focus();
                        return false;
                    }

                }
            }
        }
    }
    if (!pass) {
        shortFieldName = tempobj.name.substring(8, 30).toUpperCase();
        alert("Please make sure the " + shortFieldName + " field was properly completed.");
        if (tempobj.focus)
            tempobj.focus();
        return false;
    }
    else
        return true;
}

function submitenter(myform, e) {
    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    } else if (e) {
        keycode = e.which;
    } else {
        return true;
    }
    if (keycode == 13) {
        Form_Validator(myform);
        return false;
    }
    else
        return true;
}

function submitenter2(myform, e) {
    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    } else if (e) {
        keycode = e.which;
    } else {
        return true;
    }
    if (keycode == 13) {
        validate_it(myform);
        return false;
    }
    else
        return true;
}

function submitenter3(theForm,e) {
	  var errStr = ""
    var thiscode;
    //alert(e==undefined);
    e = e ? e : window.event;
    //alert(e);
    if (e) {
    	thiscode = window.event ? window.event.keyCode : e.which;
    	if (thiscode == undefined) thiscode = 0;
    	if ((navigator.appName == "Netscape") && navigator.appVersion == "5.0 (Windows; en-US)") {
    		//Firefox sends the tab key as an "enter" keycode (0) so it needs to be converted to an MS "tab" keycode or the keypress is treated as a form submission
    		if (e.type == "keypress") {
    			if (thiscode == 0) {
    				thiscode = 9;
    			}
    		}
    	}
    	
    	if (thiscode == 13 || e.type == "click" || thiscode == 0) {
    		errStr = basic_Valid(theForm, errStr);

    		if (errStr && errStr != true) {
    			alert(errStr);
    			return false;
    		} else {
    			return true;
    		}
    	} else {
    		return true;
    	}
    } else return true;
}

function GetEventTargetName(e) {
	var targ;
	if (!e) e = window.event;
	
	if (e.target) {
		targ = e.target;
	}
	else if (e.srcElement) {
		targ = e.srcElement;
	}
	if (targ.nodeType == 3) // defeat Safari bug
	{
		targ = targ.parentNode;
	}
	
	var tname="";
	if(targ)	tname = targ.tagName;
	
	return tname;
}
function SetFocus_Index(thisForm, index) {
    var elem;
    var ct = 0;
    if (thisForm) {
        for (i = 0; i < thisForm.elements.length; i++) {
            elem = thisForm.elements[i];
            if (elem.type == "text") {
                if (ct == index) {
                    elem.focus();
                    break;
                } else ct++;
            }
        }
    }
}