﻿/*Expend and Collapse panels*/
function Expander(el) {
    var par = $(el).parent();
    var exp = $(par).find("div.expandable");
    var disp = $(exp).css("display");
    if (disp != "none") $(exp).fadeOut('slow');
    else $(exp).fadeIn('slow');
}
/*fix top links tabs in ie and safar (chrome)*/
function FixLinks() {
    if ($.browser.safari) {
        $("#topLinks ul li").remove("#topLinks ul li.current").css("padding-bottom", "1px");
        $("#topLinks ul li").css("padding-bottom", "2px");
    } else if ($.browser.msie) {
        $("#topLinks").css("background", "transparent url('/images/toplink-bg.gif') repeat-x bottom");
        $("#topLinks ul li").css("padding-bottom", "1px");
    }
}

function FixTableAlignment() {
    //make content in first td in tables with class contentTable right aligned and
    //in second td left aligned
    $("table.contentTable td:nth-child(1)").css({ "text-align": "right", "background-color": "#c0c0c0" });
    $("table.contentTable td:nth-child(2)").css({ "text-align": "left", "background-color": "#d3d3d3" });
}

function InitJS() {
    $.datepicker.setDefaults({ showOn: 'both', buttonImage: '/images/calendar.gif', buttonImageOnly: true,
        changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy', showButtonPanel: true
    });
    
    FixLinks();
    
    $("div.expander").click(function() {
        Expander(this);
    });

    $(".dtp").datepicker();

    $(".dtp").attr("readonly", "readonly");
    //$("input").focusFields('#a1e1ed', 2);

//    if (typeof (console) != "undefined" & console != null) {
//        console.clear();
//        console.profile("Style Textboxes");
    //    }

//    $("input:text").css({ "border": "1px solid #bdbdbd", "background-color": "#ffffff",
//        "font-size": "10px", "font-family": "Arial Verdana Sans-Serif"
//    });

//    if (typeof (console) != "undefined" & console != null) {
//        console.profileEnd();
    //    }

//    console.clear();
//    console.profile("styling table");
//    FixTableAlignment();
//    console.profileEnd();
}