var p4WindowObject;function InviteFriend(AppID){var opponentEmail="";if(window.external.Users!=null)opponentEmail=parent.MessengerGamesScripts.P4Adapter.external.Users.Item(1).Email.toLowerCase();else{var uniqueId=GetQueryString("uniqueid");if(uniqueId!="")opponentEmail=decode64(GetCookie("username"+uniqueId,"/"));if(opponentEmail==""||opponentEmail==null)opponentEmail=GetQueryString("username")}LaunchApp(AppID,opponentEmail);return false}function LaunchApp(AppID,emailID){CheckMessenger();if(p4WindowObject!=null)p4WindowObject.LaunchApp(AppID,emailID)}function CheckMessenger(){try{p4WindowObject=new ActiveXObject("MSNMessenger.P4QuickLaunch")}catch(exception){p4WindowObject=null}if(p4WindowObject==null)alert(messengerNotInstalledMessage)}function GetQueryString(qsKey){var separators=new RegExp("[?&]"),args=location.search.split(separators),value="";for(var i=0;i<args.length;i++)if(args[i].match(qsKey)!=null){var idx=args[i].indexOf("=");if(idx!=-1){value=args[i].substring(idx+1);break}}return value}var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function decode64(input){if(input==null)return null;var output="",chr1,chr2,chr3="",enc1,enc2,enc3,enc4="",i=0,base64test=/[^A-Za-z0-9\+\/\=]/g;if(base64test.exec(input))alert("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, ?, ?, and ?\nExpect errors in decoding.");input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64)output=output+String.fromCharCode(chr2);if(enc4!=64)output=output+String.fromCharCode(chr3);chr1=chr2=chr3="";enc1=enc2=enc3=enc4=""}while(i<input.length);return output}