// Written by 301 Design.

//
// This function uses the jquery library.
//

$(function() {
	


	//Show/Hide Languages panel 
	/*****************************
	include in update to staging
	******************************/

	// we were using the hover() method	
	// e.g. 	$("#pnlLanguagesShow").hover(function() {}
	// hover() requires two function arguments, one that gets
	// called when the mouse hovers over the element and one 
	// gets called when the mouse leaves the element. I think all
	// you need is the mouseover event.
	//
	// Note we set the 'visible' class attribute against the
	// #pnlLanguages element so we can keep track of its state
	
	// Reference the langauges panel here to avoid constant lookup
	// Note addition of background iframe 'shim' to enable the panel
	// to cover windowed objects like drop-down boxes and Flash objects.
	// You might have to adjust some of the bgiframe options to get
	// exact coverage - see documentation at:
	// http://brandonaaron.net/jquery/plugins/bgiframe/docs/

	var $languagePanel = $("#pnlLanguages").bgiframe();

	var languageTimer = null;

	var clearLanguageTimer = function() {
		if (languageTimer)
		{
			clearTimeout(languageTimer);
			languageTimer = null;
		}
	};

	var closeLanguagePanel = function() {
		clearLanguageTimer();
		$languagePanel.removeClass("visible").hide("slow");	
	};
	
	// Wire the events for opening (on mouseover) and closing (click)
	$("#pnlLanguagesShow").mouseover(function() {
			if (!$languagePanel.hasClass("visible")) {
				$languagePanel.show("slow").addClass("visible");
			}
	});
	$languagePanel.mouseout(function(evt) {
		languageTimer = setTimeout(function() {
			closeLanguagePanel();
		}, 250);
	})
	.mouseover(function() {
		clearLanguageTimer();
	})
	.children().mouseover(function() {
		clearLanguageTimer();
	});

	//$(".langsClose").click(function(evt) {
	//		evt.preventDefault();
	//		$languagePanel.removeClass("visible").hide("slow");
	//});


});






