

	$(document).ready(function ()
		{
		
			checkCookie();
		
			$.get('/onlineincludes/getdetails250ad.cfm?id='+propertyid+'&activeContract='+hasactivecontract, function(data)
				{
					$('#ad250x250').html(data).css('display','block');
				});



					  $("#casinosearchtop").submit(function() {
						$.cookie('activeSearchTab', '', {expires: -1});
					  });
					  
					  $("#casinosearchtop2").submit(function() {
						$.cookie('activeSearchTab', '', {expires: -1});
					  });
					
					  $("#AdvSearchText").click(function() {
						urchinTracker("/click/searchmodule/advancedsearch");
						return true;
					  });
					  
					  $("#SearchButton2").click(function() {
						urchinTracker("/click/searchmodule/gosearch/"+$("#searchTextBox").val());document.casinoSearch.submit();
					  });
					  
					  $("#AdvSearchText2").click(function() {
						urchinTracker('/click/searchmodule/advancedsearch');
						return true;
					  });

					  $("#propNameAffiliate").click(function() {
						urchinTracker(trackertextPropertyName);
						return true;
					  });
					  
					  $("#trackertextDL").click(function() {
						urchinTracker(trackertextDL);
						return true;
					  });
					  
					  $("#trackertextVisitNow").click(function() {
						urchinTracker(trackertextVisitNow);
						return true;
					  });
					  
					  $("#trackertextPlayNow").click(function() {
						urchinTracker(trackertextPlayNow);
						return true;
					  });
					 
					  $(".rankings-at-a-glance").click(function() {
						urchinTracker('/click/rankings-at-a-glance/');
						return true;
					  });
					  
					  $("#trackertextScreenShot").click(function() {
						urchinTracker(trackertextScreenShot);
						return true;
					  });
					  
					  $("#trackertext-offer").click(function() {
						urchinTracker(trackertext + '/offer');
						return true;
					  });
					  
					  $("#showallslots").click(function() {
						$('#moreslots').css('height','auto');$('#showallslots').hide();$('#collapseslots').show();
					  });

					  $("#collapseslots").click(function() {
						$('#moreslots').css('height','135px');$('#collapseslots').hide();$('#showallslots').show();
					  });
					  //has issue because the primarty category is not displaying correctly on the pop-up (gammon empire example)
					  $(".trackertextURLVisitOthers").click(function() {
						ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextURLVisitOthers);
						return false;
					  });

					  $("input.SearchButton").click(function() {
						urchinTracker('/click/searchmodule/gosearch/'+$('#searchTextBox').val());
						$("#casinoSearch").submit();
						//document.casinoSearch.submit();											
					  });
					  
					  $("#editPrefs").click(function() {
						urchinTracker('/click/preferences/box_link');
						return true;
					  });

					  $("#ad-link").click(function() {
						urchinTracker('/click/ads/igbd');
						return true;
					  });

					  $("#errorsLink").click(function() {
						urchinTracker('/clickoff/details/errors_omissions/link');
						return setPopUp(this);
					  });

					  $("#submitBtn").click(function() {
						urchinTracker('/clickoff/details/errors_omissions/submit');
						submitIt();
					  });

					  $("#cancelBtn").click(function() {
						urchinTracker('/clickoff/details/errors_omissions/cancel');
						return HideErrorsOmissions();
					  });

					  $("#eCograLink").click(function() {
						OpenWindow("/ecogra/cert.cfm?id={$propertyId}")
					  });
					  
					  
					  //this is where the alerts started to break - because of the ShowWeRecommendPopup
					  $("#propNameNotAffiliate").click(function() {
						ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextPropertyNameVisit);
						return false;
					  });
					  
					  $("#trackertextVisitElse").click(function() {
						ShowWeRecommendPopup(propertyId,"","true","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextVisitElse);
						return false;
					  });
					  
					  $("#trackertextRecommendFeat").click(function() {
						ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextRecommendFeat);
						return false;
					  });
					  
					  $("#trackertextScreenShotVisit").click(function() {
						ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextScreenShotVisit);
						return false;
					  });
					  
					  $("#trackertextURL1").click(function() {
						//this should not display a pop-up - affiliate sites - ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextURL);
						return true;
					  });
					  
					  $(".trackertextURLOthers").click(function() {
						//ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}"); 
						//this should not open the pop-ups because it should be an affiliate site.
						urchinTracker(trackertextURLOthers);
						return true;
					  });

					  $("#trackertextURLVisit").click(function() {
						ShowWeRecommendPopup(propertyId,"","","{OnlineGamingProperty/@PrimaryCategory}");
						urchinTracker(trackertextURLVisit);
						return false;
					  });
					  

					  $("#pref_off img").click(function() {

						$("#pref_off").css("display","none");
						$("#pref_off").css("visibility","hidden");

						$("#pref_on").css("display","block");
						$("#pref_on").css("visibility","visible");	
						
						setCookie('preferences','on',1);
						urchinTracker('/click/preferences/box_open');
						
						return true;
					  });


					  $("#pref_on img").click(function() {
					    
						$("#pref_on").css("display","none");
						$("#pref_on").css("visibility","hidden");

						$("#pref_off").css("display","block");
						$("#pref_off").css("visibility","visible");

						setCookie('preferences','off',1);
						urchinTracker('/click/preferences/box_close');
						
						return true;
					  });

					//Preference box values
					if (getCookie("LANGUAGEID")==0){$("#langname").text("Any Language");}else{$("#langname").text(getCookie("LANGUAGENAME"));}
					if (getCookie("LOCATIONID")==0){$("#locname").text("Any Location");}else{$("#locname").text(getCookie("LOCATIONNAME"));}																	  
					

					$('#IsVisitorRestricted').load('/onlineincludes/IsVisitorRestricted.cfm?id='+propertyid+'&r=' + Math.random());

					  
					});//end document.ready
				
						


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 teh 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);
	});
}










