jQuery(document).ready(function() {
								
	 /*******************************************************************************************/
	 jQuery(".page-casino_bonus_loyalty #loyaltyPointsTable").insertAfter("#loyaltyPlaceholder");	 
	 /*******************************************************************************************/
	
	 jQuery(".textAreaP").hover( 
								
			function() {
				jQuery(".textAreaP").stop();
				jQuery(this).animate({"border-color": "#ffc439"}, "slow");

			},
			function() {
				jQuery(this).animate({"border-color": "#443300"}, "slow");				
			}
	);		
	
	 /***** FLASH **************************************************************************************/
	 if (jQuery.browser.flash == false)  {
		 jQuery("#downloadNow").html("<a id='downloadNow_noflash' class='themeButton2' href='"+jQuery("#downloadNow").attr("customURL")+"'>"+jQuery("#downloadNow").attr("customLABEL")+"</a>");
	 }
	 if (jQuery.browser.flash == false)  {		 
		  			jQuery("#logo").html("<div class='logo_noflash'></div>");
	 }
	 /*******************************************************************************************/
		
	
	jQuery(".ui_image").hover(
		  function () {
			jQuery(this).animate({"border-color": "#c09100"}, "slow");
		  },
		  function () {
			jQuery(this).animate({"border-color": "#735700"}, "slow");
		  }
	);	
	
	jQuery( "#navigation li" ).hover(			
			function() {
				jQuery( "#navigation li" ).stop();
				
				jQuery( "#navigation li" ).fadeTo("fast",0.4);
				jQuery(this).fadeTo("fast",1);

			},
			function() {
				jQuery( "#navigation li" ).fadeTo("slow",1);
				jQuery( "#navigation li" ).stop();
			}
	);	
	jQuery( "#gameButtons a" ).hover(			
			function() {				
				jQuery(this).fadeTo("fast",1);

			},
			function() {
				//do nothing
			}
	);	
	jQuery( ".header_content" ).hover(			
			function() {	
				//do nothing
			},
			function() {				
				jQuery( "#navigation li" ).stop();
				jQuery( "#navigation li" ).fadeTo("fast",1);
			}
	);	
									 
	
	//CHAT
	jQuery(".casino-chat").dialog( 
		  {
			  autoOpen : false,
			  zIndex: 100,
			  stack: true,
			  resizable : true,
			  width:550,
			 
			  hide: "fade",
			  
			  show : "fade",
			  
			  resizeStop: function(event, ui) {
				   var height = jQuery(".casino-chat").dialog( "option", "height" );
				   var messageHeight = height - 160;
				   jQuery(".message-window").animate( { height: messageHeight } );
			  },		
			  beforeClose: function(event, ui) { 
					jQuery(".casino-chat").effect("transfer",{ to: jQuery( "#chatButton" ) }, 500);	
			  },
			  close: function(event, ui) {
				 	chat.deactivate();
			  }
		  } 
	);
	jQuery("#chatButton , #chatButton2").click( 
		function() {
			
			if(!jQuery( ".casino-chat" ).dialog("isOpen") ) {
				
				jQuery("#SupportMsgInput").attr("value",">");
				jQuery("#SupportSendButton").trigger("click");			
				chat.activate();
				
			}
			
		}	
	);
	jQuery(".game-icon-ctnr").hover(
		  function() {
				jQuery(this).find(".game-icon").fadeIn("fast");

			},
			function() {
				jQuery(this).find(".game-icon").fadeOut("fast");				
			}
	);	
	
	//use manual switch of gametype indicators if not in game related pages, if yes the function would be called manually through
	//the file so that they server-side variable (gameType) is passed to the function
	if(!jQuery("body").hasClass("thegames") && !jQuery("body").hasClass("page-thegame_display") ) {
		showActiveGame();
	}	
	
	
	/****************** QUICKSEARCH **************************************************/	
	if(jQuery("body").hasClass("thegames")) {
		jQuery( ".quickSearch select" ).combobox();		
	}	
	jQuery(".quickSearch").appendTo(".titleBar");	
	sortDropDownListByText("#quickSearchDropdown");
	/****************************************************************************/	
	
	
	
	/****************** TOOLTIP **************************************************/	
	jQuery(".slotMachineIconLink").wijtooltip();
	jQuery(".slotMachineIconLink").wijtooltip("option","closeBehavior","auto");
	//this line is slowing down the entire page for an unknown reason
	//jQuery(".slotMachineIconLink").wijtooltip("option","position",{my: 'center bottom', at: 'center top'});
	/****************************************************************************/	
	
	
	
	jQuery(".ui-autocomplete-input").focus( 
		function() {								   
			jQuery(this).attr("value","");
		}
	);
	
	

});
/*******************************************************************************************************/
function sortDropDownListByText(getRef) {
    // Loop for each select element on the page.
    jQuery(getRef).each(function() {

        // Keep track of the selected option.
        var selectedValue = jQuery(this).val();

        // Sort all the options by text. I could easily sort these by val.
        jQuery(this).html(jQuery("option", jQuery(this)).sort(function(a, b) {
            return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
        }));

        // Select one option.
        jQuery(this).val(selectedValue);
		
    });
}

function showActiveGame(getGameType) {
	
	
	//the argument of this function is passed from thegame_display.asp or thegames.asp
	jQuery( ".unscrollableWindow .gameTypes a" ).hover(			
			function() {				
				jQuery(this).fadeTo("fast",1);

			},
			function() {
				jQuery(this).fadeTo("slow",0.6);
			}
	);		
	
	jQuery(".unscrollableWindow .gameTypes a").fadeTo("slow",0.6);

	switch (getGameType) {
		case "1" :
			setActiveGame(".gameTypes .sm");
			break;
		case "2" :
			setActiveGame(".gameTypes .tg");
			break;
		case "3" :
			setActiveGame(".gameTypes .vp");
			break;
		case "4" :
			setActiveGame(".gameTypes .sc");
			break;
		case "6" :
			setActiveGame(".gameTypes .sc");
			break;
	}
}
function setActiveGame(getReg) {
		jQuery(getReg).unbind("mouseleave hover");
		jQuery(getReg).fadeTo("fast",1);		
}
function goToGame(getID) {
	location.href = "/thegame_display.asp?gameid=" + getID
}
function setButtonOn(getRef) {
	jQuery(getRef).addClass("themeButton2");
}
/************************************************************************************************/

