﻿function DoSearch() {
    var destMenu = document.getElementById("destMenu");
    var typeMenu = document.getElementById("typeMenu");
    var highMenu = document.getElementById("endDateMenu");
    var lowMenu = document.getElementById("startDateMenu");
    var destIndex, typeIndex, destValue, typeValue;
    var highIndex, lowIndex, highValue, lowValue;
    destIndex = destMenu.selectedIndex;
    typeIndex = typeMenu.selectedIndex;
    highIndex = highMenu.selectedIndex;
    lowIndex = lowMenu.selectedIndex;
    destValue = destMenu[destIndex].getAttribute("rel");
    typeValue = typeMenu[typeIndex].getAttribute("rel");
    highValue = highMenu[highIndex].value;
    lowValue = lowMenu[lowIndex].value;
    if ((destValue == "none") && (typeValue != "none") && (lowValue == "none") && (highValue == "none")) {
        location.href = "http://www.tauck.com" + typeMenu[typeIndex].value; return true;
    }
    if ((destValue != "none") && (typeValue == "none") && (lowValue == "none") && (highValue == "none")) {
        location.href = "http://www.tauck.com" + destMenu[destIndex].value; return true;
    }
    if (((destValue != "none") && (typeValue != "none")) || (((destValue != "none") || (typeValue != "none")) && ((highValue != "none") || (lowValue != "none"))) || (((highValue != "none") || (lowValue != "none")))) {
        if (destValue == "none") {
            destValue = "";
        }
        if (typeValue == "none") {
            typeValue = "";
        }
        else {
            typeValue = typeMenu[typeIndex].text;
        }

        var current_date = new Date();
        if (highValue == "none") {
            highValue = current_date.getFullYear() + "-12-31";
        } if (lowValue == "none") {
            lowValue = current_date.getFullYear() + "-1-1";
        }
        location.href = "http://www.tauck.com/journeys/search-results/?searchType=smart&destination=" + destValue + "&travelType=" + escape(typeValue) + "&highDate=" + highValue + "&lowDate=" + lowValue + "&take=7&skip=0&sort=name";
        return true;
    }
    else { alert('Please select your search criteria to continue.'); return true; }
}