/*** begin jQuery ***/

/* make links in left nav show icon on hover */

//global function to set background image, for leftNav only
jQuery.fn.setLeftNavBg = function(){
	if(jQuery(this).attr("img")){
		jQuery(this).css("background","transparent url(" + jQuery(this).attr("img") + ") no-repeat scroll 8px center");
	}
};



jQuery(document).ready(function() {

	
	/*** top nav submenus ***/

	//activate menus
	jQuery("ul.topNav > li").hover(
		function(){
			jQuery(".subNav",this).removeClass("hidden");
		},
		function(){
			jQuery(".subNav",this).addClass("hidden");
		}
	);
	/* Remove for now - way ugly 
	jQuery("#footAboutMindjet").hover(
		function(){
			jQuery("div.fNav1").removeClass("hidden");
		},
		function(){
			jQuery("div.fNav1").addClass("hidden");
		}
	);
	
	jQuery("#footMedia").hover(
		function(){
			jQuery("div.fNav2").removeClass("hidden");
		},
		function(){
			jQuery("div.fNav2").addClass("hidden");
		}
	);
	*/
	/*** locale chooser ***/
	
	//activate locale chooser visibility
	jQuery("#localeChooser").hover(
		function(){
			jQuery("#localeDropDown").removeClass("hidden");
		},
		function(){
			jQuery("#localeDropDown").addClass("hidden");
		}
	);
	
	//activate language drop-down
	jQuery("#localeDropDown a").click(function(){
		setLocale(jQuery("span",this).attr('id'));
		return false;
	});	
	
	
	/*** left nav display ***/
	if (jQuery("#leftNav").length != 0) {
	//set bg image for nav title, even if not selected
	jQuery("#leftNav div.navTitle a[img]").setLeftNavBg();	
	
	//for each div containing a selected link (class="on")	
	jQuery("#leftNav div.section:has(a.on)").each(function(){

		 //force "on" class and permanent background 
		 jQuery(this).find("a:first").addClass("on").setLeftNavBg();
		 
		 //unhide selected section's subsections, if they were hidden to begin with
		 jQuery(this).find("div.subsection.hidden").removeClass("hidden");

	});
		
	//for all sections that do not contain an "on" link
	//activate hover to show img="" attribute
	jQuery("#leftNav div.section:not(:has(a.on)) a[img][class!=on]").hover(
	      function () {
	        jQuery(this).setLeftNavBg();
	      }, 
	      function () {
	      	jQuery(this).css("background","");
	      }
    );
        
}
});


