var poker_players = "";
var poker_poker_tables = "";
var poker_badbeat = "";
var racing_tracks = "";

// css image pre-loader
jQuery.preloadCssImages=function(c){c=jQuery.extend({statusTextEl:null,statusBarEl:null,errorDelay:999,simultaneousCacheLoading:2},c);var a=[],f=0,d=[],g,e;function i(){clearTimeout(e);if(d&&d.length&&d[f]){f++;if(c.statusTextEl){var j=(d[f])?"Now Loading: <span>"+d[f].split("/")[d[f].split("/").length-1]:"Loading complete";jQuery(c.statusTextEl).html('<span class="numLoaded">'+f+'</span> of <span class="numTotal">'+d.length+'</span> loaded (<span class="percentLoaded">'+(f/d.length*100).toFixed(0)+'%</span>) <span class="currentImg">'+j+"</span></span>")}if(c.statusBarEl){var k=jQuery(c.statusBarEl).width();jQuery(c.statusBarEl).css("background-position",-(k-(k*f/d.length).toFixed(0))+"px 50%")}h()}}function h(){if(d&&d.length&&d[f]){var j=new Image();j.src=d[f];if(!j.complete){jQuery(j).bind("error load onreadystatechange",i)}else{i()}e=setTimeout(i,c.errorDelay)}}function b(n,y){var v=false,r=[],p=[],z;var o=n.length;while(o--){var x="";if(y&&y[o]){z=y[o]}else{var B=(n[o].href)?n[o].href:"window.location.href";var A=B.split("/");A.pop();z=A.join("/");if(z){z+="/"}}if(n[o].cssRules||n[o].rules){g=(n[o].cssRules)?n[o].cssRules:n[o].rules;var s=g.length;while(s--){if(g[s].style&&g[s].style.cssText){var q=g[s].style.cssText;if(q.toLowerCase().indexOf("url")!=-1){x+=q}}else{if(g[s].styleSheet){r.push(g[s].styleSheet);v=true}}}}var C=x.match(/[^\("]+\.(gif|jpg|jpeg|png)/g);if(C){var u=C.length;while(u--){var k=(C[u].charAt(0)=="/"||C[u].match("://"))?C[u]:z+C[u];if(jQuery.inArray(k,d)==-1){d.push(k)}}}if(!v&&n[o].imports&&n[o].imports.length){for(var l=0,j=n[o].imports.length;l<j;l++){var w=n[o].imports[l].href;w=w.split("/");w.pop();w=w.join("/");if(w){w+="/"}var m=(w.charAt(0)=="/"||w.match("://"))?w:z+w;p.push(m);r.push(n[o].imports[l])}}}if(r.length){b(r,p);return false}var t=c.simultaneousCacheLoading;while(t--){setTimeout(h,t)}}b(document.styleSheets);return d};


//jFav - jQuery favourite script
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(7($){$.8.9=7(d){g e=$.v({},$.8.9.k,d);g f=e.l;2.w(7(){5(!$(2).3(\'4\')||$(2).3(\'4\')=="#"){$(2).3(\'4\',j.x.4)}5(!$(2).3(\'6\')){$(2).3(\'6\',y.6)}5($.h.z){$(2).3(\'m\',$(2).3(\'4\')).3(\'4\',\'\').3(\'4\',\'A:B(0)\').3(\'C\',\'$.8.9.n(2,"\'+$(2).3(\'6\')+\'","\'+$(2).3(\'m\')+\'")\')}i{$(2).o(p)}});7 p(a){g b=$(2).3(\'4\');g c=$(2).3(\'6\');b=b.E("q:///","F://q/");5($.h.G){j.H.I(b,c)}i 5($.h.J){j.r.K(c,b,\'\')}i 5(L.M.N().O(\'P\')>-1){s(f)}i 5($.h.Q){s(f)}a.R()};t 2};$.8.9.k={l:\'S "T + D" U "V + D" W X, u Y 2 Z u 10 11.\'};$.8.9.n=7(e,a,b){e.12="r";e.6=a;e.4="";e.4=b;e.o();t 13}})(14);',62,67,'||this|attr|href|if|title|function|fn|jFav|||||||var|browser|else|window|defaults|msg|link|OperaBookmark|click|addToFavorites|file|sidebar|alert|return|to|extend|each|location|document|opera|javascript|void|onClick||replace|http|msie|external|AddFavorite|mozilla|addPanel|navigator|userAgent|toLowerCase|indexOf|chrome|safari|preventDefault|Press|Ctrl|or|CMD|for|MAC|add|page|your|bookmarks|rel|false|jQuery'.split('|'),0,{}))


//Auto download function
function autoDownload() {
	$('a.auto-download').each(function() {
		var  downloadUrl = $(this);
		setTimeout(function () {window.location = downloadUrl.attr('href');}, 5000);					   
	});
}

//jQuery Cookies
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

function cookieNameGrabber(){
	$('form').submit(function(){
		var $inputsToTag = $(this).find('input');
		$inputsToTag.addClass('submit');
		$.cookie('alsun', $("input.submit[name*='username'],input.submit[name*='userid']").attr('value'), { path: '/', domain: window.location.host.replace("www.","") });
	});
}

// Call with number_format(number, decimals, comma, formatSeparator);
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 k(a,b,c,d){a=5.l(a*5.6(7,b))/5.6(7,b);e=a+\'\';f=e.m(\'.\');4(!f[0])f[0]=\'0\';4(!f[1])f[1]=\'\';4(f[1].2<b){g=f[1];8(i=f[1].2+1;i<=b;i++){g+=\'0\'}f[1]=g}4(d!=\'\'&&f[0].2>3){h=f[0];f[0]=\'\';8(j=3;j<h.2;j+=3){i=h.n(h.2-j,h.2-j+3);f[0]=d+i+f[0]+\'\'}j=h.o(0,(h.2%3==0)?3:(h.2%3));f[0]=j+f[0]}c=(b<=0)?\'\':c;p f[0]+c+f[1]}',26,26,'||length||if|Math|pow|10|for|function|||||||||||number_format|round|split|slice|substr|return'.split('|'),0,{}));


//Call jackpot(speed,id) Speed 1-5
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('y p(a,b){k(g.l||g.q){h=g.l?g.l(b):g.q[b];k(h&&(z h.m)!=\'A\'){r c=h.m;c=c.s(1);c=c.B(/,/,"");n=2;t=4;i=(j.u(j.v()*(t-n)))+n;i=".0"+i;7=w(c)+w(i);7=C(7,2,\'.\',\',\');7="$"+7;r d=7.D(\'.\');k(d>0){7+=\'x\';7=7.s(0,d+=3)}E 7=7+\'.x\';h.m=7;F(a){f 0:8=G;9=H;e;f 1:8=I;9=J;e;f 2:8=K;9=L;e;f 3:8=o;9=M;e;f 4:8=N;9=O;e;f 5:8=P;9=Q;e;f 6:8=R;9=S;e;T:8=o;9=o;e}U("p("+a+",\'"+b+"\')",(j.u(j.v()*(9-8)))+8)}}}',57,57,'|||||||updatedvalue|mininterval|maxinterval|||||break|case|document|objH|increment_value|Math|if|getElementById|innerHTML|minincrement|2500|jackpot|all|var|substring|maxincrement|round|random|parseFloat|00|function|typeof|undefined|replace|number_format|indexOf|else|switch|500|700|1000|1400|2000|2800|3700|3000|5000|3500|7000|4000|8000|default|setTimeout'.split('|'),0,{}));

/* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

//Auto download function
function autoDownload() {
	$('a.auto-download').each(function() {
		var  downloadUrl = $(this);
		setTimeout(function () {window.location = downloadUrl.attr('href');}, 5000);					   
	});
}

// Ajax Live Odds Loader
function liveOddsLoader(ajaxType, ajaxTarget, ajaxSelected, ajaxButtons, hash) {
	ajaxButtons.removeClass('active');
	
	//checks to see if a sports number is passed in
	if (hash == 'hash') {
		ajaxURL = "http://www.sporting-affiliates.com/sports/" + ajaxType + "/betusa/" + ajaxSelected + "/";;
		
		currentSportsNumber = window.location.hash;
		curretSportsNumber = currentSportsNumber.replace('#','');
		$('span.' + window.location.hash.replace('#','')).addClass('active');
	}
	else {
		ajaxURL = "http://www.sporting-affiliates.com/sports/" + ajaxType + "/betusa/" + ajaxSelected.attr('class') + "/";
		ajaxSelected.addClass('active');
	}

	
	// Move loader gif insertion to before the ajax call, since after switching it to dataType to "script" it stopped working.
	ajaxTarget.html('<p><img src="/10/images/furniture/ajax-loader.gif" alt="" /></p>');
	
	// Ajax call
	$.ajax({
		url:ajaxURL,
		cache: false,
		dataType: "script",
		beforeSend: function(html){

		},
		success: function(html) {
			ajaxTarget.hide();
			//alert(html.replace("()",""));
			ajaxTarget.html(odds_ajax);
			$('#liveodds-ajax table tr th a').each(function(){
				$(this).html($(this).html().replace("()",""));
				$(this).html($(this).html().replace("OFF","</a><br /> No Points Spread Bet Available<a>"));
			});
			$('#liveodds-ajax div.game').each(function(){
				var check_line = $(this).find('span.line').html().indexOf('(OFF)');
				var check_money = $(this).find('span.money').html().indexOf('(OFF)');
				var check_total = $(this).find('span.total').html().indexOf('(OFF)');
				if (check_line != -1) {
					if (check_money != -1) {
						if (check_total != -1) {
						} else {
							$(this).find('span.line').addClass('displayNone');
							$(this).find('span.total').addClass('displayBlock');
						}
					} else {
						$(this).find('span.line').addClass('displayNone');
						$(this).find('span.money').addClass('displayBlock');
					}
				}
			});
			ajaxTarget.fadeIn('1000');
		}
	});	
}

function DailyLoader() {
	var ajaxTarget2 = $('#dail-table-body');
	
	$.ajax({
			url:"/odds/ajax/daily",
			cache: false,
			success: function(html) {
				ajaxTarget2.html(html);
			}
	});
	
}

// Works out page height
function pageHeight() {
	var y;
	if (self.innerHeight) {
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		y = document.body.clientHeight;
	}
	return y;
}

// For resizing logged in lines
function resizeLayers() {
	var page = pageHeight();
	var newHeight = page - 156;
	//var newHeight = page - 125;
	var minHeight = 328;
	if (newHeight <= minHeight){
		$('#BETTING').attr('height',328 );
	} else {
		$('#BETTING').attr('height',newHeight);
	}
} 

function showNav() {

	var baseURL = ["http://www.betusa.com", "http://betusa.com"];
	var documentURL = decodeURI(document.location);

	$('#navlist ul').each(function(){
		$(this).addClass('hideComplete');
	});
	
	$('#navlist a').each(function(){
	//	var checkURL = [baseURL[0] + $(this).attr('href'), baseURL[1] + $(this).attr('href'), baseURL[2] + $(this).attr('href'), baseURL[3] + $(this).attr('href'), baseURL[4] + $(this).attr('href'), baseURL[5] + $(this).attr('href')];
		//if (checkURL[0] == documentURL || checkURL[1] == documentURL || checkURL[2] == documentURL || checkURL[3] == documentURL || checkURL[4] == documentURL || checkURL[5] == documentURL) {
		if ($(this).attr('href') == window.location.pathname) {
			$(this).parent().addClass('active');
			var parentTag = $(this).parent().parent().parent().get(0).tagName;
			if(parentTag == 'LI'){
				$(this).parent().parent().parent().addClass('active');
				$(this).parent().parent().removeClass('hideComplete');
	  		} else {
		 		$('#navlist li.active ul').removeClass('hideComplete');
			}
		}
	});

	$('li.active a').each(function(){
		var currentActive = $(this).attr('href');
			$('#subtabs h2 a,#subtabs ul li a').each(function(){
				if($(this).attr('href') == currentActive) {
					$(this).addClass('active');
				}
			});						
	});

}

// Popups
// Call with rel="popup", rel="popup console", rel="popup console 830 673" etc...
function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}
 
function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	var randomnumber=Math.floor(Math.random()*9999999999)
	//alert(randomnumber);
		
	type = type.toLowerCase();
	
	if (type == "fullscreen"){
		strWidth = screen.availWidth;
		strHeight = screen.availHeight;
	}
	var tools="";
	if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin'+randomnumber, tools);
	newWindow.focus();
}

function doPopUp(e) {
	var t = "standard";
	var w = "800";
	var h = "580";
	
	attribs = this.rel.split(" ");
	if (attribs[1]!=null) {t = attribs[1];}
	if (attribs[2]!=null) {w = attribs[2];}
	if (attribs[3]!=null) {h = attribs[3];}

	popUpWin(this.href,t,w,h);
	
	if (window.event) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}
}


function findPopUps()
{
var popups = document.getElementsByTagName("a");
for (i=0;i<popups.length;i++)
	{
	if (popups[i].rel.indexOf("popup")!=-1)
		{
		popups[i].onclick = doPopUp;
		popups[i].title = popups[i].title + " [Opens in pop-up window]";
		}
	}
}

function jqueryPopups() {
	$('a').each(function(){
						 
		attribs = $(this).attr('rel').split(" ");
		if (attribs[0] == "popup") {
			
			var currentTime = new Date();
			var timeInSeconds = currentTime.getTime();

			var type = "standard";
			var strWidth = "800";
			var strHeight = "580";
			
			if (attribs[1]!=null) {type = attribs[1];}
			if (attribs[2]!=null) {strWidth = attribs[2];}
			if (attribs[3]!=null) {strHeight = attribs[3];}		
			$(this).attr('rev',$(this).attr('href'));
					
			if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
			if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
			$(this).click(function(){
				$(this).attr('href','#');
				newWindow = window.open($(this).attr('rev'), 'newWin'+timeInSeconds, tools);
				newWindow.focus();
			});
			
		}
	
	});
}

function loggedIn() {
	$('#loginbox').html($('#loggedinbox').html());
	$('#loginbox').addClass('loggedin');
	$('#newtobetting, .signupbonus, .registerbox, #headerregister').addClass('hideImportant');
}
	
function loggedOut() {
	$('#loginbox').html($('#loggedoutbox').html());
	$('#loginbox').removeClass('loggedin');
	$('#newtobetting, .signupbonus, .registerbox, #headerregister').removeClass('hideImportant');
}

function displayBadge(divID, baseURL, airURL, casinoId, imageURL) {
	var so = new SWFObject(baseURL + "/AIRInstallBadge.swf", casinoId, "200", "138", "9.0.115", "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.useExpressInstall(baseURL + '/expressinstall.swf');
	so.addVariable("airversion", "1.0");
	so.addVariable("appname", "BetUSA.com Casino");
	so.addVariable("appurl", airURL);
	so.addVariable("appid", "MyApplication");
	so.addVariable("pubid", "");
	so.addVariable("appversion", "1.0.2");
	so.addVariable("image", imageURL); 
	so.addVariable("appinstallarg", casinoId); 
	so.addVariable("applauncharg", casinoId);
	so.addVariable("helpurl", "help.html"); 
	so.addVariable("hidehelp", "false"); 
	so.addVariable("skiptransition", "false"); 
	so.addVariable("titlecolor", "#ffffff"); 
	so.addVariable("buttonlabelcolor", "#ffffff"); 
	so.addVariable("appnamecolor", "#ffffff"); 
	so.addVariable("str_err_airswf", "<u>Running locally?</u><br/><br/>The AIR proxy swf won't load properly when this demo is run from the local file system."); 
	so.write(divID);
}

var alslgin = "lgok";

function playForFree(){
	var footerURL = parent.frames[3].location.href;
	footerURL = footerURL.replace("&mode=free", "");
	footerURL = footerURL.replace("&mode=real", "");
	footerURL = footerURL.replace("&mode=", "");
	parent.frames[3].location.href = footerURL + '&mode=free';
	$('#sp_game_mode').attr('value','free');
	$('#loginform').submit();
}

$(document).ready(function() {

	// Iframe page - resizes main iframe area to match the height of the window minus the size of the header
	resizeLayers();
	$(window).resize(function(){
		resizeLayers();
	});	

	// Background switcher
	$('ul#bgchanger li a').click(function(){
										  
		$('#container').removeClass();
		$('#container').attr('class',$(this).attr('rel'));
	});
	
	$('ul#navchanger li a').click(function(){
		$('#main-nav ul').removeClass();
		$('#main-nav ul').attr('class',$(this).attr('rel'));
	});

	// Setting up the scroller, it needs to use the api functionality to get the nav to bind corretly.
	$('#flowpanes').each(function() {
		window.api = $("#flowpanes").scrollable({
			vertical:true,  
			size: 1
		}).circular().autoscroll({
			interval:10000,
			api:true
		});
	});

	// Setting up the play/pause button
	$('#button-play').click(function(){
		
		// Checks to see what class is on the button, and changes its functionalty based on it.
		if ($(this).attr('class') == "imapause") {
			//alert($(this).attr('class'));
			api.stop();
			$(this).removeClass('imapause');
			$(this).addClass('imaplay');
		} else {
			//alert($(this).attr('class'));
			api.play();
			$(this).removeClass('imaplay');
			$(this).addClass('imapause');
		}

	});
	
	// Set up the navigation for the scroller
	$('#flowtabs ul li img').click(function(){
		api.seekTo($(this).attr('class').replace("item",""));
	});
	
	// Add the class of 'button' to any input box that is a 'submit'
	$('.box input:submit').addClass('button');

	showNav();

	$('#poker-players,.poker-players').each(function(){
		$(this).html(poker_players);
	});
	$('#poker-tables,.poker-tables').each(function(){
		$(this).html(poker_poker_tables);
	});
	$('#poker-badbeat,.poker-badbeat').each(function(){
		$(this).html(poker_badbeat);
	});
	$('#horse-races,.horse-races').each(function(){
		$(this).html(racing_races);
	});	
	$('#horse-tracks,.horse-tracks').each(function(){
		$(this).html(racing_tracks);
	});		
	
	$("#flowpanes").each(function(){
		api.seekTo("1");
	});
	$('.racetrackname,.raceposttime').click(function(){
		$(this).parent().find('.racetrackweather').toggleClass('hide');
	});

	$('#live-trends').click(function(){
		$('#ajax-buttons span').unbind();
		$('#ajax-buttons span').click(function() {
			liveOddsLoader("trends",$("#liveodds-ajax"),$(this),$('#ajax-buttons span'));
		});
		liveOddsLoader("trends",$("#liveodds-ajax"),$('#ajax-buttons span.active'),$('#ajax-buttons span'));
		$('#live-trends').removeClass('active');
		$('#live-odds').removeClass('active');
		$('#live-trends').addClass('active');
	});
	
	$('#live-odds').click(function(){
		$('#ajax-buttons span').unbind();
		$('#ajax-buttons span').click(function() {
			liveOddsLoader("oddsbox",$("#liveodds-ajax"),$(this),$('#ajax-buttons span'));
		});
		liveOddsLoader("oddsbox",$("#liveodds-ajax"),$('#ajax-buttons span.active'),$('#ajax-buttons span'));
		$('#live-trends').removeClass('active');
		$('#live-odds').removeClass('active');
		$('#live-odds').addClass('active');
	});
	
	// Live Odds
	if (window.location.hash.replace('#','') != '') {
		currentSportsNumber = window.location.hash.replace('#','');
		liveOddsLoader("oddsbox",$("#liveodds-ajax"),currentSportsNumber.replace('#',''),$('#ajax-buttons span'),'hash');
	}
	else { 
		$('#ajax-buttons').each(function(){
			//liveOddsLoader("oddsbox",$("#liveodds-ajax"),$('#ajax-buttons span:first'),$('#ajax-buttons span'));
			liveOddsLoader("trends",$("#liveodds-ajax"),$('#ajax-buttons span:first'),$('#ajax-buttons span'));
		});
	}
	$('#ajax-buttons span').click(function() {
		//liveOddsLoader("oddsbox",$("#liveodds-ajax"),$(this),$('#ajax-buttons span'));
		liveOddsLoader("trends",$("#liveodds-ajax"),$(this),$('#ajax-buttons span'));
	});
	
	
	//$('#live-odds').addClass('active');
	$('#live-trends').addClass('active');
	
	//findPopUps();
	//jqueryPopups();
	
	$('#odddata').each(function(){
		$('#oddnumber').html('<span class="' + $('#oddnumber').html() + '"></span>');
		liveOddsLoader("fullodds",$("#odddata"),$('#oddnumber span'),$('#oddnumber span'));
	});

	if (isLoggedIn == true) {
		loggedIn();
	} else {
//		loggedOut();
	}

	$('#sub-nav ul li a').click(function(){
		$('#sub-nav ul li a').removeClass('selected');
		$(this).addClass('selected');
	});
	
	if ($.preloadCssImages()) { }

	
	cookieNameGrabber();
	autoDownload();
	$('#lifebookmark, a.bookmark').jFav();
	
	
	jqueryPopups();
});