﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
var startDatePicker;
var endDatePicker;

function Page_Window_Load(e) {
    startDatePicker = $("input[id$='TextVisitStartDate']").datepicker({ onSelect: function(dateText, inst) { checkEndDate(dateText); } 
    });
    endDatePicker = $("input[id$='TextVisitEndDate']").datepicker();
}

$("input[id$='TextCheckInDate']").change
    (function (e) {
        alert("Here I am");
        checkCheckOutDate();
    }
    );

$("input[id$='TextCheckInDate']").keyup
    (function (e) 
    {
        alert("Here I am");
        checkCheckOutDate();
    }
    );

$("input[id$='TextVisitStartDate']").keyup
    (function(e) {
        if (e.keyCode == 13) {
            $(".addtrip").click();
        }
    }
    );

    $("input[id$='TextVisitEndDate']").keyup
(function(e) {
    if (e.keyCode == 13) {
        $(".addtrip").click();
    }
}
);

function checkCheckOutDate() {
//    var startDate = Date.parse(checkInDate);
//    if ($("#TextCheckOutDate").val() == "") {
//        $("#TextCheckOutDate").val((1).days().after(startDate));
//    }
    $("#TextCheckOutDate").val("potato");
}

function checkEndDate(dateText) {
    var startDate = startDatePicker.datepicker('getDate');
    var nextDate = new Date();
    nextDate = startDate;
    nextDate.setDate((startDate.getDate() + 1));

    var endDate = endDatePicker.datepicker('getDate');
    if (!endDate) {

        endDatePicker.datepicker('setDate', nextDate);
    }
    else {
        //fortunately the date object allows direct comparison to make life easier.
        if (startDate > endDate) {
            endDatePicker.datepicker('setDate', nextDate);
        }
    }

    //set the min date on our date picker for the end date to the new start date.
    endDatePicker.datepicker('option', 'minDate', startDate);
}

//$(document).ready(function() { $("#bigLink").click(function() { $.modal('<div><img src="' + $("img[id$=ImageMain]").get(0).src + '"/></div>'); }); $("#bigLink").css("cursor", "pointer") });
function switchPictures(smallImageID) {
    var big = $("img[id$=ImageMain]").get(0);
    var small = $("img[id$=" + smallImageID + "]").get(0);
    //  var bigLink = $("#bigLink");
    big.src = small.src.replace(/PropertyThumbnail/, "PropertyImage")
};
  //  bigLink.unbind("click", null);
  //  bigLink.click(function() { $.modal('<div><img src="' + big.src + '"/></div>'); });
  //  bigLink.css("cursor", "pointer");

