$(document).ready(function(){bindCalendar();});

var minCalDate = new Date(2011,3-1,1);   
//change this min date to +0 after 1st march to avoid showing old dates

function bindCalendar(){
    $(".arrDtTextBox").datepicker({ yearRange: "2011-2012", minDate: minCalDate, maxDate: new Date(2012, 10 - 1, 26), defaultDate: "", dateFormat: "dd/mm/yy", nextText: "N", prevText: "P", hideIfNoPrevNext: true, beforeShowDay: nationalDays, showStatus: true, firstDay: 1, changeFirstDay: false, initStatus: "", dayStatus: "", statusForDate: describeDate, helpText: '<div class="holidayHelpText">Bank Holidays are marked in yellow</div>', weekStatus: "" });
    
    $(".arrivalDateContainerTxtBox").datepicker({yearRange:"2011-2012",minDate:minCalDate,maxDate:new Date(2012,10-1,26),defaultDate:"",dateFormat:"dd/mm/yy",nextText:"N",prevText:"P",hideIfNoPrevNext:true,beforeShowDay:nationalDays,showStatus:true,firstDay:1,changeFirstDay:false,initStatus:"",dayStatus:"",statusForDate:describeDate,helpText:'<div class="holidayHelpText">Bank Holidays are marked in yellow</div>',weekStatus:""});

    $(".rightLocationBookThirdDdl .ddlYear").datepicker({ yearRange: "2011-2012", minDate: minCalDate, maxDate: new Date(2012, 10 - 1, 26), defaultDate: "", dateFormat: "dd/mm/yy", nextText: "N", prevText: "P", hideIfNoPrevNext: true, beforeShowDay: nationalDays, showStatus: true, firstDay: 1, changeFirstDay: false, initStatus: "", dayStatus: "", statusForDate: describeDate, helpText: '<div class="holidayHelpText">Bank Holidays are marked in yellow</div>', weekStatus: "" });

    $(".rightLocationBookFirstDdlNew .ddlYear").datepicker({ yearRange: "2011-2012", minDate: minCalDate, maxDate: new Date(2012, 10 - 1, 26), defaultDate: "", dateFormat: "dd/mm/yy", nextText: "N", prevText: "P", hideIfNoPrevNext: true, beforeShowDay: nationalDays, showStatus: true, firstDay: 1, changeFirstDay: false, initStatus: "", dayStatus: "", statusForDate: describeDate, helpText: '<div class="holidayHelpText">Bank Holidays are marked in yellow</div>', weekStatus: "" });
    
    $(".arrDtTextBox").attr("readOnly",true);$(".arrivalDateContainerTxtBox").attr("readOnly",true);
    
    $(".rightLocationBookThirdDdl .ddlYear").attr("readOnly",true);$(".rightLocationBookFirstDdlNew .ddlYear").attr("readOnly",true);
    
}

natDays = [
/*2011*/[1, 3, 2011, "NYD", "New Year Day"], [4, 22, 2011, "GFD", "Good Friday"], [4, 25, 2011, "ESD", "Easter Monday"], [4, 29, 2011, "ESD", "Royal Wedding Holiday"], [5, 2, 2011, "EMD", "Early May Bank Holiday"], [5, 30, 2011, "SPH", "Spring Bank Holiday"], [8, 29, 2011, "SUM", "Summer Bank Holiday"], [12, 26, 2011, "CHD", "Christmas Day"], [12, 27, 2011, "BXD", "Boxing Day"],
/*2012*/[1, 2, 2012, "NYD", "New Year Day"], [4, 6, 2012, "GFD", "Good Friday"], [4, 9, 2012, "ESD", "Easter Monday"], [5, 7, 2012, "EMD", "Early May Bank Holiday"], [6, 4, 2012, "SPH", "Spring Bank Holiday"], [6, 5, 2012, "SPH", "Queens Diamond Jubilee"], [8, 27, 2012, "SUM", "Summer Bank Holiday"], [12, 25, 2012, "CHD", "Christmas Day"], [12, 26, 2012, "BXD", "Boxing Day"]
];

function nationalDays(B)
{
    var C="";
    var A=true;
    if((B.getMonth()==0)||(B.getMonth()==1)||(B.getMonth()==10)||(B.getMonth()==11)||(B.getFullYear()==2012 & (B.getMonth()==2)&&(B.getDate()<16)) || (B.getFullYear()==2011 & (B.getMonth()==2)&&(B.getDate()<18)))
    {
        C="DisabledDate";
        A=false;
    }
    for(i=0;i<natDays.length;i++)
        {
            if((B.getMonth()==natDays[i][0]-1) && B.getDate()==natDays[i][1]&&B.getFullYear()==natDays[i][2])
                {
                    if(C=="DisabledDate")
                        {
                            C="DisabledDate BankHoliday"+natDays[i][3];
                        }
                   else
                        {
                            C="BankHoliday"+natDays[i][3];}break;
                        }
                 }
           return[A,C];
        }
   
    function describeDate(A)
        {
            for(i=0;i<natDays.length;i++)
            {
                if(A.getMonth()==natDays[i][0]-1&&A.getDate()==natDays[i][1]&&A.getFullYear()==natDays[i][2])
                    {
                        return"<div>"+natDays[i][4]+"</div>";
                    }
            }
            return"";
        }
    function ShowCal()
        {
            var A=document.getElementById("hdnCalBtnClicked");
            if(A.value=="1"){}document.getElementById("hdnCalBtnClicked").value="0";
        }
    function ShowCalOnOffers(){}

