new function(){eval(liligo.namespace);new Application({emailRE:/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/,init:function(){this.reset();this.gameOpened=false;this.defaultBox=$("defaultBox");this.gameBox=$("gameBox");this.thxBox=$("thxBox");__Eo("deafultDownload","click",bind(this.urchinTrack,this,"Download_NoGame"));__Eo("gameDownload","click",bind(this.urchinTrack,this,"Download_NoGame"));__Eo("defaultLink","click",bind(this.showPage,this,this.gameBox));__Eo("gameLink","click",bind(this.showPage,this,this.defaultBox));__Eo("recommend-form","submit",__EbS(liligo.nullFunc,liligo));Event.observe("recommend-submit","click",bind(this.submit,this));Event.observe("recommend-error","click",function(){Style.removeClass("recommend-form","error")});forEach($$("input.text",$("recommend-form")),function(A){__Eo(A,"blur",bind(this.checkError,this,A))},this);this.animPhoneBox()},showPage:function(A){Style.hide(this.defaultBox,this.gameBox,this.thxBox);Style.show(A);if(A==this.gameBox){$("recommend-mail-1").focus();if($("gameCheck")){$("gameCheck").checked=true}if(!this.gameOpened){this.urchinTrack("GameOpened")}this.gameOpened=true}else{if(A==this.defaultBox&&$("defaultCheck")){$("defaultCheck").checked=false}}},checkError:function(A){if(Style.hasClass(A,"error")){this.setError(A,false);Style.removeClass("recommend-form","error")}},submit:function(){var G={},H=[],A,E,C=false,F;for(var D=1;D<5;D++){E=$("recommend-mail-"+D);this.setError(E,false);if(A=E.value){if(!this.emailRE.test(A)){if(!F){F=E}this.setError(E,C=true);$("recommend-error").innerHTML="<span>"+labels.recommend_email_alert+"</span>"}else{H.push(A)}}}if(C){Style.addClass("recommend-form","error");F.focus();F.select();return }if(!H.length){$("recommend-error").innerHTML="<span>"+labels.recommend_email_alert_2+"</span>";this.setError("recommend-mail-1",true);Style.addClass("recommend-form","error");return }forEach(H,function(I,J){G["email_"+(J+1)]=I});E=$("recommend-name");var B=E.value;if(!B){$("recommend-error").innerHTML="<span>"+labels.recommend_name_alert+"</span>";this.setError(E,true);Style.addClass("recommend-form","error");E.focus();E.select();return }G["u_name"]=B;this.setError(E,false);E=$("recommend-your-mail");A=E.value;if(!this.emailRE.test(A)){$("recommend-error").innerHTML="<span>"+labels.recommend_email_alert_3+"</span>";this.setError(E,true);Style.addClass("recommend-form","error");E.focus();E.select();return }G["u_email"]=A;this.setError(E,false);G["terms_and_conditions"]=true;if($("recommend-nl").checked){new AjaxRequest("/widgets/gateway.jsp",{method:"post",parameters:{url:"http://liligo.cabestan.com/optin.cfm?EMAIL="+encodeURIComponent($("recommend-your-mail").value)+"&LANGUE=FR&CIV=&NOM="+encodeURIComponent($("recommend-name").value)+"&PRENOM=&DEPARTURECITY=&call_method=post"}})}Style.removeClass("recommend-form","error");new AjaxRequest("/static/iphonerecommend.jsp",{parameters:G});this.showPage(this.thxBox);this.urchinTrack("Download_WithGame");this.urchinTrack("GameEmail/"+H.length);window.open(labels.static_iphone_download_url,"liligo_ipdl")},reset:function(){$("recommend-mail-1").value=$("recommend-mail-2").value=$("recommend-mail-3").value=$("recommend-mail-4").value=$("recommend-name").value=$("recommend-your-mail").value="";this.setError("recommend-mail-1",false);this.setError("recommend-mail-2",false);this.setError("recommend-mail-3",false);this.setError("recommend-mail-4",false);this.setError("recommend-name",false);this.setError("recommend-your-mail",false);Style.removeClass("recommend-form","error")},setError:function(C,A,D){var B=$(C);if(D){B=B.parentNode}if(A===null){Style.removeClass(B,"error");Style.removeClass(B,"valid")}else{if(A&&window.iPhoneMode){Query.selectNode("div.error").style.height=document.documentElement.scrollHeight+"px";window.scrollTo(0,350)}(A?Style.addClass:Style.removeClass)(B,"error");(!A?Style.addClass:Style.removeClass)(B,"valid")}return A},animPhoneBox:function(){function E(F,J,I){var H=(J=="in")?0.015:-0.015,G;if(liligo.IE){G=F.filters.alpha.opacity/100}else{G=F.style.opacity}G=parseFloat(G)+H;if(G>0&&G<=1){setTimeout(function(){E(F,J,I)},I)}else{G=parseInt(G)-H}if(liligo.IE){G=G*100;F.style.filterzoom=1;F.style.filter="alpha(opacity="+G+")"}else{F.style.opacity=G}}var D=0,B=$$(".phonebox .phone img").length,A=false,C=function(F){if(A){return }A=true;if(!F){F=1}D+=F;if(D>=B){D=0}else{if(D<0){D=B-1}}forEach($$(".phonebox .phone img"),function(G,H){E(G,(H==D?"in":"to"),10)});setTimeout(function(){A=false},1100)};setInterval(C,1000)},urchinTrack:function(A){urchinTracker("/iPhone/ViralGame/"+(window.iPhoneMode?"Phone":"PC")+"/"+A)}})}
