$(function() {
	// Fix the instant games hovers
	$('#instant-games .contentpaneopen p').addClass('instant-game-hover');
	
	//add spaces between - on sidebar	
	 //var dash = $("#winning-numbers");
	 //dash.html( dash.html().replace(/>-</g,">&nbsp;-&nbsp;<") );
	  
  	//when hovering over 'games'
	$('#nav .itemgames').hover(function() {
 		$('#nav-drop').css("display", "block");
 		$('#nav .itemgames').addClass('navdrop'); 
 		return false;
 	}, function(){
 		$('#nav-drop').css("display", "none");
 		$('#nav .itemgames').removeClass('navdrop'); 
 	}); 
 	
	//when hovering over the 'games' drop down
	$('#nav-drop').hover(function() {
 		$('#nav-drop').css("display", "block");
 		$('#nav .itemgames').addClass('navdrop'); 
 		return false;
 	}, function(){
 		$('#nav-drop').css("display", "none");
 		$('#nav .itemgames').removeClass('navdrop'); 
 	});
 	
 	//display & hide home popup
 	$('.i_logo').hover(function(){
 		$('#home-popup').css("display", "block");
 		return false;
 		}, function(){
 		$('#home-popup').css("display", "none");
 	});
	
	//clears search box
	$('#wheretoplay').focus(function(){
		if(this.value=='Where to play (enter zip code)'){
			this.value='';
		}
	});
	
	//	Put's message back if no data...
	$('#wheretoplay').blur(function(){
		if ( this.value == '' || this.value == null )
			this.value = 'Where to play (enter zip code)';
	});
	
	//hover for featured games on home page
		$('.banneritem_gamebox, .winners-wrap').hover(function() {
				$(this).addClass('hover');
			}, function() {
				$(this).removeClass('hover');
			});
			
//-------------------------------------------------------------------------------
			
    // setup ul.tabs to work as tabs for each div directly under div.panes 
    $("ul.tabs").tabs("div.panes > div"); 

//-------------------------------------------------------------------------------


	//stripes for tables
  	$("#top-prizes-table tr:even").addClass("odd");
  	$("#ending-games-table tr:even").addClass("odd");


//-------------------------------------------------------------------------------



	//lotterybar slidebox
	
	var page = $('body').attr("id");
	 if (page == ('home')) {
		 $('#lotterybar').css("display", "block");
		 $('.numbers').addClass('active');
	 };
	
	$('#lotterybar-min a').click(function() {
		if($(this).hasClass('active')){ //if the current button is already clicked
		$('#lotterybar').slideToggle(); //slide down
	    $('#lotterybar-min a').removeClass('active'); //remove the active class
		return false;	
	}else if($('#lotterybar-min a').hasClass('active')){ //if any button is already clicked, leave the bar up
		var currentUp = $(this).attr("id"); //finds the lb attribute that relates to the id of the lotterybar sidebar
		$("#lotterybar-left ul").css("display", "none"); //hides all sidebar items
		$("#"+currentUp+"-show").css("display", "block"); //shows current sidebar
		$('#lotterybar-min a').removeClass('active'); //remove the active class from everything
		$(this).addClass('active'); //adds the active class to the clicked item
		return false;
	}else{ //animate the opening
		var currentUp = $(this).attr("id"); //finds the ld attribute that relates to the id of the lotterybar sidebar
		$("#lotterybar-left ul").css("display", "none"); //hides all sidebar items
		$("#"+currentUp+"-show").css("display", "block"); //shows current sidebar
		if($(this).attr('class')=='info'){
    		$('#lotterybar-left, #lottery-numbers-box').css("display", "none");
    		$('#lotterybar-right').addClass('helpbox');
		}
	    $('#lotterybar').slideToggle(); //slide up
	    $('#lotterybar-min a').removeClass('active'); //remove 'active' from everything
    	$(this).addClass('active'); //adds active class to the clicked item
    	return false;
	}
	
    });
    
    //hide and show for each lottery bar section
    $('.numbers').click(function(){
    	$('.show-right').css("display", "none");
    	$('#lotterybar-right').removeClass('helpbox');    	
    	$('#lottery-numbers-box, #lotterybar-left').css("display", "block");
		$('.close a').css("color", "#606060");
    	
    });
    $('.info').click(function(){
    	$('.show-right, #lotterybar-left').css("display", "none");
    	$('#lotterybar-right').addClass('helpbox');
    	$('#player-info-box').css("display", "block");
		$('.close a').css("color", "#606060");
    });
    $('.club').click(function(){
    	$('#lotterybar-left').css('display', 'block');
    	$('#lotterybar-right').removeClass('helpbox');    	    	
    	var _sDiv = 'div#players-club-box';
    	var _sRel = $('div#players-club-box-logged-in').attr('rel');
   		if ( _sRel ) {
   			_sDiv += '-logged-in';
   			$('#players-club-user-name').html(_sRel);
		}
    	$('.show-right').css("display", "none");
		$(_sDiv).css("display", "block");
		$('.close a').css("color", "#fff");
    });
    
   //close button function
	$('.close a').click(function() {
		$('#lotterybar').slideToggle(); //slide down
	    $('#lotterybar-min a').removeClass('active'); //remove the active class
	});
    
	//lottery clicks disabled
	
	$('#lotterybar-min a , .close a').click(function(){
		return false;
	});


// Jackpot slideshow text in header


	if($('.jackpot-scroll').length>0) {
	    $('.jackpot-scroll').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}

//tooltip on instant games page

	$('#instant-games p.instant-game-hover').hover(function(){
  		var pos = $(this).offset();  
  		var width = $(this).width();
  		var popText = $(this).next("div.instant-game-pop").html(); //find the text
  		var theTitle = $("img", this).attr("alt"); //find the title
  		var theLink = $("a", this).attr("href"); //find the url
		$("#tool-tip").css( { "left": (pos.left - 30) + "px", "top":(pos.top - 100) + "px", "display" : "block" } );
		$("#tool-tip").html("<h2>"+ theTitle + "</h2><p>" + popText + "</p><p class=\"hidie\"><a href=\"" + theLink + "\">View Game</a>");
	}, function(){
		$('#tool-tip').css("display", "none");		
	})
	

//tooltip code for main games page can be found on the mod_glc-gamepagenumbers template

		
//main tool tip code

	$('#tool-tip').hover(function(){
		$(this).css("display", "block");
	}, function(){
		$(this).css("display", "none");
	})


});




