var knLargeChange=50;var knLargeLeaderboardMinWidth=728+10+4;var knLargeLeaderboardHeight=90+7;var knSmallLeaderboardHeight=60+7;var kstrLargeLeaderboard='/ad_leader.html';var kstrSmallLeaderboard='/ad_banner.html';var aAds=[{width:729+10+4,height:90+7,url:'/ad_leader',vertical:false},{width:468+10+4,height:60+7,url:'/ad_banner',vertical:false}];var _obCurrentAd=null;var _anPrevSize=[0,0];var _fShowAds=true;var _fFullScreen=false;var _strAdLocale="en_US";var g_GAMAttrs="";var g_BTAttrs="";var knMinShowWidth=320;var knMinShowHeight=240;function findAd(aSize){for(var i=0;i<aAds.length;i++){var oAd=null;if(aAds[i].vertical&&aSize[0]-knMinShowWidth>=aAds[i].width&&aSize[1]>=aAds[i].height){oAd=aAds[i];}else if(!aAds[i].vertical&&aSize[0]>=aAds[i].width&&aSize[1]-knMinShowHeight>=aAds[i].height){oAd=aAds[i];}
if(oAd&&'minAspect'in oAd&&aSize[1]!=0&&(aSize[0]/aSize[1]<oAd.minAspect)){oAd=null;}
if(oAd)return oAd;}
return null;}
function setFrameSource(ifrmIn,strUrl){var strHash="";if(g_GAMAttrs){if(strHash.length>0){strHash+=".";}
for(var key in g_GAMAttrs){strHash+=key+"="+g_GAMAttrs[key]}}
try{var doc=(ifrmIn.contentWindow||ifrmIn.contentDocument);if(doc&&doc.document)doc=doc.document;if(doc){doc.location.replace(strUrl);return;}}catch(e){}
ifrmIn.src=strUrl;}
function buildAdUrl(strUrl,strPos){return strRoot+"app/"+g_strLocale+strUrl+"?pos="+strPos+"&rel="+g_strRelease;}
function setSocialNetworkUrl(strUrl){if(g_GAMAttrs&&('src'in g_GAMAttrs)){if(g_GAMAttrs['src']=='facebook'){strUrl+='_fb'}else if(g_GAMAttrs['src']=='myspace'){strUrl+='_ms';}}
return strUrl+'.html';}
function SetAdState(aSize){var fRefreshAd=false;var obAd=null;if(_fShowAds){if(largeChange(_anPrevSize,aSize)){_anPrevSize=aSize;fRefreshAd=true;}
obAd=findAd(aSize);}else{obAd=null;}
var rectTarget={top:0,left:0,width:aSize[0],height:aSize[1]};var ifrmAd=$("#ifrmAd");var divGreenBar=$("#GreenBar");var strAdPos="t"
if(_fShowAds){divGreenBar.css("display","block");rectTarget.height-=divGreenBar.height();if(rectTarget.width<700){$("#GreenBarShare").css("display","none");}else{$("#GreenBarShare").css("display","block");}
if(rectTarget.width<300){$("#GreenBarButton").css("display","none");}else{$("#GreenBarButton").css("display","block");}}else{divGreenBar.css("display","none");}
if(ifrmAd){if(obAd){if(obAd.vertical){strAdPos="r";}else{strAdPos="b";}
if(strAdPos=="t"){rectTarget.top+=obAd.height;rectTarget.height-=obAd.height;ifrmAd.css("top",0);ifrmAd.css("left",0);}else if(strAdPos=="l"){rectTarget.left+=obAd.width;rectTarget.width-=obAd.width;ifrmAd.css("top",0);ifrmAd.css("left",0);}else if(strAdPos=="r"){rectTarget.width-=obAd.width;ifrmAd.css("top",0);ifrmAd.css("left",rectTarget.width);}else if(strAdPos=="b"){rectTarget.height-=obAd.height;ifrmAd.css("top",rectTarget.height+divGreenBar.height());ifrmAd.css("left",0);}
if(obAd.vertical){ifrmAd.width(obAd.width);ifrmAd.height(rectTarget.height);}else{ifrmAd.width(rectTarget.width);ifrmAd.height(obAd.height);}
var strT=ifrmAd.css("display");ifrmAd.css("display","none");ifrmAd.css("display",strT);if(obAd!=_obCurrentAd||fRefreshAd){var strUrl=buildAdUrl(setSocialNetworkUrl(obAd.url),strAdPos);setFrameSource(ifrmAd.get(0),strUrl);}}else{ifrmAd.css("display","none");}}
_obCurrentAd=obAd;return rectTarget;}
function getViewportSize(){var size=[0,0];if(typeof window.innerWidth!='undefined'){size=[window.innerWidth,window.innerHeight];}else if(typeof document.documentElement!='undefined'&&typeof document.documentElement.clientWidth!='undefined'&&document.documentElement.clientWidth!=0){size=[document.documentElement.clientWidth,document.documentElement.clientHeight];}else{size=[document.getElementsByTagName('body')[0].clientWidth,document.getElementsByTagName('body')[0].clientHeight];}
return size;}
function largeChange(anSize1,anSize2){var nChange=Math.max(Math.abs(anSize1[0]-anSize2[0]),Math.abs(anSize1[1]-anSize2[1]));return(nChange>=knLargeChange);}
var _fReadyCalled=false;function onReady(){if(!_fReadyCalled){_fReadyCalled=true;onResize();}}
function SetShowAds(fAds){_fShowAds=fAds;if(_fReadyCalled){onResize();}}
function onResize(){if(_fFullScreen)return true;var size=getViewportSize();var rectTarget=SetAdState(size);if(rectTarget!=null)
updateFrames(rectTarget);var ifrmAd=$("#ifrmAd");if(_fShowAds&&ifrmAd&&ifrmAd.contentWindow&&ifrmAd.contentWindow.onResize){ifrmAd.contentWindow.onResize();}
return true;}
function updateFrames(rectTarget){var oFlash=$("#show_holder");if(oFlash){oFlash.css("top",rectTarget.top);oFlash.css("left",rectTarget.left);oFlash.css("height",rectTarget.height);oFlash.css("width",rectTarget.width);}
var oPicnik=$("#picnik");if(oPicnik){oPicnik.css("height",rectTarget.height);oPicnik.css("width",rectTarget.width);}
var oSimple=$("#show_simple");if(oSimple){oSimple.css("height",rectTarget.height);oSimple.css("width",rectTarget.width);}}
$(document).ready(onReady);$(window).bind("load",onReady);$(window).bind("resize",onResize);