$(document).ready(function(){
/*
	$('ul#menu-main-menu > li').mouseenter(function(){
		//self = $(this);
		//clearTimeout(self.data('timeoutId'));
		$(this).find('ul').slideDown(300);
	});
	
	/*
	hover(
		function(){
			clearTimeout($('#footerContainer').data('timeoutId'));
			$('#footerContainer').stop().animate({bottom: '0'}, 300);
		},
		function(){
			var timeoutId = setTimeout(function(){ $('#footerContainer').animate({bottom: '-33px'}, 300);}, 800);
			$('#footerContainer').data('timeoutId', timeoutId); //set the timeoutId, allowing us to clear this trigger if the mouse comes back over
	});
	
	$("someelement").mouseenter(function(){
    clearTimeout($(this).data('timeoutId'));
    $(this).find(".tooltip").fadeIn("slow");
	}).mouseleave(function(){
	    var someelement = this;
	});

	$('ul#menu-main-menu').addClass('js-enabled');
	
	
	
	*/
	$('ul#menu-main-menu > li').hover(
		function(){
			var self = $(this);
			var data = $(this).data('timeoutId');
			if(data){
				clearTimeout(data);
			}
			self.addClass('hover');
			self.find('ul').slideDown(100);
		},
		function(){
			var self = $(this);
			var itemId = self.attr('id');
			var timeoutId = setTimeout('$("#'+itemId+'").removeClass("hover").find("ul").stop().slideUp(200);', 200);
			self.data('timeoutId', timeoutId);
		}
	);
	
	$('#eyespeak-slider-shadow').hover(
		function(){
			$('#menu-main-menu li').each(function(){
				if(data = $(this).data('timeoutId')){
					clearTimeout(data);
				}
			});
		},
		function(){
			$('#menu-main-menu li').each(function(){
				var self = $(this);			
				var itemId = self.attr('id');	
				var timeoutId = setTimeout('$("#'+itemId+'").removeClass("hover").find("ul").stop().slideUp(200);', 200);
				self.data('timeoutId', timeoutId);
			});
		}
	)

	var params = {wmode: 'transparent'};
	var flash = getQuerystring('flash');
	if (!flash || flash == "on")
		swfobject.embedSWF(templateUrl+'/ks_flash.swf', 'characters', "286", "531", '9.0.0', false, null, params);
});

function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

