var status=0;var forceStatus;Qik.Account=function(){var G=null;var K=0;var M=null;var N;var H=(IS_FF)?(false):(0.55);var B={status1:{partial:"/account/modal/step1",modalOptions:{ajax:true,width:540,height:300,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status2:{partial:"/account/modal/step2",modalOptions:{ajax:true,width:540,height:300,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status3:{partial:"/account/modal/step3",modalOptions:{ajax:true,width:540,height:300,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status4:{partial:"/account/modal/step4",modalOptions:{ajax:true,width:560,height:550,opacity:H,afterFinish:F,overlayCloseOnClick:false,startingScale:1.9}},status5:{partial:"/account/modal/download_client_step",modalOptions:{ajax:true,width:540,height:350,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status6:{partial:"/account/modal/email_confirm_step",modalOptions:{ajax:true,width:540,height:300,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status7:{partial:"/account/modal/sent_sms_step",modalOptions:{ajax:true,width:540,height:300,opacity:H,afterFinish:F,overlayCloseOnClick:false}},status102:{partial:'<h1 class="error">Smash! You found a bug! Send us an email and let us know!</h1>',modalOptions:{ajax:false,width:540,height:300}},status101:{partial:'<h1 class="error">An unexpected server error occurred! Please contact Qik at info@qik.com.</h1>',modalOptions:{ajax:false,width:540,height:300}}};var I=B["status"+status];function C(){hidden_inputs=$$("div.batch_edit_ribbon form input.selected_videos");selected_videos=$$("ul.video_list li.video.selected");selectedVideoIds="";selected_videos.each(function(P){selectedVideoIds+=P.id.replace(/video/,"")+","});hidden_inputs.each(function(P){P.value=selectedVideoIds})}function A(){I=B["status"+status]}function D(){A();M=new Modalog(I.partial,I.modalOptions)}function F(){if($("btnTryAgain")){$("btnTryAgain").onclick=function(){if(confirm("Are you really really really sure you want delete this account? All your videos will be lost.")){new Ajax.Request("/account/delete",{method:"get",onSuccess:function(){previousStatus=0;status=0;M.destroy()}})}return false}}if($("btnTakeMeToMyProfile")){$("btnTakeMeToMyProfile").onclick=function(){return false}}if($("btnCancel")){$("btnCancel").onclick=function(){previousStatus=0;status=0;M.destroy();return false}}}function E(){if(status!=0){new Ajax.Request("/account/step_number",{method:"get",onSuccess:function(P){status=forceStatus?forceStatus:parseInt(P.responseText);if(M==null){D()}A();if(previousStatus!=status&&M.modal.hasClassName("open")){M.update(I.partial,I.modalOptions);previousStatus=status}}})}}function J(P){if(!P){P="frmSignUp"}P=$(P);A();new Ajax.Request("/account/sign_up",{method:"post",parameters:P.serialize(true),onSuccess:function(Q){status=parseInt(Q.responseText);if(isNaN(status)==1){window.location=Q.responseText}else{status=forceStatus?forceStatus:status;previousStatus=forceStatus?forceStatus:status;if(typeof(urchinTracker)=="function"){_uacct="UA-5728471-3";urchinTracker("/0496824334/goal")}D()}},onFailure:function(){status=102;D()}});if($("txtPhoneNumber")){$("txtPhoneNumber").blur()}}function O(P){$(P).length=0}function L(){if($("optPhoneBrand")){Event.observe($("optPhoneBrand"),"change",function(){if($F("optPhoneBrand")!=0){$("optPhoneModel").up("form").disable();new Ajax.Request("/api/device_brands/"+$F("optPhoneBrand")+"/device_models.json",{method:"get",onComplete:function(Q){O($("optPhoneModel"));for(var P=0;P<Q.responseJSON.length;P++){$("optPhoneModel").options[P]=new Option(Q.responseJSON[P].name+(Q.responseJSON[P].alt_name?" ("+Q.responseJSON[P].alt_name+")":""),Q.responseJSON[P].device_platform_id,P==0,P==0)}$("optPhoneModel").up("form").enable();if($("otherBrand")){$("optPhoneModel").options[Q.responseJSON.length]=new Option($t("other"),0,false,false);$("selectPhone").show();$("otherBrand").hide();$("otherModel").hide()}}})}else{if($("otherBrand")){if($("optPhoneBrand").options[$("optPhoneBrand").selectedIndex].text==$t("other")){$("optPhoneModel").selectedIndex=$("optPhoneModel").options.length-1;$("selectPhone").hide();$("otherBrand").show();$("otherModel").show()}else{if($("optPhoneBrand").options[$("optPhoneBrand").selectedIndex].text==$t("select_your_brand")){$("optPhoneModel").selectedIndex=$("optPhoneModel").options.length-1;$("selectPhone").hide();$("otherBrand").hide();$("otherModel").hide()}}}else{O($("optPhoneModel"));$("optPhoneModel").options[0]=new Option($t("select_model"),0,true,true)}}});if($("otherBrand")){Event.observe($("optPhoneModel"),"change",function(){if($F("optPhoneModel")==0){$("otherBrand").hide();$("otherModel").show()}else{$("otherModel").hide()}})}}}return{signUpPage:function(){Qik.initializePhoneNumberInput();if($("fbConnectBox")){$("fbConnectBox").style.height=$("signUpBox").getHeight()-28+"px"}if($("txtEmail")){$("txtEmail").focus()}if($("frmSignUp")||$("frmSignupSMS")||$("frmSignupPC")||$("frmSignupWeb")){N=new PeriodicalExecuter(function(P){E()},3)}if($("frmSignUp")){$("frmSignUp").onsubmit=function(){J();return false}}if($("frmSignupSMS")){$("frmSignupSMS").onsubmit=function(){J("frmSignupSMS");return false}}if($("frmSignupPC")){$("frmSignupPC").onsubmit=function(){forceStatus=5;J("frmSignupPC");return false}}if($("frmSignupWeb")){$("frmSignupWeb").onsubmit=function(){forceStatus=6;J("frmSignupWeb");return false}}L()},editBasicPage:function(){if($("changeProfileImage")){$("changeProfileImage").onclick=function(){$("changeProfileImage").up("p").hide();$("changeProfileImageBox").show();Qik.currentlyEditingField($("changeProfileImage").up("li"))}}var Q=new Control.Slider($("locationSliderHandle"),$("locationSliderTrack"),{range:$R(0,2),values:[0,1,2],onSlide:function(T){var S=T==0?"off":(T==1?"city":"street");$("user_location_setting").value=S;$$("div#locationDescription div").each(function(U){if(U.id=="location"+S+"Description"){U.show()}else{U.hide()}})}});var P=$("user_location_setting").value;var R=(P=="street"?2:(P=="city"?1:0));Q.setValue(R)},editNetworksPage:function(){var P=window.location.href.toQueryParams();if(P.saveInfiniteSessionKey=="true"){$("facebookNotice").innerHTML=$t("communicating_with_facebook");Qik.Account.saveInfiniteSessionKey(P.permissionSaved);return}var Q=window.location.hash.substring(1);$$("#profileEdit ul li.netElement a.netOpenClose").each(function(R){Event.observe(R,"click",function(){Effect.toggle(R.next(),"slide",{duration:0.5,afterFinish:function(){if(R.innerHTML.indexOf("Edit")!=-1){R.innerHTML="&#171; "+$t("close")}else{R.innerHTML="&#171; "+$t("edit_this_account")}}})})});$$("div.small_column p.edit a").each(function(R){R.onclick=function(){R.up().hide();R.up().previous().hide();R.up("li").addClassName("editing")}});if($("offlineAccessOverlayBackground")){$("offlineAccessOverlayBackground").setOpacity(0.8)}$$("ul#editNetworksNav li").each(function(S){var R=S.down(".largeIcon");R.absolutize();var T=R.positionedOffset();R.setStyle({left:T.left+"px",top:T.top+"px"});Event.observe(S,"click",function(U){Qik.Account.showNetworkBox(U,S)})});if(Q&&$(Q+"Tab")){$("editNetworksIntro").hide();$(Q+"Tab").addClassName("active");Qik.Account.showNetworkBox(null,$(Q+"Tab"))}},hideNetworkBoxes:function(S,Q){if(S){Event.stop(S)}$("editNetworksBodyLoading").className="";var R=[];if(Q){var P=Q.down(".largeIcon");Event.stopObserving(Q,"click");P.style.zIndex=100;R.push(new Effect.Morph(P,{style:"left:846px;top:57px;",sync:true}));Event.observe(Q,"click",function(T){if($("editNetworksNav").className=="blocked"){return false}else{Qik.Account.hideNetworkBoxes(T)}})}$("editNetworksIntro").hide();$$("ul#editNetworksNav li").each(function(T){if(T!=Q){Event.stopObserving(T,"click");var U=T.positionedOffset();R.push(new Effect.Morph(T.down(".largeIcon"),{style:"left:"+U.left+"px;top:"+U.top+"px;",sync:true,afterFinish:function(){T.removeClassName("active");T.down(".largeIcon").style.zIndex=1;Event.observe(T,"click",function(V){Qik.Account.showNetworkBox(V,T)})}}))}});R.push(new Effect.Fade($("editNetworksBodyInner"),{sync:true}));new Effect.Parallel(R,{duration:0.5,queue:{position:"end",scope:"networks"},afterFinish:function(){if(Q){Q.addClassName("active");$("editNetworksBodyLoading").down("div").innerHTML="Loading...";$("editNetworksBodyLoading").show()}else{$("editNetworksIntro").appear({duration:0.5,queue:{position:"end",scope:"networks"}})}}});return false},showNetworkBox:function(Q,P){$("editNetworksNav").addClassName("blocked");Qik.Account.hideNetworkBoxes(Q,P);new Ajax.Updater("editNetworksBodyInner","/api/"+P.readAttribute("rel")+"_accounts/"+Qik.getCookieValue("safelink")+"/edit",{method:"get",onComplete:function(){$$("#editNetworksBodyInner form").each(function(R){Event.observe(R,"submit",function(){Qik.Account.showSavingSpinner();return true})});window.location.hash=P.readAttribute("rel").gsub("api/","");$("editNetworksBodyLoading").hide();new Effect.Appear("editNetworksBodyInner",{duration:0.5,queue:{position:"end",scope:"networks"},afterFinish:function(){if($("firstfocus")){$("firstfocus").activate()}$("editNetworksBodyLoading").hide();FB.ensureInit(function(){FB.XFBML.Host.parseDomTree()});$("editNetworksNav").removeClassName("blocked")}})}});return false},facebookInvite:function(){FB.ensureInit(function(){var P=new FB.UI.FBMLPopupDialog("Invite your friends to join Qik","");var Q='<fb:fbml><fb:request-form action="'+document.location.href+'" invite="true" type="Qik" content="Come join me on Qik! <fb:req-choice url=\'http://www.qik.com/join?campaign=fb\' label=\'Join Qik\' />"><fb:multi-friend-selector showborder="false" exclude_ids="" actiontext="Invite your friends to join Qik!" rows="4" cols="5" max="35" bypass="cancel" showborder="false" /></fb:request-form></fb:fbml>';P.setFBMLContent(Q);P.setContentWidth(760);P.setContentHeight(540);P.show()})},showSavingSpinner:function(){new Effect.Fade($("editNetworksBodyInner"),{to:0.2,duration:0.25});$("editNetworksBodyLoading").down("div").innerHTML="Saving...";$("editNetworksBodyLoading").show()},hideSavingSpinner:function(){new Effect.Appear($("editNetworksBodyInner"),{to:1,duration:0.25});$("editNetworksBodyLoading").hide();$("editNetworksBodyLoading").className=""},showCheck:function(R,P,S,Q){if($("editNetworksBodyLoading")){$("editNetworksBodyLoading").down("div").innerHTML=S;$("editNetworksBodyLoading").addClassName(P);$(R+"Tab").down("span").className=P;if(Q){setTimeout("Qik.Account.showNetworkBox(null, $$('ul#editNetworksNav li.active')[0]);",2000)}else{setTimeout("Qik.Account.hideSavingSpinner()",2000)}}},changeTwitterPreview:function(){$("twitter_text").innerHTML=$F("twitter_account_default_message").escapeHTML().gsub(/(#\w+)/,'<a href="#">#{1}</a>');if($("twitter_account_include_qik_link").checked==true){$("twitter_link").show()}else{$("twitter_link").hide()}},afterGrant:function(R,P,Q){if(P=="offline_access"){Qik.Account.saveInfiniteSessionKey(R);return}else{Qik.Account.updatePromptPermission(R)}if(R=="emailMe"){new Ajax.Request("/api/facebook_accounts/send_password_email",{onSuccess:function(){$("emailMe").down(".permissionsNote").appear({duration:0.5})}})}if($(R+"Box")){$(R+"Box").disable().checked=true}if(Q&&$(Q)){$(Q).checked=true}R=$(R);if($("permissionsNote")&&!$("permissionsNote").visible()){$("permissionsNote").appear({duration:0.5})}if(R.down(".preferences")){R.down(".preferences").appear({duration:0.5})}},updatePromptPermission:function(P){if(P=="postLink"){if(!$("postLinkBox").checked){$("postLinkLink").innerHTML='<a href="#" onclick="Qik.Account.afterGrant(\'postLink\');"><input type="checkbox" class="checkbox" id="postLinkBox" name="postLinkBox" /></a>';$("postLinkAutomatically").down("span").innerHTML='<input type="hidden" name="facebook_account[post_link]" value="0" /><input type="checkbox" id="facebook_account_post_link" name="facebook_account[post_link]" checked="true" value="1"/>'}}},editInvitationsPage:function(){Event.observe($("checkall"),"change",function(){Qik.checkAllBoxes("checkall","tweetinvite")}),$$("#profileEdit ul li.netElement a.netOpenClose").each(function(P){Event.observe(P,"click",function(){Effect.toggle(P.next(),"slide",{duration:0.5,afterFinish:function(){if(P.innerHTML.indexOf("Edit")!=-1){P.innerHTML="&#171; Close "}else{P.innerHTML="&#171; Invite Friends to Qik "}}})})})},selectDevicePage:function(){L()},organizePage:function(){Qik.Organize.initOrganize()},downloadQikPage:function(){N=new PeriodicalExecuter(function(P){E()},3);$("frmDownload").onsubmit=function(){if($F("isCurrentUser")=="true"){forceStatus=7}A();new Ajax.Request("/account/download_qik",{method:"post",parameters:$("frmDownload").serialize(true),onComplete:function(P){status=parseInt(P.responseText);if(isNaN(status)==1){window.location=P.responseText}else{status=forceStatus?forceStatus:status;previousStatus=forceStatus?forceStatus:status;D()}},onFailure:function(){status=102;D()}});return false};Qik.initializePhoneNumberInput();L()},loginPage:function(){$("txtUsername").focus();$$("form#frmLogin input.textbox").each(function(P){Event.observe(P,"keydown",function(){if(!$("submitButton").visible()){$("submitButton").appear({duration:0.5})}})})},openDescriptionPopup:function(){$("popupBackground").appear({duration:0.3,to:0.85,afterFinish:function(){$("popup").show()}})},closeDescriptionPopup:function(){$("popupBackground").hide();$("popup").hide()}}}();