function performSearch() {
    var i;
    var theForm = document.offerSearchForm;
    var searchUrl = theForm.action + "?";

    // process dates
    if(theForm.ciDate.value != "MM/DD/YYYY") {
        // check-in date
        searchUrl += "&ciDate=" + theForm.ciDate.value;
        searchUrl += "&coDate=" + theForm.coDate.value;
    }

    // process places
    if(theForm.where.value != "destinations") {
        // destinations
        searchUrl += "&destinationID=" + theForm.where.value;
    }
    SW.tools.Cookie.set("wo_dest",theForm.where.value);

    document.location = searchUrl;

    return false;
}

function checkSearchDates(form, event) {
    var formObj = form;
    if (event.type == "focus")   {
        if(formObj.ciDate.hasFocus == "true")    {
            var checkIn = new validDate(formObj.ciDate);
            if (  !checkIn.valid ) { formObj.ciDate.value="";}
        }
        if(formObj.coDate.hasFocus == "true")    {
            var checkOut = new validDate(formObj.coDate);
            if (  !checkOut.valid ) { formObj.coDate.value="";}
        }
    }
    if (event.type == "blur")   {
        if(formObj.ciDate.hasFocus == "false")    {
            var checkOut = new validDate(formObj.coDate);
            var checkIn = new validDate(formObj.ciDate);
            if ( checkIn.valid ) {
                checkIn.setField();
                if (checkOut.valid ) { before = (checkIn.diffDate(checkOut.d) <= 0);}
                if ( (! (checkOut.valid)) || before) {
                    checkOut.setD(checkIn.d);
                    checkOut.nextDay();
                    checkOut.setField();
                }
            } else {
                formObj.ciDate.value=dateFormatString;
            }
        }
        if(formObj.coDate.hasFocus == "false")    {
            var checkOut = new validDate(formObj.coDate);
            if ( checkOut.valid ) { checkOut.setField(); } else {formObj.coDate.value=dateFormatString;}
        }
    }
}

function hilteSpan(elementId,action){
    var container = document.getElementById(elementId);

    if (action == "off" && container.className != "locked") container.style.backgroundImage = "";
    else if (action == "on") container.style.backgroundImage = "url('/whotels/images/offers/w_offers_span_highlight.gif')";
}
