﻿$(document).ready(function() {

    $('A[rel="external"]').click(function() {
        var height = $(this).attr('height');
        var width = $(this).attr('width');

        var x = (screen.width / 2) - (width / 2);
        var y = (screen.height / 2) - (height / 2);

        var options;

        //alert('width set');
        //if (height != null && width != null) {
        //    alert('options set');

        options = 'width=' + width + ',height=' + height;
        options = options + "top=" + y + ",left=" + x;
        options = options + ",scrollbars=yes";
        //}


        window.open($(this).attr('href'), 'popup', options);
        return false;
    });

});
$(document).ready(function() {
    $("#check_in_month_year").change(function() {
        //var ss = $("#check_in_month_year");
        //alert('change-check_in_day' + ss.val());
        findNoOfDays($("#check_in_month_year").val());
        return true;
    });
});

function findNoOfDays(monthYear) {

    for (i = 0; i < calenderYears.length; i++) {
        if (calenderYears[i][0] == monthYear) {
            var selectedDay = $("#check_in_day").val();
            // Re-render the dropdown content
            renderDays(calenderYears[i][1]);
            // Select the original date
            $("#check_in_day").val(selectedDay);
        }
    }
}

function renderDays(noOfDays) {
    var options = '';
    for (i = 0; i < noOfDays; i++) {
        var day = i + 1;
        var option = '<option value=' + day + '>' + day + '</option>'
        options += option;
    }
    $("#check_in_day").html(options);
}

function doFormSubmit(childElement) {
    alert('df');
    //var parent = childElement.parentNode;
    alert('submist')
    childElement.submit();
    alert('submit')
    while (parent != null) {
        alert(parent.name);
//        if (parent.method) {
//            // Additional check needs to be done before calling submit. 
//            parent.submit();
//            // P1: Odd enough - this requires a break. Missing some basics here.
//            break;
//        }
//        else {
//            parent = parent.parentNode;
//        }
    }
}