/*
 *
 * Modry Las common JS script
 *
 */

$(document).ready(function() {
//, div.evt_tournament_option
	// Ensure that hover generates a nice DIV fill on the menu
	$("div.top_menu, div.menu").hover(function(e) {
		$(this).addClass("menu_link_hovered");
		$(this).find("a").addClass("menu_link_hovered");
	},function(e){
		$(this).removeClass("menu_link_hovered");
		$(this).find("a").removeClass("menu_link_hovered"); 	
		// must add / remove class to the anchor explicitly, if just triggering a focus / blur on it, DIV loses the full fill on click
	});
//, a.evt_in_tournament_options	
	// The same for keyboard navigation (with one snag - when navigate with keyboard AND mouse at the same time, can get unexpected results - DIV highliht + another A highlihgt
	// Need to use addClass / removeClass rather than toggleClass because it clashes with the mouse hovering
	$("a.in_top_menu, a.in_main_menu").bind("focus", function(e){
        $(this).parent().addClass("menu_link_hovered");
   	})
   	.bind("blur", function(e){   		
        $(this).parent().removeClass("menu_link_hovered");
   	});
//, div.evt_tournament_option
	// Handle the DIV click on the menu
	$("div.top_menu, div.menu").click(function(e) {
		e.preventDefault();
		var link_dest = $(this).find("a").attr("href");
// to be used later if necessary for establishing new window / same window		
//		var link_class = $(this).find("a").attr("class");
		window.document.location = link_dest;
	});
	
	 $.fn.wait = function(time, type) {
	        time = time || 1000;
	        type = type || "fx";
	        return this.queue(type, function() {
	            var self = this;
	            setTimeout(function() {
	                $(self).dequeue();
	            }, time);
	        });
	    };

	// Animate the entrance of the important links	    
	$("div#top_menu_element_1").wait().show('slow');
	$("div#top_menu_element_2").wait().show('slow');
	$( "#tabs" ).tabs();	
});

