function BeginChallenge(gameId,friendId){var response;$.ajax({type:"GET",url:"/GameChallenge.ashx",data:{command:"challenge",userId:friendId,gameId:gameId,dt:Math.random()},success:function(data,status){response=data;OpenGameWindow("/Pages/Games/GamePlay.aspx?game="+data.gameName+"&mode=mp&crid="+data.crid)},error:function(){response=null},dataType:"json",cache:false,async:false});return response}function AcceptChallenge(crid){var response;$.ajax({type:"GET",url:"/GameChallenge.ashx",data:{command:"acceptChallenge",crid:crid,dt:Math.random()},success:function(data,status){response=data;if(data.crid>0){OpenGameWindow("/Pages/Games/GamePlay.aspx?game="+data.gameName+"&mode=mp&crid="+data.crid)}},error:function(){response=null},dataType:"json",cache:false,async:false});return response}function DeclineChallenge(crid){$.ajax({type:"POST",url:"/GameChallenge.ashx",data:{command:"declineChallenge",crid:crid,dt:Math.random()},cache:false,async:false})}function GetMultiplayerGames(){var response;$.ajax({type:"GET",url:"/GameChallenge.ashx",data:{command:"getMPGames"},success:function(data,status){response=data},error:function(){response=null},dataType:"json",cache:false,async:false});return response}function ChallengeNow(source,defender,left){$.ajax({type:"GET",url:"/GameChallenge.ashx",data:{command:"isUserAvailable",userId:defender},success:function(data,status){if(data&&data.available){var popup=$("div[id$='ChallengeNowSelectGamePopup']");if(popup&&source){$("input[id$='DefenderUserId']").attr("value",defender);var position=$(source).offset();if(position){var popupHeight=popup.height();var top=position.top-(popupHeight/2);var scrollTop=$(window).scrollTop();if(top<(scrollTop+10)){top=scrollTop+10}var clientBottom=$(window).height()+scrollTop-$("div[id$='statusBar']").height()-popupHeight-45;if(top>clientBottom){top=clientBottom}popup.css("top",top);if(left){popup.css("left",position.left-popup.width())}else{popup.css("left",position.left+$(source).width())}}$("[id$='CloseImage']",popup).css("cursor","pointer");$("[id$='CloseImage']",popup).click(function(){popup.hide()});popup.show()}}else{OpenDialogWindow("StaleStatus")}},dataType:"json",cache:false,async:true})};