$(document).ready(function(){
    var businessSections = new Array();
    var productsSections = new Array();
    var aboutSections = new Array();
    
    /* 
        These equate to the first part of the page's path, i.e. "/about/contact"" == "about"
        Add more elements here to have the left menu auto-expand for different page paths
    */
    businessSections = ["business", "industry", "customers", "solutions", "partners"];
    productsSections = ["products"]
    aboutSections = ["about"]

    var url = $("#url").attr("content");

    // stupid IE hack
    var fixedUrl = url.replace(/^\//,'');
    var sect = fixedUrl.split(/\//)[0];    
    
    // From http://snook.ca/archives/javascript/testing_for_a_v/
    function oc(a)
    {
        var o = {};
        for(var i=0;i<a.length;i++)
        {
            o[a[i]]='';
        }
        return o;
    }
    
    if($("#leftMenu")) {
        $("#leftMenu dd").hide();
        $("#leftMenu dt").click(function() {
	        if(this.className.indexOf("clicked") != -1) {
		        $(this).next().slideUp(250);
		        $(this).removeClass("clicked");
	        }
	        else {
		        $("#leftMenu dt").removeClass("clicked");
		        $(this).addClass("clicked");
		        $("#leftMenu dd:visible").slideUp(250);
		        $(this).next().slideDown(300);
	        }
	        return false;
        });
        if ( sect ) {

            var section = "none";
            if (sect in oc(businessSections)) {
                section = "business";
            } else if (sect in oc(productsSections)) {
                section = "products";
            } else if (sect in oc(aboutSections)) {
                section = "about";
            }
            
            if (section != "none") {
	            $("#"+section).addClass("clicked");
	            $("#leftMenu dd:visible").slideUp(250);
	            $("#"+section).next().slideDown(300);
	       }
        }
    }
});


