﻿
/*********************************
* AddThis Configuration
* Configures what services will be available in the
* share menu for customization information visit:
* http://www.addthis.com/help/custom-buttons
*********************************/
var addthis_config = {
    services_compact: 'delicious,digg,facebook,favorites,linkedin,myspace,reddit,stumbleupon,tipd,twitters,more',
    services_expanded: 'aim,aolmail,ask,bizsugar,blogger,delicious,digg,diigo,fabulously40,facebook,favorites,friendfeed,'+
        'gmail,google,googlereader,hotmail,linkedin,live,mixx,myaol,myspace,netvibes,phonefavs,pingfm,planypus,plaxo,propeller,'+
        'reddit,stumbleupon,technorati,tipd,tumblr,twitter,typepad,viadeo,wordpress,yahoobkm,yahoomail,yammer'
}

/*********************************
 * Navigation Functions
 *********************************/
function toggleSidebarContent(content) {
    if (content.is(":hidden")) {
        openSidebar(content);
    } else {
        closeSidebar(content);
    }
}

function closeSidebar(content) {
    content.hide();
    content.parent().find(".header img").attr("src", "/bolimages/main/bid/sidebar-node.gif");
}

function openSidebar(content) {
    content.show();
    content.parent().find(".header img").attr("src", "/bolimages/main/bid/sidebar-node-on.gif");
}

$(function() {
    /* set up the click handler on the 
    side bar elements */
    $("#sidebar .header").click(function() {
        var content = $(this).parent().find(".content");
        toggleSidebarContent(content);
    });

    /* For handling the Read More Rollovers */
//    $(".link").mouseenter(function() {
//        var img = $(this).find("img");
//        img.attr("src", "/bolimages/main/bid/subheader-node-on.gif");
//    });
//    $(".link").mouseleave(function() {
//        var img = $(this).find("img");
//        img.attr("src", "/bolimages/main/bid/subheader-node.gif");
//    });

    /* for handling the shadow boxes */
    $("#sidebar .item").mouseenter(function() {
        var element = this;
        $(this).stopTime(); // stop any timers

        // loop the matching elements hide all not open
        $("#sidebar .item").each(function() {
            var activeElement = $(this);

            if (this == element) {
                // show this element
                activeElement.css("background-color", "#BB9966");
                activeElement.find(".headline").css("color", "#ffffff");
                activeElement.find(".headline").css("background-color", "#BB9966");
                activeElement.find(".body").css("background-color", "#333333");
                activeElement.find(".body").css("background-color", "#BB9966");
                var shadowBox = activeElement.find(".shadowRight");
                if(shadowBox.length)
                    shadowBox.show();

            } else {
                hideShadowBoxRight(this);
            }
        });
    });
    $("#sidebar .item").mouseleave(function() {
        $(this).oneTime(200, function() {
            hideShadowBoxRight(this);
        });
    });

    /* hides a right shadow boxs and set the color of the 
    element to its default state */
    function hideShadowBoxRight(element) {
        var jElement = $(element);
        jElement.css("background-color", "#F8F5EF");
        jElement.find(".headline").css("color", "#00539B");
        jElement.find(".headline").css("background-color", "#F8F5EF");
        jElement.find(".body").css("background-color", "#666666");
        jElement.find(".body").css("background-color", "#F8F5EF");
        var shadowBox = jElement.find(".shadowRight");
        if (shadowBox.length)
            shadowBox.hide();
    }
    
/* Right Bar */
    /* set up the click handler on the right bar elements */
    $("#rightSidebar2 .profile").click(function() {
        var content = $(this).parent().find(".content");
        toggleSidebarContent(content);
    });

    /* for handling the shadow boxes */
    $("#rightSidebar2 .profile").mouseenter(function() {
        var element = this;
        $(this).stopTime(); // stop any timers

        // loop the matching elements hide all not open
        $("#rightSidebar2 .profile").each(function() {
            var activeElement = $(this);

            if (this == element) {
                // show this element
                var shadowBox = activeElement.find(".shadowLeft");
                if (shadowBox.length)
                    shadowBox.show();

            } else {
                hideShadowBoxLeft(this);
            }
        });
    });
    $("#rightSidebar2 .profile").mouseleave(function() {
        $(this).oneTime(200, function() {
            hideShadowBoxLeft(this);
        });
    });

    /* hides a right shadow boxs and set the color of the 
    element to its default state */
    function hideShadowBoxLeft(element) {
        var jElement = $(element);
        var shadowBox = jElement.find(".shadowLeft");
        if (shadowBox.length)
            shadowBox.hide();
    }
    
    /* End Right Bar */    

   

   

/*
    $(".profile").mouseenter(function() {
        $(this).find(".shadowLeft").show();
    });
    $(".profile").mouseleave(function() {
        $(this).oneTime(200, function() {
            $(this).find(".shadowLeft").hide();
        });
    });
*/
    // close elements by default
    $("#sidebar .shadowRight").hide();
    $("#rightSidebar2 .shadowLeft").hide();
    closeSidebar($("#content_calendar"));

    var zBubble = 9000;
    $("div").each(function() {
        $(this).css('zIndex', zBubble);
        zBubble -= 1;
    });

    // Move subheader back some
    $("#subheader").css('zIndex', 1);
    
    zBubble = 1000;
    $("#content1,#content2").each(function() {
        $(this).css('zIndex', zBubble);
        zBubble -= 1;
    });

});
