﻿$(document).ready(
function() {
    applyStyle.call($(document));
    if (typeof applyCustomStyle !== "undefined" && applyCustomStyle.constructor == Function) {
        applyCustomStyle();
    }
});

function applyStyle() {
    //Dialog handler
    var dialogButtons = this.find(".ui-button");
    if (dialogButtons.length > 0) {
        dialogButtons.removeClass();
        dialogButtons.last().addClass('small_button_a');
        if (dialogButtons.length == 2)
        dialogButtons.first().addClass('small_button_b');
    }
    
    this.find(".hoverable")
    .mouseenter(
    function() {
        $(this).addClass('hover');
    })
    .mouseleave(
    function() {
        $(this).removeClass('hover');
    });

    //Form fields
    this.find(".mandatory.fieldLabel").before("<span class='mandatoryFieldMarker'>*</span>");
    this.find(".fieldLabel").filter(function() { return !$(this).hasClass("mandatory"); }).before("<span class='mandatoryFieldMarker'>&nbsp;&nbsp;</span>");
    this.find(".dataField select + select").before("<span>&nbsp;/&nbsp;</span>"); //for MonthYear control

    // Date Picker Fields
    
    //$(".datepicker").datepicker($.datepicker.regional['he']);
    $(".datepicker").datepicker({
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true
    });

    this.find("UL#LocationBar li a:gt(0)").prepend("\\ ");

    if ($.fn.location("queryParams")["hideClient"] !== undefined) {
        $("#UserDetailsForm").after("<table id=\"customFields\" width=\"100%\"></table>");
        $("#UserDetailsForm tr:has(#fldDeliveryMethod)").appendTo($("#customFields"));
        $("#UserDetailsForm").css("display", "none");
        $("#customFields>tbody>tr>td:eq(0)").css("width", "113px")
    }
    if ($.fn.location("queryParams")["hideSuppPaymentsSection"] !== undefined) {
        $("#suppPayMethods").parent().css("display", "none");
    }
    
}
