// mobile
var iPhone=navigator.userAgent.indexOf("iPhone")!=-1;if(iPhone){location='/mobile.php';}

// ie6
var browser=navigator.appName
var ver=navigator.appVersion
var thestart=parseFloat(ver.indexOf("MSIE"))+1
var brow_ver=parseFloat(ver.substring(thestart+4,thestart+7))
if((browser=="Microsoft Internet Explorer")&&(brow_ver<=6)){window.location="/ie6";}

// app_jquery
var myWidth=0,myHeight=0,myScroll=0;myScrollWidth=0;myScrollHeight=0;var myInterval=null;var mV=true;function getSize(){if(self.innerHeight){myWidth=window.innerWidth;myHeight=window.innerHeight;myScroll=window.pageYOffset;}else if(document.documentElement&&document.documentElement.clientHeight){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;myScroll=document.documentElement.scrollTop;}else if(document.body){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;myScroll=document.body.scrollTop;}
if(window.innerHeight&&window.scrollMaxY){myScrollWidth=document.body.scrollWidth;myScrollHeight=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){myScrollWidth=document.body.scrollWidth;myScrollHeight=document.body.scrollHeight;}else{myScrollWidth=document.body.offsetWidth;myScrollHeight=document.body.offsetHeight;}}
function findPosX(obj){var curleft=0;if(obj.offsetParent)
while(1){curleft+=obj.offsetLeft;if(!obj.offsetParent)
break;obj=obj.offsetParent;}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj){var curtop=0;if(obj.offsetParent)
while(1){curtop+=obj.offsetTop;if(!obj.offsetParent)
break;obj=obj.offsetParent;}
else if(obj.y)
curtop+=obj.y;return curtop;}
var mouseOutTimer;function setTimer(){if($('searchDropDown')!=null){mouseOutTimer=setTimeout('search()',5000);}}
function stopTimer(){clearTimeout(mouseOutTimer)}
function setSearch(val){$('typeParam').value=val;$('innItVal').innerHTML=val;search();}
function clearIt(id){if($(id).value=='Search'){$(id).value='';}$('sTab').className='right searchTab selected';}
function blurIt(id){if($(id).value==''){$(id).value='Search';}$('sTab').className='right searchTab';}
function checkSearchSubmit(){var se=$('search').value;var ty=$('typeParam').value;if((se!='')&&(se!='Search')){window.location.href='/search&s='+escape(se)+'&t='+escape(ty);}else{alert('Please make sure you enter something in the search box before pressing submit.')}
return false;}
var activeFlyout=false;function modalBox(width,title,content,cl,fbRen){if(!activeFlyout){activeFlyout=true;if(fbRen==undefined){fbRen=0;}
getSize();var str='<div id="dialogBox" class="dialog"><div class="body"><div class="d_hdr"><a href="#" id="closeButton" class="close"></a></div><div class="content"><div class="mb_tit">'+title+'</div><div class="mb_content">'+content+'</div></div></div><div class="foot"></div></div>';$("body").append(str);$('.dialog').offset({top:($(window).scrollTop()+55),left:(($(window).width()/2)-(315))});$('#closeButton').click(function(e){e.preventDefault();$('#dialogBox').remove();});}else{closeModalBox();modalBox(width,title,content,cl,fbRen);}}
function toggleMbLoading(){$('#mbSpace').toggleClass('hide');$('#mbLoading').toggleClass('hide');}
function fillWithLoader(obj,pad){var bdy='<div style="text-align: center; padding: '+pad+'px 0;"><img src="/img/loading.gif" alt="loading" width="66" height="66" /></div>';obj.html(bdy);}
function closeModalBox(){$('.dialog').remove();activeFlyout=false;}
function checkDDValue(val){var options=document.getElementById(val).options;var selIndex=document.getElementById(val).selectedIndex;return options[selIndex].value;}
function checkDDIndex(val){var options=document.getElementById(val).options;var selIndex=document.getElementById(val).selectedIndex;var checkOp=options[selIndex].value;if(checkOp==''){return false;}else{return true;}}
function number_format(a,b,c,d){a=Math.round(a*Math.pow(10,b))/Math.pow(10,b);e=a+'';f=e.split('.');if(!f[0])f[0]='0';if(!f[1])f[1]='';if(f[1].length<b){g=f[1];for(i=f[1].length+1;i<=b;i++){g+='0';}
f[1]=g;}
if(d!=''&&f[0].length>3){h=f[0];f[0]='';for(j=3;j<h.length;j+=3){i=h.slice(h.length-j,h.length-j+3);f[0]=d+i+f[0]+'';}
j=h.substr(0,(h.length%3==0)?3:(h.length%3));f[0]=j+f[0];}
c=(b<=0)?'':c;return f[0]+c+f[1];}
function addLoading(id){$('#'+id).html('<div class="loading"><img src="/img/loading.gif" width="66" height="66" border="0" /></div>');}
var displayPoolTypes=function(msg){if(msg!=''){modalBox(550,'Add a Pool/League',msg);}}
function disp_message(str,typ){var type='';var typeb='';if(typ==2){type=' suc';typeb='-suc';}else if(typ==0){type=' err';typeb='-err';}
$('#message_spot').prepend('<div class="notify inner-pad-10 rad'+type+'"><div class="left">'+str+'</p></div><div class="notify-close'+typeb+'"></div><div class="clear"></div></div>');$('.notify-close'+typeb).click(function(e){$(this).parent().remove();});}
function disp_loading(id,pad){if(pad==undefined){pad=50;}
$(id).html('<div class="loading_sm rad" style="margin-top: '+pad+'px;"><div><img src="/img/loading.gif" width="31" height="31" border="0" /></div><div class="txt">Loading</div></div>');}
$(document).ready(function(){$('.addpool').click(function(e){var bdy='Content';$.ajax({type:"POST",url:"/js/ajax/getPoolTypes.ajax.php",success:displayPoolTypes});});});

// scores
var slWi=659;var slideWidth=0;var curVal=0;var score_track_sec=30;var score_track_int;function toggleScore(val,wid){curVal=val;if(curVal==undefined){curVal=$('#curVal').val();}
slideWidth=wid;if(slideWidth==undefined){slideWidth=$('#slideWidth').val();}
if(slideWidth<=slWi){$('#lArr').hide();$('#rArr').hide();}else{$('#lArr').show();$('#rArr').show();}
var obj=$('#titler div');for(var i=0;i<obj.length;i++){if(obj[i].id.substr(0,5)!='clear'){if(obj[i].id.substr(4)==curVal){document.getElementById('scoreBg').className='scoreBg scoreBg_'+obj[i].id.substr(4);$(obj[i]).addClass('activeSB');$('#sb_'+obj[i].id.substr(4)).show();}else{$(obj[i]).removeClass('activeSB');$('#sb_'+obj[i].id.substr(4)).hide();}}}
if(val==8){$('#sponsorSpot').addClass('nbaS');$('#sponsorSpot').removeClass('ncaaS');}else{$('#sponsorSpot').removeClass('nbaS');$('#sponsorSpot').addClass('ncaaS');}
enable_score_ping();}
var curSp=0;function moveScores(ty){var windows=Math.ceil(slideWidth/660);if((ty==2)&&(curSp<(windows-1))){curSp++;}else if((ty==1)&&(curSp!=0)){curSp--;}
$("#scorePocket_"+curVal).animate({marginLeft:'-'+(660*curSp)+'px'},'slow');}
var resGetScores=function(msg){if(msg.substr(0,5)=='Error'){$.facebox('<div class="padBtm10"><div class="errorFlag"></div></div><div>'+msg+'</div>');}else{var arr=eval(msg);for(var i=0;i<arr.length;i++){var qtr_str='';var tim_lef='';if(arr[i]['status']==2){qtr_str='Final';tim_lef=' ';}else if(arr[i]['status']==1){var qtr='';if(arr[i]['num']==1){qtr='st';}else if(arr[i]['num']==2){qtr='nd';}else if(arr[i]['num']==3){qtr='rd';}else if(arr[i]['num']==4){qtr='th';}
qtr_str=arr[i]['num']+qtr+' '+arr[i]['unitsAbbr'];tim_lef=arr[i]['time_left'];}else if(arr[i]['status']==0){qtr_str=arr[i]['dateTime'];tim_lef=' ';}
$('#game_st_'+arr[i]['thisGID']+' div.tspot').html(qtr_str);$('#game_st_'+arr[i]['thisGID']+' div.tleft').html(tim_lef);$('#game_st_'+arr[i]['thisGID']+' div.aw_score').html(arr[i]['awayFinal']);$('#game_st_'+arr[i]['thisGID']+' div.ho_score').html(arr[i]['homeFinal']);}}}
function get_scores(){var sendVals='call=get-scores';$.ajax({type:"POST",url:"/classes/ScoreTracker.php",data:sendVals,success:resGetScores});}
function enable_score_ping(){score_track_int=setInterval('get_scores()',(1000*score_track_sec));}
$(document).ready(function(e){toggleScore();});

// social
function is_child_of(parent,child){if(child!=null){while(child.parentNode){if((child=child.parentNode)==parent){return true;}}}
return false;}
function fixOnMouseOut(element,event,JavaScript_code){var current_mouse_target=null;if(event.toElement){current_mouse_target=event.toElement;}else if(event.relatedTarget){current_mouse_target=event.relatedTarget;}
if(!is_child_of(element,current_mouse_target)&&element!=current_mouse_target){eval(JavaScript_code);}}
var FANTASY=false;var resFollowUser=function(t){alertMe('Follower!',t.responseText);if($('followButton')!=null){if($('followButton').innerHTML=='FOLLOW'){$('followButton').innerHTML='UNFOLLOW';}else{$('followButton').innerHTML='FOLLOW';}}}
function followUser(uid,type){var sendVals='FID='+escape(uid)+'&TYPE='+escape(type);new Ajax.Request('/classes/Following.php',{method:'post',postBody:sendVals,onComplete:resFollowUser});}
var xPosFO=0;var yPosFO=0;function activateFlyout(id,uid,alias,img,imgW,type){xPosFO=findPosX($(id));yPosFO=findPosY($(id));var bod=document.getElementsByTagName('body').item(0);var fOut=document.createElement("div");fOut.setAttribute('id','flyOutBox');fOut.className='flyOut';fOut.style.left=(xPosFO-Math.ceil((100-imgW)/2))+'px';fOut.style.top=(yPosFO-Math.ceil((100-imgW)/2))+'px';var add='';if(FANTASY){add=' <a href="javascript: fantasyBet('+uid+');"><img src="/icn/bet_fo.jpg" width="40" height="20" border="0" /></a>'}
fOut.innerHTML='<div onMouseOut="fixOnMouseOut(this, event, \'removeFlyout()\');"><div><a href="'+alias+'"><div class="imgPart" style="background: url(\''+img+'\') no-repeat;"></div></a></div><div style="padding: 2px;"><a href="javascript: followUser(\''+uid+'\','+type+');"><img src="/icn/plus_fo.gif" alt="Follow Me" title="Follow Me" width="20" height="20" border="0" /></a>'+add+'</div></div>';bod.appendChild(fOut);}
function removeFlyout(){document.getElementsByTagName('body').item(0).removeChild($('flyOutBox'));}

// profilecheck
var bEnd=0;function increaseIt(sta){$('.perc').html(sta+'%')
if(sta<bEnd){sta++;setTimeout('increaseIt('+sta+')',50);}}
function checkProfComplete(msg){$('#pools').html(msg.substr(7,msg.length));$('.skip').click(function(){var num=Number($(this).html());$(this).parent().parent().parent().parent().hide(1000,function(){$(this).remove();});var sta=Number($('.perc').html().substr(0,($('.perc').html().length-1)));bEnd=(sta+num);$.ajax({type:"POST",url:"/classes/Profile.php",data:"call=skip&id="+escape(this.id),success:function(msg){if(msg=='PROFILE_COMPLETED'){location='/manager';}else{increaseIt(sta);}}});});$('.imgBlock').click(function(){switch(this.id){case'createUser':location='/settings';break;case'billingInfo':location='/settings#billing';break;case'shippingInfo':location='/settings#shipping';break;case'verifyEmail':location='settings&verifyEmail=true';break;case'myPrivacy':case'standardInfo':location='/info-privacy';break;case'checkCredits':location='/credits';break;case'uploadAvatar':location='/avatar';break;case'addressBook':location='/addressbook';break;case'securityAnswers':location='/security-answers';break;case'socialNet':location='/social';break;}});}

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
