function noSpamThanks( prefix ){ location.href = "mailto:"+prefix+"@pokerlistings.com"; }
function noSpamThanksWrite( prefix ){ document.write(prefix+"@pokerlistings.com"); }
function addbookmark(url,title)
{
	if( window.sidebar && window.sidebar.addPanel ) {
	    //Gecko (Netscape 6 etc.) - add to Sidebar
	    window.sidebar.addPanel( title, url, '' );
	} else if( window.external && ( navigator.platform == 'Win32' ||
	      ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
	    //IE Win32 or iCab - checking for AddFavorite produces errors for no
	    //good reason, so I use a platform and browser detect.
	    //adds the current page page as a favourite; if this is unwanted,
	    //simply write the desired page in here instead of 'location.href'
	    window.external.AddFavorite( url, title );
	} else if( window.opera && window.print ) {
	    //Opera 6+ - add as sidebar panel to Hotlist
	    return true;
	} else if( document.layers ) {
	    //NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
	    //not target page)
	    window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
	} else {
	    //other browsers - tell them to add a bookmark (adds current page, not target page)
	    window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
}
function showPop(u,w,h){ mywin = window.open(u,"pop",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+w+',height='+h+''); }
function showPopNoScroll(u,w,h){ mywin = window.open(u,"pop",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+''); }

function FixSize(){
 var x = document.pic.width + 32;
 var y = document.pic.height + 41;
 window.resizeTo(x,y);
}

function FixSizePhoto(){
 var x = document.pic.width + 141;
 var y = document.pic.height + 141;
 window.resizeTo(x,y);
}

function validateMail(form){
	email = form.email.value;
	at = email.indexOf("@");
	dot = email.indexOf(".");
	errmsg = "";

	if (email == "") {
		errmsg = "Please enter emailadress.\n";
	}else if(at < 1 | dot < 1){
		errmsg = "The entered emailadress not valid.\n";
	}

	if (errmsg != "") {
		alert(errmsg);
		return false;
	}
}

function currentDate(){
	var d=new Date()
	var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	document.write(monthname[d.getMonth()] + " ")
	document.write(d.getDate() + ", ")
	document.write(d.getFullYear())
}
/* This has switched to trackerID implementation */
function checkCookie()
{
	sc_id = $.cookie( 'sc_id' );
	if ( sc_id == null || sc_id == "")
	{
		pb_id = $.cookie( 'pb_id' );
		s_vi = $.cookie( 's_vi' );
		if ( ( s_vi != null && s_vi != "" ) && ( pb_id == null || pb_id == "" ) )
		{
			sc_id = s_vi;
			$.cookie( 'sc_id', sc_id, { path: '/', expires: 1 });
			return 'created_' + sc_id;
		}
		else if ( ( s_vi != null && s_vi != "" ) && ( pb_id != null && pb_id != "" ) )
		{
			sc_id = s_vi;
			$.cookie( 'sc_id', sc_id, { path: '/', expires: 1 });
			return 'updated_' + sc_id + '_' + pb_id;
		}
		else if ( ( s_vi == null || s_vi == "" ) && ( pb_id == null || pb_id == "" ) )
		{
			return 'null_0';
		}
		else
		{
			return 'failed_0';
		}
	}
	else 
	{
		s_vi = $.cookie( 's_vi' );
		if ( s_vi == null && s_vi == "" )
		{
			$.cookie( 'sc_id', null);
			return 'null_0';
		}
		else if ( sc_id != s_vi )
		{
			sc_id = s_vi;
			$.cookie( 'sc_id', sc_id, { path: '/', expires: 1 });
			return 'created_' + sc_id;
		}
		else
		{
			return 'existed_' + sc_id;
		}
	}
}

var isUsIp = 'no';
var isCanadianIp = 'no';
var isGermanIp = 'no';
var isItalianIp = 'no';

$(document).ready(function() {
	// Add validator to newsletter form	
	$("#fp-newsletter-form").submit(function() {	
		return validateMail(this);	
	})

	//Check the client ip address
	$.get("/ajax/geo-ip/ip-check", function( data ){
	   
		//US ip settings
		if( data == 'US' ){
			isUsIp = 'yes';
			$("p").filter('.us-only').each(function(i) {
				$(this).removeClass('us-only');
			});
		}
		$("#ql-prr").find('li').each(function(i) {
			if( data != 'US' ){
				$(this).removeClass('non-us-only');
			}else{
				$(this).removeClass('us-only');
			}
		});
		
		//Canadian ip settings
		if( data == 'CA' ){
			isCanadianIp = 'yes';
			$("p").filter('.ca-only').each(function(i) {
				$(this).removeClass('ca-only');
			});
		}
		$("#ql-prr").find('li').each(function(i) {
			if( data != 'CA' ){
				$(this).removeClass('non-ca-only');
			}else{
				$(this).removeClass('ca-only');
			}
		});
		
		//Italian ip settings
		if( data == 'IT' ){
			isItalianIp = 'yes';
			$("p").filter('.it-only').each(function(i) {
				$(this).removeClass('it-only');
			});
		}
		$("#ql-prr").find('li').each(function(i) {
			if( data != 'IT' ){
				$(this).removeClass('non-it-only');
			}else{
				$(this).removeClass('it-only');
			}
		});
		
		//German ip settings
		if( data == 'DE' ){
			isGermanIp = 'yes';
			$("p").filter('.de-only').each(function(i) {
				$(this).removeClass('de-only');
			});
		}
		$("#ql-prr").find('li').each(function(i) {
			if( data != 'DE' ){
				$(this).removeClass('non-de-only');
			}else{
				$(this).removeClass('de-only');
			}
		});
		
	});

	if( $.browser.msie ) {
		$("table").filter('.toplist').each(function(i) {
			$(this).find('tr').mouseover(function(i) {
				$(this).addClass('hover');
			}).mouseout(function(i) {
				$(this).removeClass('hover');
			})
		});
	}
});

