var menu = {
		init: function(){
			// extend jquery hoverClass 
			jQuery.fn.hoverClass = function(c){
				return this.each(function(){
					jQuery(this).hover(function(){
						jQuery(this).addClass(c);
					}, function(){
						jQuery(this).removeClass(c);
					});
				});
			};
			 
			// main menu
			jQuery("#dropdown li").hover(function(){
				jQuery("ul li", this).fadeIn("fast");
			}, function(){
				jQuery("ul li", this).css("display", "none");
			});
			
			if (document.all) {
				jQuery("#dropdown li").hoverClass("sfHover");
			};
		}
}
  
jQuery.noConflict(); 
jQuery(document).ready(function(){
	menu.init();
	languageNav();
});


function showSearchHelp(helpId) {
	 var helpDiv = jQuery('#' + helpId);
	 if (helpDiv.css('display') == 'none')
	 	helpDiv.slideDown("fast");
	else
		helpDiv.slideUp("fast");
}


/**
 * flag icons
 */

function languageNav(){
   
   var activeButtonStrg = activeLanguage.toUpperCase() + "_1";
	jQuery("#languageNav img").hover(function(){
		if (this.src.indexOf(activeButtonStrg) == -1)
			this.src = this.src.replace("_1", "_2");
		setActiveLanguageFlag();	
    }, function(){
        if (this.src.indexOf(activeButtonStrg) == -1)
			this.src = this.src.replace("_2", "_1");
		setActiveLanguageFlag();	
    });
	setActiveLanguageFlag();	
	
}

function setActiveLanguageFlag() {
	// set active icon
    // active_language is set in template via TS
	jQuery("#languageNav img").each(function () {
		this.src = this.src.replace(activeLanguage.toUpperCase() + "_1", activeLanguage.toUpperCase() + "_2");
		});

}
