$(document).ready(function () {
	var langId = $.cookie('LANGUAGECODE') != null ? $.cookie('LANGUAGECODE') : 'en';

	if (langId.length == 0) return;

	$("a[href*=/play/?id]").each(function() {
		var href=$(this).attr('href');

		if (href.indexOf('lang') == -1) $(this).attr('href',  href + (href.indexOf('?') == -1 ? '?' : '&') + 'lang=' + langId);
	});

});


var featuredUrl= '/onlineincludes/featuredProperties.cfm?gameId=' + primaryCategoryId + '&pageheader=' + primaryCategory + '&r=' + Math.random();
$.get(featuredUrl, function(txt) {$('div#FeaturedProperties').html(txt); });

var recommendVersion = 0;

function weRecommendCallBack(text) {
	var langId = $.cookie('LANGUAGECODE') != null ? $.cookie('LANGUAGECODE') : 'en';

	$('div#WaitOtherOffers').html(text);



	if (langId.length > 0) //previously we returned out of the function;
	{
		$('div#WaitOtherOffers').find("a[href*=/play/?id]").each(function() {
			var href=$(this).attr('href');
			if (href.indexOf('lang') == -1) $(this).attr('href',  href + (href.indexOf('?') == -1 ? '?' : '&') + 'lang=' + langId);
		});
	}

	showDiv('waitBox');


	PrepareSlots();

}

function ShowWeRecommendPopup(propertyId, langCode, SiteOpen, PageHeader)
{ 
	window.scrollTo(0,0);
	var cookieLangCode = $.cookie('LANGUAGECODE') != null ? $.cookie('LANGUAGECODE') : 'en';

	if (SiteOpen == '')
	{
		SiteOpen = 'true';
	}

	if(langCode.length == 0)
	{
		langCode = cookieLangCode;
	}

	var recommendUrl = '';
	var randnum = Math.random();
	
	var weRecommendCountUrl = '/onlineincludes/weRecommendCount.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&pageheader=&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
	$.get(weRecommendCountUrl, function(txt) {
		var weRecommendCount = parseInt(txt);

		//alert(weRecommendCount); this is a hack - mahjong-rummy doesn't limit count to returncount, like the others.  proper fix is somewhere in .net land

		if (weRecommendCount > 3) { weRecommendCount = 3; }
		
		if(weRecommendCount < 3){<!-- id is property id, gameid is gamecategoryid -->
			recommendUrl = '/onlineincludes/weRecommend.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
		}
		else{
			//this block needs to be commented-in once the tracker text and game id values are included
			if(isRogueValue){
				recommendUrl = '/onlineincludes/rogue-popup.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
				//alert('rogue!');
			}
			else if(randnum > .75){
				recommendUrl = '/onlineincludes/weRecommend4.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
				recommendVersion = 4;
			}
			else if(randnum <= .75 && randnum > .5){
			recommendUrl = '/onlineincludes/weRecommend5.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
			}
			else if(randnum <= .5 && randnum > .25){
				recommendUrl = '/onlineincludes/weRecommend9.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
			}
			else if(randnum <= .25){
				recommendUrl = '/onlineincludes/weRecommend8.cfm?id=' + propertyId + '&gameId=' + primaryCategoryId + '&siteopen='+SiteOpen+'&pageheader='+escape(PageHeader)+'&text='+ escape(trackerTextVar) + '&propertyname=' + javascriptFormatName + '&r=' + Math.random() + '&cookieLangCode=' + cookieLangCode + '&linkLangCode=' + langCode;
				recommendVersion = 8;
			}
			
			
		}
		$.get(recommendUrl,  weRecommendCallBack);
	});
}

$(document).ready(function(){
	$('#Visit-Now').click(function(){
		$('#mainColumn *:first').show('fast');
		return false;
	})
});
