function reviewsViewer(){function t(t){t.preventDefault(),n||(n=!0,$.ajax({type:"GET",dataType:"html",url:$(this).attr("href"),success:i,error:function(){n=!1}}))}function i(t){var r=$(t),i;if(n=!1,r.find("li").length>0&&($reviewsList.append($("li",r)),i=$("#moreReviews",r).attr("href"),i!=null&&i.length>0)){$moreReviews.attr("href",i);return}$moreReviews.hide()}var n=!1;$reviewsList=$("#appDetails #reviews ul"),$moreReviews=$("#appDetails #reviews #moreReviews"),$moreReviews.bind("click",t)}function reviewEditor(){function s(){$header=$("#appDetails #userReviewHeader"),$header.addClass("error"),$header.text(appDetailsStrings.reviewError)}function h(n){e=i.val(),n.success&&(u.attr("disabled","disabled"),u.attr("value",n.submitText),e.length==0?f.hide():f.show()),l(n)}function c(t){r=n.val(),t.success&&($("#appDetails .ratingNotification").removeClass("notRated"),$("form#review textarea").attr("disabled",""),$("form#review textarea").is(".unrated")&&($("form#review textarea").val(""),$("form#review textarea").removeClass("unrated"))),l(t)}function l(n){$header=$("#appDetails #userReviewHeader"),$header.removeClass("error"),n.success||$header.addClass("error"),$header.text(n.text)}function a(n){t.removeClass("zeroPtZero onePtZero twoPtZero threePtZero fourPtZero fivePtZero");switch(n){case"5":t.addClass("fivePtZero");break;case"4":t.addClass("fourPtZero");break;case"3":t.addClass("threePtZero");break;case"2":t.addClass("twoPtZero");break;case"1":t.addClass("onePtZero");break;default:t.addClass("zeroPtZero")}}var t=$("form#rate div.ratingLarge"),n=$('form#rate input[name="rating"]'),u=$("form#review input.submit"),f=$("form#review input.clear"),i=$("form#review textarea"),o=$('form#review input[type="hidden"]').val(),r=n.val(),e=$("form#review textarea").val();u.attr("disabled","disabled"),e!=null&&e.length==0&&f.hide(),(r==null||r.length==0||r=="0")&&($("form#review textarea").attr("disabled","disabled"),f.hide()),u.click(function(n){n.preventDefault(),$.ajax({xhrFields:{withCredentials:!0},type:"POST",url:$("form#review").attr("action"),data:{reviewText:i.val(),rating:r,__RequestVerificationToken:o},success:h,error:s}),WpsTracking.omnitureTrack(u.parent())}),f.click(function(n){n.preventDefault(),i.val(""),$.ajax({xhrFields:{withCredentials:!0},type:"POST",url:$("form#review").attr("action"),data:{reviewText:i.val(),rating:r,__RequestVerificationToken:o},success:h,error:s})}),i.bind("keyup cut paste change",function(){e.length==0&&$.trim(i.val()).length==0?u.attr("disabled","disabled"):u.removeAttr("disabled")}),i.bind("keypress keyup paste change",function(){var t=i.val();t.length>1024&&i.val(t.substr(0,1024))}),t.mouseenter(function(){t.hasClass("active")||t.addClass("active")}),t.mouseleave(function(){t.removeClass("active"),a(r)}),t.mousemove(function(t){var r=$(t.target).offset(),i=t.pageX-r.left,u=$("html").attr("dir")=="rtl";u?i<11?n.val("5"):i<28?n.val("4"):i<45?n.val("3"):i<62?n.val("2"):n.val("1"):i<17?n.val("1"):i<34?n.val("2"):i<51?n.val("3"):i<68?n.val("4"):n.val("5"),a(n.val())}),t.click(function(){var u=t.parent().data("ov").replace("{rate}",n.val());r=n.val(),i.attr("disabled")||i.val()==""?$.ajax({crossDomain:!0,xhrFields:{withCredentials:!0},type:"POST",url:$("form#rate").attr("action"),data:{rating:n.val(),__RequestVerificationToken:o},success:c,error:s}):$.ajax({crossDomain:!0,xhrFields:{withCredentials:!0},type:"POST",url:$("form#review").attr("action"),data:{reviewText:i.val(),rating:n.val(),__RequestVerificationToken:o},success:c,error:s}),WpsTracking.omnitureTrack(t.parent())})}$(function(){var n,t;$("body.marketplace.landingPage .spotRow .collectionContainer").hoverPeek({height:-141}),$("body.marketplace.landingPage div.appContainer.xxlarge").hoverPeek({height:-292}),$("body.marketplace.landingPage div.appContainer.large").hoverPeek({height:-141}),n=[],$("body.marketplace.landingPage div.appContainer.xxlarge, body.marketplace.landingPage div.appContainer.large, body.marketplace.landingPage .spotRow .collectionContainer").each(function(){n.push($(this))}),n.length>=4&&(t=function t(){var i=Math.floor(Math.random()*5e3);setTimeout(function(){var u=Math.floor(Math.random()*(n.length-3)),i=n[u],r;n.push(n.splice(u,1)[0]),i.is(".hovered")?t():(r=0,i.is(".appContainer.xxlarge")?r=-i.find(".appInfo .appTitle").height()-32:i.is(".appContainer.large")?r=-i.find(".appInfo .appTitle").height()-16:i.is(".collectionContainer")&&(r=-i.find(".collectionInfo .collectionTitle").height()-16),i.peek({distance:r,duration:1e3,completed:function(){i.peek({distance:0,duration:1e3,delay:5e3,completed:t})}}))},i)},t(),t())});var minHeightDescription=0;$(function(){var i;$(".marketplace.appDetailsPage #screenshots a").each(function(n){var t=n;$(this).click(function(n){n.ctrlKey||n.shiftKey||(n.preventDefault(),ScreenshotViewer.show(t))})}),reviewsViewer(),reviewEditor();var r=$(".marketplace.appDetailsPage #licenseOptions .buy"),u=$(".marketplace.appDetailsPage #licenseOptions .try"),n=r.outerWidth(),t=u.outerWidth();n!=null&&t!=null&&n+t>252&&(i=n>t?n:t,r.css({width:i+"px"}),u.css({width:i+"px"})),$(".marketplace.appDetailsPage").length>0&&$("#languageList").textToggle(appDetailsStrings.showLanguagesString,appDetailsStrings.hideLanguagesString),$(".marketplace.appDetailsPage").length>0&&$("#appDescription").textToggle(appDetailsStrings.readMoreString,appDetailsStrings.readLessString),$(".marketplace.appDetailsPage .button3").mousedown(function(n){$(n.target).is(".button3")&&WpsTracking.omnitureTrack($("a",$(this)))}),$(".marketplace.appDetailsPage .button3").click(function(n){$(n.target).is(".button3")&&(window.location=$("a",$(this)).attr("href"))}),$(".marketplace.appDetailsPage .button4").mousedown(function(n){$(n.target).is(".button4")&&WpsTracking.omnitureTrack($("a",$(this)))}),$(".marketplace.appDetailsPage .button4").click(function(n){$(n.target).is(".button4")&&(window.location=$("a",$(this)).attr("href"))})}),ScreenshotViewer={isInitialized:!1,currentIndex:0,maxIndex:0,src:"",show:function(n){this.currentIndex=n,this.isInitialized?($(document).bind("keydown",this.keyHandler),$(document).bind("focusin",this.focusHandler),$(document).bind("click",this.clickHandler),this.showShot(this.currentIndex),$("#shotViewer").show(),$("#shotViewer #closeViewer").focus()):this.initialize()},hide:function(){$(document).unbind("keydown",this.keyHandler),$(document).unbind("focusin",this.focusHandler),$(document).unbind("click",this.clickHandler),$("#shotViewer .shot:eq("+this.currentIndex+")").hide(),$("#shotViewer").hide()},initialize:function(){var n=this;$.get(this.src,function(t){n.loadComplete(t)})},loadComplete:function(n){$("body").append(n);var t=this;this.isInitialized=!0,this.maxIndex=$("#shotViewer .shot").length-1,$("#shotViewer .shot").hide(),$("#shotViewer").bind("previous",function(){t.previous()}),$("#shotViewer").bind("next",function(){t.next()}),$("#shotViewer").bind("hide",function(){t.hide()}),$("#shotViewer #previousShot").click(function(n){n.preventDefault(),$("#shotViewer").trigger("previous")}),$("#shotViewer #nextShot").click(function(n){n.preventDefault(),$("#shotViewer").trigger("next")}),$("#shotViewer #closeViewer").click(function(n){n.preventDefault(),$("#shotViewer").trigger("hide")}),this.maxIndex==0&&$("#shotViewer #previousShot, #shotViewer #nextShot").css("visibility","hidden"),this.show(this.currentIndex)},keyHandler:function(n){var t=null;switch(n.which){case 27:t="hide";break;case 37:t="previous";break;case 32:case 39:t="next"}t&&(n.preventDefault(),$("#shotViewer").trigger(t))},focusHandler:function(n){$(n.target).parents("#shotViewer").length||(n.shiftKey?$("#shotViewer #nextShot").focus():$("#shotViewer #closeViewer").focus())},clickHandler:function(n){$(n.target).is(".shot > img")&&$("#shotViewer").trigger("next")},next:function(){this.showShot(this.currentIndex+1)},previous:function(){this.showShot(this.currentIndex-1)},showShot:function(n){$("#shotViewer .shot:eq("+this.currentIndex+")").hide(),n>this.maxIndex?n=0:n<0&&(n=this.maxIndex),this.currentIndex=n;var i=$("#shotViewer .shot:eq("+this.currentIndex+")"),t=$("#shotViewer > .foreground"),u=$("html").attr("dir")=="rtl",r="margin-right";u||(r="margin-left"),i.hasClass("R90")||i.hasClass("R270")?(t.css(r,-336),t.css("margin-top",-185),t.removeClass("R0"),t.addClass("R90"),$("#shotViewer #previousShot").css("margin-top",142),$("#shotViewer #nextShot").css("margin-top",142)):(t.css(r,-228),t.css("margin-top",-284),t.removeClass("R90"),t.addClass("R0"),$("#shotViewer #previousShot").css("margin-top",250),$("#shotViewer #nextShot").css("margin-top",250)),i.show(),$("#shotViewer #shotNumber").text(i.children("img").attr("alt"))}},$(function(){function u(n){return(n=n?n:window.event,n.which&&n.which>31&&(n.which<48||n.which>57))?!1:!0}var n=$("#smsSetup select#region"),t=$("#smsSetup #disclaimerCheckbox"),i=n.val(),r=$("#smsSetup #PhoneNumber").val();t.change(function(){SmsSetupSettings.DisclaimerSelectedCallback(t.is(":checked"))}),n.change(function(){$("#smsSetup #dialingCode").html("+"+$("#region option:selected").attr("data-dialingCode")),t.attr("checked",!1),t.change(),SmsSetupSettings.DisclaimerSelectedCallback(!1)}),SmsSetupSettings={DisclaimerSelectedCallback:function(){},Save:function(){i=n.val(),r=$("#smsSetup #PhoneNumber").val()},Reset:function(){n.val(i),$("#smsSetup #PhoneNumber").val(r),$("#smsSetup #serverError").html(""),$("#smsSetup .phoneNumberValidationError .field-validation-error > span").html(""),n.change()},ServerError:function(n){$("#smsSetup #userError").hide(),$("#smsSetup #serverError").html(n),$("#smsSetup #serverError").show()}},jQuery("input#PhoneNumber").bind("paste",function(){return!1}),jQuery("input#PhoneNumber").bind("keypress",function(n){return u(n)}),jQuery("input#PhoneNumber").bind("keydown",function(){$("#smsSetup #serverError").hide(),$("#smsSetup #userError").show()})}),$(function(){function t(n){n.Success==!1&&n.ErrorUrl?document.location=n.ErrorUrl:n.Success==!0&&n.InstallAppRequestId&&n.InstallAppRequestId>0?r(n.InstallAppRequestId,n.UnknownUrl,n.SuccessUrl,n.ErrorUrl,PurchaseSettings.PollingCount):document.location=n.Success==!0&&n.SuccessUrl?n.SuccessUrl:"/"+GlobalSettings.Market+"/error"}function i(n){document.location=n.status==403?document.location:"/"+GlobalSettings.Market+"/error"}function r(n,t,i,u,f){$.ajax({type:"GET",url:$(".purchase form#getInstallAppStatus").attr("action"),data:{installAppRequestId:n},success:function(e){var o=e.State;if(o=="Failed"){document.location=u;return}if(o=="Completed"){document.location=i;return}if(f==0){document.location=t;return}setTimeout(function(){r(n,t,i,u,f-1)},PurchaseSettings.PollingIntervalMilliseconds)},error:function(n){document.location=n.status==403?document.location:"/"+GlobalSettings.Market+"/error"}})}var n;if(PurchaseSettings={PollingIntervalMilliseconds:5e3,PollingCount:6},n=$(".confirmPurchase input.primaryAction"),$(".confirmPurchase #capabilities").length!=0&&($(".confirmPurchase input#acceptCapabilitiesCheckbox").change(function(){n.attr("disabled",!$(".confirmPurchase input#acceptCapabilitiesCheckbox").attr("checked"))}),n.attr("disabled",!0)),n.click(function(n){n.preventDefault();var r=$(".confirmPurchase #email input").val(),u=$('.confirmPurchase form#purchase input[type="hidden"]').val();$(".confirmPurchase .emailValidationError > .field-validation-error").length==0&&r!=""&&($(".confirmPurchase #details").css("display","none"),$(".confirmPurchase #progress").css("display","inline"),$.ajax({type:"POST",url:$(".confirmPurchase form#purchase").attr("action"),data:{"EmailValidationModel.Email":r,__RequestVerificationToken:u},success:t,error:i}))}),$(".processPurchase").length!=0){var u=$(".processPurchase #resumePurchaseUrl").val(),f=$('.processPurchase #antiForgeryToken input[type="hidden"]').val(),e=$(".processPurchase #resumePurchaseHandler").val(),o=$(".processPurchase #authorizationToken").val();$.ajax({type:"POST",url:u,data:{__RequestVerificationToken:f,authorizationToken:o,handler:e},success:t,error:i})}}),$(function(){function i(n){n.Success==!0?document.location=$(".setupDevice input[type=hidden]#nextUrl").val():SmsSetupSettings.ServerError(n.ErrorMessage)}function r(){document.location="/"+GlobalSettings.Market+"/error"}function u(){return $("#smsSetup .phoneNumberValidationError .field-validation-error").length==0&&$("#smsSetup #PhoneNumber_PhoneNumber").val()!=""}$(".purchase #smsSettingsSubmitButton").attr("disabled",!$("#disclaimerCheckbox").is(":checked")),SmsSetupSettings.DisclaimerSelectedCallback=function(n){$(".purchase #smsSettingsSubmitButton").attr("disabled",!n)};var n=$(".setupDevice input.primaryAction"),t=$('.setupDevice input[type="hidden"]').val();n.click(function(n){n.preventDefault(),u()&&$.ajax({type:"POST",url:$(".setupDevice form#smsSettings").attr("action"),data:{region:$("#smsSetup #region").val(),phoneNumber:$("#smsSetup #PhoneNumber").val(),__RequestVerificationToken:t},success:i,error:r})})})