
if(!window.iwin){var iwin={};}
if(!iwin.clubSubscription){iwin.clubSubscription={};}
iwin.clubSubscription.init=function(){var allAccessHTML,clubiWinHTML;if(i$('clubiWinChoice').innerHTML){showObj('ous-container');}
if(i$('allAccessChoice').innerHTML){showObj('pick-allAccess');}
i$('continueiAccess').observe('click',function(event){i$('joiningClub').innerHTML='false';i$('joiningiAccess').innerHTML='true';if(iwin.Auth.getCurrentUsername()){iwin.clubSubscription.purchaseIcoins();}
else{iwin.clubSubscription.showSignInForm();}
Event.stop(event);});i$('joinAAMain').observe('click',function(event){if($J(this).is("a[href*='#joinAllAccess']")){i$('joiningClub').innerHTML='false';i$('joiningiAccess').innerHTML='true';if(iwin.Auth.getCurrentUsername()){iwin.clubSubscription.purchaseIcoins();}
else{iwin.clubSubscription.showSignInForm();}
Event.stop(event);}});i$('continue').observe('click',function(event){i$('joiningClub').innerHTML='true';i$('joiningiAccess').innerHTML='false';if(iwin.Auth.getCurrentUsername()){iwin.clubSubscription.purchaseIcoins();}
else{iwin.clubSubscription.showSignInForm();}
Event.stop(event);});i$('joinLinkSmall').observe('click',function(event){i$('joiningClub').innerHTML='true';i$('joiningiAccess').innerHTML='false';if(iwin.Auth.getCurrentUsername()){iwin.clubSubscription.purchaseIcoins();}
else{iwin.clubSubscription.showSignInForm();}
Event.stop(event);});i$('joinLinkMain').observe('click',function(event){if($J(this).is("a[href*='#joinClubiWin']")){i$('joiningClub').innerHTML='true';i$('joiningiAccess').innerHTML='false';if(iwin.Auth.getCurrentUsername()){iwin.clubSubscription.purchaseIcoins();}
else{iwin.clubSubscription.showSignInForm();}
Event.stop(event);}});Event.observe(document,'iwin:auth:login:success',function(){if(!i$('signin-container').hasClassName('hideObj')){iwin.clubSubscription.purchaseIcoins();return;}});i$('selectiAccessLandingPage').observe('click',function(event){hideObj('ous-container');showObj('pick-allAccess');i$('joiningClub').innerHTML='false';i$('joiningiAccess').innerHTML='true';Event.stop(event);});i$('selectClubiWinLandingPage').observe('click',function(event){hideObj('pick-allAccess');showObj('ous-container');i$('joiningiAccess').innerHTML='false';i$('joiningClub').innerHTML='true';Event.stop(event);});allAccessHTML="Customers who join All Access will pay a monthly charge of $9.99 and "+"receive unlimited access to play over 900 downloadable games as long as their "+"membership is active.  Members simply download any game that they wish to play, "+"and that's it! Members must be online to activate the games that have been "+"downloaded and then can play those games offline for up to 24 hours. In "+"addition, All Access members can purchase games at low club prices at "+"anytime - most games are $6.99 or less."+"<h4>Other benefits:</h4>"+"<ul>"+"<li>At least 20 new games every month</li>"+"<li>Play all you want, ad free</li>"+"<li>Sneak Peeks on all iWin-developed games</li>"+"<li>Double Opals for playtime on purchased games</li>"+"<li>500 Opals for every game you purchase</li>"+"<li>Steals and Deals with games at up to 75% off list price</li>"+"</ul>";$$('a[id="learnMoreAllAccess"]','a[id="learnMoreClubiWin"]').each(function(element){element.writeAttribute('href','#');element.observe('click',function(event){Event.stop(event);});});if($('learnMoreAllAccess')){reqObj=new Tip('learnMoreAllAccess',allAccessHTML,{stem:'bottomLeft',hook:{target:'bottomMiddle',tip:'bottomLeft'},offset:{x:-20,y:-20},width:500});}
clubiWinHTML="Club iWin is our subscription program that allows you to get the games you love "+"at our lowest prices - with no minimum purchase or time-based commitments.  How "+"it works:  You pay a monthly charge of $6.99 and receive 1000 iCoins to use "+"toward the games you want.  Nearly all of our games are priced at 1000 iCoins "+"(or less - we still have our \"Steals & Deals\" section full of lower priced "+"games to peruse and buy).  We have some new \"Premium\" titles that may cost a "+"little more - but will be worth every iCoin you spend.  Sure, you'll be able to "+"buy as many games as you like at member prices but there's even more to "+"mention. <h4> Club iWin members will receive: </h4>"+"<ul>"+"<li>Sneak Peeks on all iWin-developed games</li>"+"<li>Double Opals for playtime on purchased games</li>"+"<li>500 Opals for every game you purchase</li>"+"<li>Steals and Deals with games at up to 75% off list price</li>"+"</ul>";if($('learnMoreClubiWin')){reqObj=new Tip('learnMoreClubiWin',clubiWinHTML,{stem:'bottomLeft',hook:{target:'bottomMiddle',tip:'bottomLeft'},offset:{x:-20,y:-20},width:500});}};iwin.clubSubscription.currentHash='';iwin.clubSubscription.showSignInForm=function(){hideObj('account-container');hideObj('pick-allAccess');hideObj('ous-container');hideObj('landing-container');i$('shopping-flow').addClassName('signIn');showObj('shopping-flow');showObj('signin-container');iwin.tracking.trackPageview('/sign-in');};iwin.clubSubscription.purchaseIcoins=function(memberPlan){if(i$('joiningClub').innerHTML=='true'){memberPlan=i$('joiningClubCname').innerHTML;}else if(i$('joiningiAccess').innerHTML=='true'){memberPlan=i$('joiningiAccessCname').innerHTML;}
json={'lineItems':[{'game':{'canonicalName':memberPlan},'quantity':1}]};iwin.clubSubscription.sendingPurchase(Object.toJSON(json));};iwin.clubSubscription.sendingPurchase=function(jsonObj){var sendingPurchase=new Ajax.Request('/commerce/orders/current',{contentType:'application/json',postBody:jsonObj,requestHeaders:{Accept:'application/json'},onSuccess:function(req){window.location.href=req.responseText.evalJSON().self;},onException:problemHandler.bind('iwin.clubSubscription.sendingPurchase'),onFailure:problemHandler.bind('iwin.clubSubscription.sendingPurchase'),on500:function(request){try{var data=JSON.parse(request.responseText);if(data&&data.self){window.location.href=data.self;}else{console.error('Error: '+request.responseText);}}catch(e2){console.error('Error: '+request.responseText);}},on503:function(request){try{var data=JSON.parse(request.responseText);if(data&&data.self){window.location.href=data.self;}else{console.error('Error: '+request.responseText);}}catch(e2){console.error('Error: '+request.responseText);}}});};iwin.clubSubscription.deleteSubscription=function(deleteSubscriptionURL){var deleteSubscription=new Ajax.Request(deleteSubscriptionURL+'?_method=DELETE',{method:'GET',requestHeaders:{Accept:'application/json'},onSuccess:function(req){window.location.href=req.responseText.evalJSON().self;},onException:problemHandler.bind('iwin.clubSubscription.deleteSubscription'),onFailure:problemHandler.bind('iwin.clubSubscription.deleteSubscription')});};Event.observe(document,'dom:loaded',iwin.clubSubscription.init);
