﻿/*
** Unobtrusive Ajax support library for jQuery
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
(function(a){var b="unobtrusiveAjaxClick",g="unobtrusiveValidation";function c(d,b){var a=window,c=(d||"").split(".");while(a&&c.length)a=a[c.shift()];if(typeof a==="function")return a;b.push(d);return Function.constructor.apply(null,b)}function d(a){return a==="GET"||a==="POST"}function f(b,a){!d(a)&&b.setRequestHeader("X-HTTP-Method-Override",a)}function h(c,b,e){var d;if(e.indexOf("application/x-javascript")!==-1)return;d=(c.getAttribute("data-ajax-mode")||"").toUpperCase();a(c.getAttribute("data-ajax-update")).each(function(f,c){var e;switch(d){case"BEFORE":e=c.firstChild;a("<div />").html(b).contents().each(function(){c.insertBefore(this,e)});break;case"AFTER":a("<div />").html(b).contents().each(function(){c.appendChild(this)});break;default:a(c).html(b)}})}function e(b,e){var j,k,g,i;j=b.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j))return;k=a(b.getAttribute("data-ajax-loading"));i=b.getAttribute("data-ajax-loading-duration")||0;a.extend(e,{type:b.getAttribute("data-ajax-method")||undefined,url:b.getAttribute("data-ajax-url")||undefined,beforeSend:function(d){var a;f(d,g);a=c(b.getAttribute("data-ajax-begin"),["xhr"]).apply(this,arguments);a!==false&&k.show(i);return a},complete:function(){k.hide(i);c(b.getAttribute("data-ajax-complete"),["xhr","status"]).apply(this,arguments)},success:function(a,e,d){h(b,a,d.getResponseHeader("Content-Type")||"text/html");c(b.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(this,arguments)},error:c(b.getAttribute("data-ajax-failure"),["xhr","status","error"])});e.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});g=e.type.toUpperCase();if(!d(g)){e.type="POST";e.data.push({name:"X-HTTP-Method-Override",value:g})}a.ajax(e)}function i(c){var b=a(c).data(g);return!b||!b.validate||b.validate()}a("a[data-ajax=true]").live("click",function(a){a.preventDefault();e(this,{url:this.href,type:"GET",data:[]})});a("form[data-ajax=true] input[type=image]").live("click",function(c){var g=c.target.name,d=a(c.target),f=d.parents("form")[0],e=d.offset();a(f).data(b,[{name:g+".x",value:Math.round(c.pageX-e.left)},{name:g+".y",value:Math.round(c.pageY-e.top)}]);setTimeout(function(){a(f).removeData(b)},0)});a("form[data-ajax=true] :submit").live("click",function(c){var e=c.target.name,d=a(c.target).parents("form")[0];a(d).data(b,e?[{name:e,value:c.target.value}]:[]);setTimeout(function(){a(d).removeData(b)},0)});a("form[data-ajax=true]").live("submit",function(d){var c=a(this).data(b)||[];d.preventDefault();if(!i(this))return;e(this,{url:this.action,type:this.method||"GET",data:c.concat(a(this).serializeArray())})})})(jQuery);
(function(c,a,d){var e={LogLevel:{Off:0,Info:1,Warning:2,Error:4}},j=a.navigator;a.GvHelper={DebugLevel:e.LogLevel.Warning|e.LogLevel.Error|e.LogLevel.Info,FillLocalizationList:function(f,g){g=g||function(){};var b=c("#LocalizationId");if(f==-1){b.val("0").selectmenu("refresh");g()}else{b.children().remove();b.append('<option value="0">--</option>');c.post("/Mobile/Ajax/GetRegionsByCountryId",{countryId:f},function(h){if(h!=d){for(var i=0;i<h.length;i++)b.append('<option value="'+h[i].Id+'">'+h[i].ShortLabel+
" - "+h[i].Label+"</option>");b.val("-1").selectmenu("refresh")}g()})}},HandleError:function(f,g){if(typeof f==="undefined"||typeof f.error==="undefined"||!f.error)return false;if(GvHelper.DebugLevel){var b={ErrorInfo:{Navigator:j.userAgent,Screen:{Width:a.screen.width,Height:a.screen.height},Origin:a.location.href,Method:g,Result:f}};if(GvHelper.DebugLevel&e.LogLevel.Info&&a.console)c.browser.msie?console.log(JSON.stringify(b)):console.log(b)}return true}}})(jQuery,window);
window.onerror=function(c,a,d){try{d>1&&a!=""&&GvHelper.HandleError({error:{Message:c,Url:a,Line:d}},c)}catch(e){}};jQuery(document).ajaxError(function(c,a,d,e){GvHelper.HandleError({error:{data:d.data||null,status:a.status,responseText:a.responseText,exception:e||null}},d.url)});

(function(h,d,a){h.GV={Constants:{CreditType:{Gold:0,Silver:1}},Avatar:{Home:{getTemporaryAvatar:function(b){a.mobile.showPageLoadingMsg();var c=a("#avatar-preview").data("items");a("#avatar").load("/Mobile/Avatar/GetTemporaryAvatar",{itemIds:c,newItemId:b},function(){a("#update-avatar").show(0);a.mobile.hidePageLoadingMsg()})},updateAvatarItems:function(){a.mobile.showPageLoadingMsg();var b=a("#avatar-preview").data("items");a.post("/Mobile/Avatar/UpdateAvatarItems",{itemIds:b},function(){a.mobile.hidePageLoadingMsg();
d.location.reload(true)})}}},Billing:{Home:{buyCreditsSuccess:function(b){if(b.IsError)a(".validation-summary-errors").hide(200).html(b.Message).show(200);else{b={itemCost:0,resultText:b.Message,itemDescription:"",itemPreviewUrl:"",returnUrl:"",itemId:0,applicationId:0,creditType:GV.Constants.CreditType.Gold};a("#pez-result").load("/Mobile/Billing/GetNewSolde",b,function(){a(".ui-collapsible").trigger("collapse");a.mobile.silentScroll(0);a(".validation-summary-errors").hide(0);a("input[type=text]").val("")})}},
callBackFailure:function(){a(".validation-summary-errors").hide(200).show(200)}},HomeStore:{creditsRequired:0,itemCost:0,itemDescription:"",itemPreviewUrl:"",returnUrl:"",itemId:0,applicationId:0,creditType:0,equipmentSuccess:function(b){d.location.href=b},buyCreditsSuccess:function(b){if(b.IsError)a(".validation-summary-errors").hide(200).html(b.Message).show(200);else{b={itemCost:GV.Billing.HomeStore.itemCost,resultText:b.Message,itemDescription:GV.Billing.HomeStore.itemDescription,itemPreviewUrl:GV.Billing.HomeStore.itemPreviewUrl,
returnUrl:GV.Billing.HomeStore.returnUrl,itemId:GV.Billing.HomeStore.itemId,applicationId:GV.Billing.HomeStore.applicationId,creditType:GV.Billing.HomeStore.creditType};a("#pez-result").load("/Mobile/Billing/GetNewSolde",b,function(){GV.Billing.HomeStore.creditsRequired<=0&&d.location.reload(true);a.mobile.silentScroll(0);a(".validation-summary-errors").html("").hide(0);a("input[type=text]").val("")})}},callBackFailure:function(){a(".validation-summary-errors").hide(200).show(200)}},Store:{callBackSuccess:function(b){d.location.href=
b},callBackFailure:function(){a(".validation-summary-errors").hide(200).show(200)}}},Mail:{Invitation:{callBackFailure:function(){a(".validation-summary-errors").html("Une erreur est survenue pendant la demande d'ajout d'ami").show(0)},callBackSuccess:function(b,c){if(b){a("form").hide(0);a(".validation-summary-errors").html("Une demande d'ajout d'ami a \u00e9t\u00e9 envoy\u00e9s \u00e0 "+c).show(0)}else GV.Mail.Invitation.callBackFailure(b)}},MailBox:{nextMails:function(b,c){a.mobile.showPageLoadingMsg();
var e=a("#mail-list-"+c+"-"+b),f=e.find("ul").last().data("nextPage");a.get("/Mobile/Mail/NextMails",{typeId:b,received:c,pageIndex:f},function(g){e.append(g).find("ul").listview();a.mobile.hidePageLoadingMsg()})}},MailCreate:{removeSuccess:function(b){a(".comment-"+b).remove()}},MailInvitation:{callBackSuccess:function(b,c){if(b){a("#actionbutton").hide(0);alert(c+" a bien \u00e9t\u00e9 ajout\u00e9 \u00e0 votre liste d'amis !")}else GV.Mail.MailInvitation.callBackFailure(b)},callBackFailure:function(){alert("Une erreur est survenue pendant l' envoi du mini mail")},
callBackRefuseSuccess:function(b,c){if(b){a("#actionbutton").hide(0);alert("L'invitation a bien \u00e9t\u00e9 refus\u00e9 !, "+c+" ne sera pas notifi\u00e9 de ce refus !")}else GV.Mail.MailInvitation.callBackFailure(b)}},Shared:{MailConversation:{callBackSuccess:function(b){if(b){a("#mail-conversation").trigger("create");a.mobile.silentScroll(500)}}}}},OpenSocial:{Application:{resizeIFrame:function(){a("#appscontent").css("height",a.mobile.getScreenHeight()+"px")}},Home:{getParamValue:function(b){var c=
d.location.href;b=RegExp("(\\?|&|^)"+b+"=(.*?)(&|$)");c=c.match(b);return c!=null&&c[2]!=undefined?decodeURIComponent(c[2]).replace(/\+/g," "):""},installApp:function(b){if(a("#cacceptcgu").prop("checked"))d.location.href="/Mobile/OpenSocial/Application?appId="+b+"&add=1&urlParams="+encodeURIComponent(GV.OpenSocial.Home.getParamValue("urlParams"))+"&fromId="+GV.OpenSocial.Home.getParamValue("fromId")+"&from="+GV.OpenSocial.Home.getParamValue("from");else alert("Vous devez accepter les conditions d'utilisation du service.")}}},
Shared:{AvatarItems:{checkAvatarItemDirection:function(b,c,e,f,g){if(c)GV.Avatar.Home.getTemporaryAvatar(b);else d.location.href="/Mobile/Billing/BillingOsItem?applicationId=105&itemCost="+e+"&itemDescription="+f+"&returnUrl=/Mobile/Avatar/Home&itemId="+b+"&creditType="+g}},FriendsButton:{callBackSuccess:function(b){if(b){a("#addfriendlink").show(0);a("#removefriendlink").hide(0);a(".validation-summary-errors").html(b+" a bien \u00e9t\u00e9 supprim\u00e9 de votre liste d'amis !")}else GV.Shared.FriendsButton.callBackFailure()},
callBackFailure:function(b){a("#addfriendlink").hide(0);a("#removefriendlink").show(0);a(".validation-summary-errors").html("Une erreur est survenue pendant la suppression de "+b+" de votre liste d'amis !")}},UserList:{callBackSuccess:function(){a.mobile.silentScroll(200);a("#users-listview").listview();a("input[type=submit]").button();a.mobile.hidePageLoadingMsg()},callBackFailure:function(b){alert(b)}}},User:{Home:{pageIndex:1,getActivityList:function(b){a.mobile.showPageLoadingMsg();GV.User.Home.pageIndex++;
a.get("/Mobile/User/GetActivityList",{userId:b,pageIndex:GV.User.Home.pageIndex},function(c){a("#activity-list").append(c).find("ul").listview();a.mobile.hidePageLoadingMsg()})}},ProfileView:{pageIndex:1,getActivityList:function(b){a.mobile.showPageLoadingMsg();GV.User.ProfileView.pageIndex++;a.get("/Mobile/User/GetActivityList",{userId:b,pageIndex:GV.User.ProfileView.pageIndex},function(c){a("#activity-list").append(c).find("ul").listview();a.mobile.hidePageLoadingMsg()})}},Register:{countryChanged:function(){var b=
a("#ZipCode");b.val("");a("#CountryId option:selected").val()=="1"?b.prop("disabled",false):b.prop("disabled",true)},localizationChanged:function(){var b=a("#ZipCode");if(a("#CountryId option:selected").val()=="1"){var c=a("#LocalizationId option:selected").text();c=c.substring(0,2);if(c=="2A"||c=="2B")c="20";if(c=="--")c="";if(c!=""){b.val(c+"000");a("#PhoneNumber").focus()}else b.val("")}else b.val("").prop("disabled",true)}},UpdateMood:{callBackSuccess:function(b){a.mobile.changePage("/Mobile/User/Profile?UserId="+
b,{reloadPage:true})},callBackFailure:function(){a("#callbackresult").val("Une erreur est survenue pendant la demande d'ajout d'ami.");a("#callbackresult").show(0)}}}};a(".menu-plus a").click(function(){a(".menu-plus").hide(0)});a("div[data-role=page], div[data-role=dialog]").live("pageshow",function(){a(".menu-plus").hide(0)})})(window,document,jQuery,undefined);


