function initializeJQueryCode() {
    $(".save").click(function() {
        $.validity.start();
        $(".requiredfield").require();
        $(".datefield").match("date");
        $(".emailfield").match("email");
        $(".integerfield").match("number");
        $(".numberfield").match("number");
        $(".numericfield").match("number");
        $(".decimalfield").match("number");
        $(".moneyfield").match("number");
        var result = $.validity.end();
        return result.valid;
    });
    try {
        $(".datefield").datepicker({ changeMonth: true, changeYear: true, numberOfMonths: 1, showOtherMonths: true, selectOtherMonths: true, showButtonPanel: true, showOn: 'both' });
        $(".datefield").datepicker('option', '{showAnim: slideDown}');
    } catch (err) { }
    try {
        $(".datefield").attr('autocomplete', 'off');
    } catch (err) { }
    try {
        $("a.dialog").colorbox({ iframe: 'true', innerWidth: '500px', innerHeight: '500px', scrolling: 'true' });
    } catch (err) { }
    $(".accordion").accordion({ autoHeight: false, collapsible: true, navigation: true });
    $(".showwhenloaded").show();

    $(document).ready(function() {
        $(".collapsible-list-open-first .collapsible-body:first").show();
        //toggle the componenet with class msg_body
        $(".collapsible-header").click(function() {
            $(this).next(".collapsible-body").toggle();
        });
    });
}

$(document).ready(function() {
    initializeJQueryCode();
});

function PopupWindow(aUrl, w, h, sb, rs, tb, dir, st, mnu)
{
	if (!sb) sb = "yes"; if (!rs) rs = "yes"; if (!tb) tb = "no"; if (!dir) dir = "no"; if (!st) st = "no"; if (!mnu) mnu = "no";
	popupWin=window.open(aUrl,"PopupWin","scrollbars="+sb+",resizable="+rs+",toolbar="+tb+",directories="+dir+",status="+st+",menubar="+mnu+",width="+w+",height="+h+",resizable=yes");
	popupWin.self.focus();
}

function PopupNamedWindow(aName, aUrl, w, h, sb, rs, tb, dir, st, mnu)
{
	if (!sb) sb = "yes"; if (!rs) rs = "yes"; if (!tb) tb = "no"; if (!dir) dir = "no"; if (!st) st = "no"; if (!mnu) mnu = "no";
	popupWin=window.open(aUrl,aName,"scrollbars="+sb+",resizable="+rs+",toolbar="+tb+",directories="+dir+",status="+st+",menubar="+mnu+",width="+w+",height="+h+",resizable=yes");
	popupWin.self.focus();
}

function PopupUniqueWindow(aUrl, w, h, sb, rs, tb, dir, st, mnu)
{
	if (!sb) sb = "yes"; if (!rs) rs = "yes"; if (!tb) tb = "no"; if (!dir) dir = "no"; if (!st) st = "no"; if (!mnu) mnu = "no";
	popupWin=window.open(aUrl, "PopupWin"+(new Date()).getTime(),"scrollbars="+sb+",resizable="+rs+",toolbar="+tb+",directories="+dir+",status="+st+",menubar="+mnu+",width="+w+",height="+h+",resizable=yes");
	popupWin.self.focus();
}

function HideShowControl(ctrlid) {
    var ctrl = document.getElementById(ctrlid);
    if (ctrl.style.display == "none") {
        ctrl.style.display = "";
    }
    else {
        ctrl.style.display = "none";
    }
}

function HideControl() {
    var ctrl;

    for (i = 0; i < arguments.length; i++) {
        ctrl = document.getElementById(arguments[i]);
        if (ctrl.style.display != "none") {
            ctrl.style.display = "none";
        }
    }
}

function ShowControl() {
    var ctrl;

    for (i = 0; i < arguments.length; i++) {
        ctrl = document.getElementById(arguments[i]);

        if (ctrl.style.display == "none") {
            ctrl.style.display = "";
        }
    }
}