function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function PreloadImages() {
    preload_image_object = new Image();
    
    image_url = new Array();
    image_url[0] = "images/nav_on_profiles.png";
    image_url[1] = "images/nav_on_about.png";
    image_url[2] = "images/nav_on_careers.png";
    image_url[3] = "images/nav_on_practice.png";
    image_url[4] = "images/nav_on_news.png";
    image_url[5] = "images/nav_on_contact.png";

    var i = 0;
    for (i = 0; i <= 3; i++)
        preload_image_object.src = image_url[i];

}

function FormatNews() {
    
    var sPath = window.location.pathname;
    var cpage = sPath.substring(sPath.lastIndexOf('/') + 1);

    if (cpage.indexOf("news") > -1) {

        document.getElementById('newssidebar').style.display = 'none';
    }
    else {
        document.getElementById('newssidebar').style.display = 'block';
    }


}

function WriteCopyright() {
    
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();
    document.write(year);
}

function ShowSubMenu(menu) {
    document.getElementById('profilessubmenu').style.display = 'none';
    document.getElementById('aboutsubmenu').style.display = 'none';
    document.getElementById('practicesubmenu').style.display = 'none';
    document.getElementById('newssubmenu').style.display = 'none';
    document.getElementById('contactsubmenu').style.display = 'none';
    document.getElementById('careerssubmenu').style.display = 'none';

    document.getElementById(menu).style.display = 'block';
}

function HideSubMenu(){

    document.getElementById('profilessubmenu').css("visibility", "hidden");
    document.getElementById('aboutsubmenu').css("visibility", "hidden");
    document.getElementById('practicesubmenu').css("visibility", "hidden");
    document.getElementById('newssubmenu').css("visibility", "hidden");
    document.getElementById('contactsubmenu').css("visibility", "hidden");
    document.getElementById('careerssubmenu').css("visibility", "hidden");

//$("this").css("visibility", "hidden");

}

function StretchNewsSub() {
    if (($("#subcontentcontainer").height() - 30) < 287) {
        $("#subnewscontainer").height(287);
    } else {
        $("#subnewscontainer").height($("#subcontentcontainer").height() - 30);
    }
    
}

$(document).ready(function () {
    $("div.hpanel").click(
    function () {

        //$("#parent > div:eq(1)").show();

        if ($(this).next('.apanel').is(':visible')) {

            $(this).prev('img').attr("src", "images/arrowright.gif");
            $(this).next('.apanel').slideUp();

            object.style.zIndex="-1";

            event.preventDefault();

        }
        else {

            $(this).prev('img').attr("src", "images/arrowdown.gif");

            
            $(this).next('.apanel').slideDown('slow', function () {
                // Animation complete.
                StretchNewsSub();
            });


        }

        

    });
});

//function breadCrumb(){

//$(".breadcrumbcontainer a").addClass('link');

//};



//addLoadEvent(breadCrumb);
addLoadEvent(PreloadImages);
addLoadEvent(FormatNews);
addLoadEvent(StretchNewsSub);


