function pageLoad() {

    var nav = window.location.pathname;

    $.each($.browser, function(i, val) {

        if (i == "safari" && navigator.platform == "MacIntel") {
            $(".location").css("top", "-3px");
            $('.date').css("top", "21px");
            $('.time').css("top", "45px");
        }
    });

    if (nav.indexOf("rush") != -1 || nav.indexOf("contact") != -1 || nav.indexOf("appointment") != -1) {
        $('.close').hide();
    }
    else{

        var ddl = $('.rcbInput').val();

        $('.close').css("cursor", "pointer");

        if (ddl === 'Location') {
            $('.date').hide();
            $('.time').hide();
            $('.rush').hide();
            $('.price').hide();
            $('.close').hide();
            $('.schedulerButton').hide();
            $('.scheduler').css('height', '84px');
            $('.scheduler').parent().append('<div class="schedulerBottom" class="schedulerBottom"><img src="/images/modules/scheduler-bottom.gif"/></div>');
            $('.scheduler').click(function() {
                if ($('.scheduler').height() == '84') {
                    $('.scheduler').parent().parent().css('z-index', '100');
                    $('.scheduler').animate({ height: '283px' }, 1000, function() {
                        $('.date').show();
                        $('.time').show();
                        $('.rush').show();
                        $('.price').show();
                        $('.schedulerButton').show();
                        $('.close').show();
                        ResizeContainer();
                    });
                }
            });
        }
        else {
            $('.scheduler').parent().parent().css('z-index', '100');
        }

        $('.close').click(function() {
            $('.date').hide();
            $('.time').hide();
            $('.rush').hide();
            $('.price').hide();
            $('.close').hide();
            $('.schedulerButton').hide();
            $('.scheduler').animate({ height: '84px' }, 1000);
            ResizeContainer();
        });
    }
 
}

// necessary to disable the weekends on client-side navigation
function OnDayRender(calendarInstance, args) {

    // convert the date-triplet to a javascript date
    // we need Date.getDay() method to determine 
    // which days should be disabled (e.g. every Saturday (day = 6) and Sunday (day = 0))                
    var jsDate = new Date(args.Date[0], args.Date[1] - 1, args.Date[2]);
    if (jsDate.getDay() == 0 || jsDate.getDay() == 6) {
        var otherMonthCssClass = "otherMonth_" + calendarInstance.Skin;
        args.Cell.className = otherMonthCssClass;
        // replace the default cell content (anchor tag) with a span element 
        // that contains the processed calendar day number -- necessary for the calendar skinning mechanism 
        args.Cell.innerHTML = "<span>" + args.Date[2] + "</span>";
        // disable selection and hover effect for the cell
        args.Cell.DayId = "";
    }
    
}

function PopupOpening(sender, args) 
{

    var table = $get(sender.get_id() + "_timeView_tdl");

    for (var r = 0; r < table.tBodies[0].rows.length; r++) 
    {
        for (var c = 0; c < table.tBodies[0].rows[r].cells.length; c++) 
        {
            var cell = table.tBodies[0].rows[r].cells[c];

            for (var dd = 0; dd < DisabledTimes.length; dd++) 
            {
                if (cell.innerHTML.indexOf(DisabledTimes[dd]) != -1) 
                {
                    cell.innerHTML = DisabledTimes[dd];
                    cell.style.textAlign = "center";

                    $(cell).bind("click", DisableEvent);
                    $(cell).bind("mouseover", DisableEvent);
                    $(cell).bind("mouseout", DisableEvent);
                    $(cell).css("style", "color:#000 !important;");
                }
            }
        }
    }
    
}

function PopupClosing(sender, args) {

    var table = $get(sender.get_id() + "_timeView_tdl");
    for (var r = 0; r < table.tBodies[0].rows.length; r++) {
        for (var c = 0; c < table.tBodies[0].rows[r].cells.length; c++) {
            var cell = table.tBodies[0].rows[r].cells[c];
            for (var dd = 0; dd < DisabledTimes.length; dd++) {
                if (cell.innerHTML.indexOf(DisabledTimes[dd]) != -1) {
                    cell.innerHTML = DisabledTimes[dd];
                    
                    $(cell).unbind("click", DisableEvent);
                    $(cell).unbind("mouseover", DisableEvent);
                    $(cell).unbind("mouseout", DisableEvent);
                }
            }
        }
    }
    
}

function DisableEvent(e) 
{

    e = e || window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    
}
