﻿// legacy code (new code following below):
function changeTime() {
    for (i = 0; i < document.getElementById('drpPickup_Time').length; ++i)
        if (document.getElementById('drpPickup_Time').options[i].selected == true)
        document.getElementById('drpDropoff_Time').options[i].selected = true;
}

function changeStation() {
    for (i = 0; i < document.getElementById('drpPickup_Location').length; ++i)
        if (document.getElementById('drpPickup_Location').options[i].selected == true)
        	document.getElementById('drpDropoff_Location').options[i].selected = true;
}

function change_dropoff_date(id, value) {
    if (value.length != 10) {
        alert("Wrong date format, must be dd-mm-yyyy");
        return false;
    }
    var Day = value.substr(0, 2);
    var Month = value.substr(3, 2);
    var Year = value.substr(6, 4);

    var myDate = new Date();
    myLastYear = (eval(myDate.getFullYear()) + 2);

    if (Day < 1 || Day > 31) {
        alert("Wrong Date!");
        return false;
    }
    if (Month < 1 || Month > 12) {
        alert("Wrong Date!");
        return false;
    }
    if (Year < myDate.getFullYear() || Year > myLastYear) {
        alert("Wrong Date!");
        return false;
    }

    var PickUp = new Date();
    var DropOff = new Date();
    var DDay, DMonth, DYear;
    var PLimit = new Date();
    var DropField = document.getElementById('txtDropOffDate');

    PickUp.setTime(Date.parse(Month + '/' + Day + '/' + Year));
    DropOff = PickUp;

    DropOff.setDate(DropOff.getDate() + 7);
    DDay = DropOff.getDate();
    if (DDay < 10) { DDay = '0' + DDay }
    DMonth = DropOff.getMonth() + 1;
    if (DMonth < 10) { DMonth = '0' + DMonth }
    DYear = DropOff.getFullYear();

    DropField.value = DDay + '-' + DMonth + '-' + DYear;

    $find("CalExDropOffDate").set_selectedDate(DropOff);
}

function isIE6() {
    return (document.all && navigator.userAgent.toLowerCase().indexOf("msie 6") != -1);
}

function hidedropdown() {
    if (isIE6()) {
        $("select").css("visibility", "hidden");
    }
}

function showdropdown() {
    if (isIE6()) {
        $("select").css("visibility", "visible");
    }
}
