/* toggle parent items in left nav */
$(document).ready(function () {
    // parent iframe height setting
    adjust_height();

    // function to change the rendering of the fieldset 
    $("table").find('td[width]').each(function (index) {
        if ($(this).attr("width") == "10px" || $(this).attr("width") == "10") {
            $(this).css("width", "0px");
        };
    });

    $('fieldset').not(".no-panel fieldset").each(function () {
        //var old_legend = $(this).find("legend").html()

        //var old_inner_html = $(this).html();
        //$(this).html("<div class='panel'><div class='panel-head'><div class='panel-head-l'><div class='panel-head-r'><h4>" + old_legend + "</h4></div></div></div><div class='panel-content'>" + old_inner_html + "</div><div class='panel-foot'><div class='panel-foot-l'><div class='panel-foot-r'></div></div></div></div>");
        //$(this).html("<div class='box'><div class='box-t'><div class='box-r'><div class='box-b'><div class='box-l'><div class='box-t-r'><div class='box-t-l'><div class='box-b-r'><div class='box-b-l'><div class='box-head'><h3>" + old_legend + "</h3></div><div class='box-content'>" + old_inner_html + "</div></div></div></div></div></div></div></div></div></div>");
        //$(this).find("legend, LEGEND").wrap("<div class='box-head'><h3>");
        //$(this).wrap("<div class='box'><div class='box-t'><div class='box-r'><div class='box-b'><div class='box-l'><div class='box-t-r'><div class='box-t-l'><div class='box-b-r'><div class='box-b-l'><div class='box-content'>");
    })
    $('.menu ul li span').click(function () {
        $(this).parent().find("ul").slideToggle();
        $(this).parent().toggleClass("open");
    });
    $('.panel .panel-head h4').click(function () {
        $(this).parents(".panel").find(".panel-content").slideToggle();
        $(this).parents(".panel").find(".panel-foot").slideToggle();
        $(this).parents(".panel").toggleClass("panel-open");
    });
    /* appl;ying classes to inputs */
    $("input:text, textarea, input:password").addClass("input_text");
    $("input:checkbox").addClass("input_checkbox");
    $("input:radio").addClass("input_radio");
    /* grid first col bold */
    $(".grid table tr").each(function () {
        $(this).find("td:first").css("font-weight", "bold");
    })
    /* fixing col-2 issue */
    $("li .col-2").parent("li").append("<div class='clear'></div>");

    /* replacing the 7 in the inline validation with * */
    $("font[face*='Webdings']").html("*");
    $("font[face*='Webdings']").css("font-family", "Arial");

    /* removing the nbsp; */
    $(".grid span").each(function (intIndex) {
        $(this).html($(this).html().replace(/&nbsp;/g, " "));
    });


});
function set_selected(cur_page_id) {
    $("li[id$='" + cur_page_id + "']").addClass("selected");
    $("li[id$='" + cur_page_id + "']").parent("ul").parent("li").addClass("open");

}
function adjust_height() {
    if ($(".pp_overlay").size() > 0)
        var new_height = $(".pp_overlay").height();
    else
        var new_height = $(".wrapper").height();
    if (new_height < 1000)
        new_height = 1000;
    new_height += 100; 
    $("#esrvices_iframe", top.document).height(new_height);
}
