/*var searchType = "car_fd";
var carDoaCal;
var carDodCal;
var carCalArray = new Array();

// store calendar objects for use to show calendar.
function carInitCal() {
    carDoaCal = new WCT.calendar("carDoa", "carCal1Container", "calendarBoxArrive", document.forms["CarSearch"].chk_in, "DOA");
    carDodCal = new WCT.calendar("carDod", "carCal2Container", "calendarBoxDepart", document.forms["CarSearch"].chk_out, "doD");
    carDoaCal.addLinkedCal(carDodCal);
    carDodCal.addLinkedCal(carDoaCal);
    carCalArray.push(carDoaCal);
    carCalArray.push(carDodCal);
    carDoaCal.position("relative");
    carDodCal.position("relative");
}

function carSplitDate() {
    carDoaCal.returnSelectedDate("", "pu_month", "pu_day");
    carDodCal.returnSelectedDate("", "do_month", "do_day");
}

// to redirect to 4hr car advanced search page
function go() {
    var destination = document.CarSearch.puwhere.value;
    var re = new RegExp('CarRequest');
    var m = re.exec(destination);
    if (m != null) {
        //location.target = "_top";
        top.location.href = destination;
    } else {
        return false;
    }
}
*/
function submitForm() {
    b_valid = true;
    if (!htlDoaCal.returnSelectedDate("doa_yy", "doa_mm", "doa_dd")) b_valid = false;
    if (!htlDodCal.returnSelectedDate("dod_yy", "dod_mm", "dod_dd")) b_valid = false;
    critUpdate();
    return (b_valid);
}

function pastDate(date) {
    var now = new Date();
    now = now.getTime();
    //NN3
    var params = date.split('/');
    var mm = params[0];
    var dd = params[1];
    var yy = params[2];
    var dateToCheck = new Date();
    dateToCheck.setYear(yy);
    dateToCheck.setMonth(mm - 1);
    dateToCheck.setDate(dd);
    var checkDate = dateToCheck.getTime();
    var futureDate = (now < checkDate);
    var pastDate = (now > checkDate);
    if (pastDate == true) return true;
    else return false;
}

function critCheck() {
    //used at load
    var x = get_cookie('HotelWidget');
    if (x) {
        var params = x.split('|');
        var doa = params[0].substring(params[0].indexOf('=') + 1);
        var dod = params[1].substring(params[1].indexOf('=') + 1);
        if (pastDate(doa) || pastDate(dod)) {
            //old date
            document.getElementById('chk_in').value = 'MM/DD/YYYY';
            document.getElementById('chk_out').value = 'MM/DD/YYYY';
        } else {
            document.getElementById('chk_in').value = doa;
            document.getElementById('chk_out').value = dod;
        }
    }
    return null;
}

function critUpdate() {
    //used at submit
    var doa = document.getElementById('chk_in').value;
    var dod = document.getElementById('chk_out').value;
    var cookie_string = "doa=" + escape(doa) + "|dod=" + escape(dod);
    set_cookie('HotelWidget', cookie_string);
    return null;
}

function delete_cookie(cookie_name) {
    var cookie_date = new Date();
    // current date & time
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
    if (results) return (unescape(results[2]));
    else return null;
}

function set_cookie(name, value) {
    var cookie_string = name + "=" + escape(value) + "; expires=31/12/2222 00:00:00";
    delete_cookie(name);
    document.cookie = cookie_string;
}