var MAIN_HOST="http://ms.mindjolt.com";var VE_PUBLISHER="mindjolt";var VE_SITE="myspace";var VE_AREA="myspace_mindjolt";var MS_HOST=MAIN_HOST+"/ms";var viewer=null;var showloadingtimer=null;function showPageLoadingTimer(){if(showloadingtimer){window.clearTimeout(showloadingtimer);showloadingtimer=null;}document.getElementById("loading").style.display="none";showloadingtimer=window.setTimeout(showPageLoading,1000);}function showPageLoading(){document.getElementById("content").style.display="none";document.getElementById("content").innerHTML="";document.getElementById("loading").style.display="block";}function showPageContent(){if(showloadingtimer){window.clearTimeout(showloadingtimer);showloadingtimer=null;}document.getElementById("loading").style.display="none";document.getElementById("content").style.display="inline";gadgets.window.adjustHeight(getHeight());}function ctrAdd(C){if(!C.getElementsByTagName){return false;}var A=C.getElementsByTagName("a");for(var B=0;B<A.length;B++){if(A[B].getAttribute("id")){Event.observe(A[B],"mousedown",ctrRecord,false);}}}function ctrRecord(C){if(!C){var C=window.event;}var B=Event.element(C);var E;if(B.tagName=="IMG"){if(B.parentNode.tagName=="A"){E=B.parentNode.getAttribute("id");}}else{E=B.getAttribute("id");}var A=null;var D=document.getElementById("request_uri");if(D){A=D.value;}(new Image()).src=MAIN_HOST+"/servlet/CTR?link="+E+"&page="+A;return false;}function navigateTo(B){var A=gadgets.views.getCurrentView();if(A.getName()==gadgets.views.ViewType.CANVAS){displayPage(B,{});}else{var C={};C["page"]=B;gadgets.views.requestNavigateTo(new gadgets.views.View(gadgets.views.ViewType.CANVAS),C);}}function displayChallengeTakeover(A){removeChallengeTakeover();document.getElementById("white_overlay").style.display="block";var B=opensocial.newDataRequest();addFetchViewerFriendsRequest(B,"viewerFriends");B.send(function(G){var C=document.getElementById("challengeForm");var F={};var E=false;for(var D=0;D<C.elements.length;++D){if(C.elements[D].type=="checkbox"){if(C.elements[D].checked){F[C.elements[D].name]=C.elements[D].value;E=true;}}}if(E){document.getElementById("challenge_instructions_background").style.display="block";document.getElementById("challenge_instructions_padding").style.display="block";if(A){document.getElementById("challenge_instructions_bulletin_content").style.display="block";}else{document.getElementById("challenge_instructions_content").style.display="block";}}else{document.getElementById("challenge_none_background").style.display="block";document.getElementById("challenge_none_padding").style.display="block";document.getElementById("challenge_none_content").style.display="block";}});}function removeChallengeTakeover(){document.getElementById("white_overlay").style.display="none";document.getElementById("challenge_instructions_background").style.display="none";document.getElementById("challenge_instructions_padding").style.display="none";document.getElementById("challenge_instructions_bulletin_content").style.display="none";document.getElementById("challenge_instructions_content").style.display="none";document.getElementById("challenge_instructions_continue").style.display="none";document.getElementById("challenge_none_background").style.display="none";document.getElementById("challenge_none_padding").style.display="none";document.getElementById("challenge_none_content").style.display="none";}function submitRequestAndBulletinChallenge(B,I,G,D){var E=document.getElementById("challengeForm");var C=[];var A={};for(var F=0;F<E.elements.length;++F){if(E.elements[F].type=="checkbox"){if(E.elements[F].checked){A[E.elements[F].name]=E.elements[F].value;C.push(E.elements[F].value);}}}removeChallengeTakeover();if(!viewer){var H=opensocial.newDataRequest();H.add(H.newFetchPersonRequest("VIEWER"),"viewer");H.send(function(J){viewer=J.get("viewer").getData();postChallengeBulletinAndRequests(viewer,B,C,I,G,D,A);});}else{postChallengeBulletinAndRequests(viewer,B,C,I,G,D,A);}}function submitRequestChallenge(C,F){var B=document.getElementById("challengeForm");var A=[];var E={};for(var D=0;D<B.elements.length;++D){if(B.elements[D].type=="checkbox"){if(B.elements[D].checked){E[B.elements[D].name]=B.elements[D].value;A.push(B.elements[D].value);}}}removeChallengeTakeover();postChallengeRequests(C,A,F,E,0);}function postChallengeBulletinAndRequests(D,C,A,F,B,H,E){var G=opensocial.newMessage(B);G.setField(opensocial.Message.Field.TITLE,H);G.setField(opensocial.Message.Field.TYPE,opensocial.Message.Type.NOTIFICATION);opensocial.requestSendMessage(D.getField(opensocial.Person.Field.ID),G,function(I){if(I&&!I.hadError()&&I.getData()==1){var J=getPersonId(D);E["ids"+J]=J;}postChallengeRequests(C,A,F,E,0);});}var g_requestRecipients;var g_requestIds;var g_requestUrl;var g_requestText;function postChallengeRequests(B,C,H,A,G){g_requestRecipients=C;g_requestUrl=B;g_requestText=H;g_requestIds=A;if(G>1&&C.length>0){document.getElementById("white_overlay").style.display="block";document.getElementById("challenge_instructions_background").style.display="block";document.getElementById("challenge_instructions_padding").style.display="block";document.getElementById("challenge_instructions_continue").style.display="block";return ;}var F=C.pop();if(F==undefined){var E={};var D=A;D["challenge"]="1";E[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(D);E[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;displayPage(B,E);}else{if(F==329353963||F==6221){A["ids"+F]="";postChallengeRequests(B,C,H,A,G);}else{var I=opensocial.newMessage(H);opensocial.requestShareApp(F,I,function(J){if(J&&(J.hadError()||J.getData()==0)){A["ids"+F]="";if(J.getData()==0){G=G+1;}}else{G=0;}postChallengeRequests(B,C,H,A,G);});}}}function cancelChallengeRequests(C,A,D){var B=A.pop();if(B==undefined){var F={};var E=D;E["challenge"]="1";F[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(E);F[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;displayPage(C,F);}else{D["ids"+B]="";cancelChallengeRequests(C,A,D);}}function submitChallenge(B,D,A,E){removeChallengeTakeover();var C=opensocial.newDataRequest();addFetchViewerFriendsRequest(C,"viewerFriends");C.add(C.newFetchPersonRequest("VIEWER"),"viewer");C.send(function(K){var G=document.getElementById("challengeForm");var J={};for(var I=0;I<G.elements.length;++I){if(G.elements[I].type=="checkbox"){if(G.elements[I].checked){J[G.elements[I].name]=G.elements[I].value;}}}var F=[];var L=K.get("viewerFriends").getData();L.each(function(M){if(J["ids"+getPersonId(M)]){F.push(M);}});var H=K.get("viewer").getData();F.reverse();postChallengeBulletinAndComments(H,B,F,D,A,E,J);});}function submitCommentChallenge(A,C){removeChallengeTakeover();var B=opensocial.newDataRequest();addFetchViewerFriendsRequest(B,"viewerFriends");B.send(function(H){var E=document.getElementById("challengeForm");var G={};for(var F=0;F<E.elements.length;++F){if(E.elements[F].type=="checkbox"){if(E.elements[F].checked){G[E.elements[F].name]=E.elements[F].value;}}}var D=[];var I=H.get("viewerFriends").getData();I.each(function(J){if(G["ids"+getPersonId(J)]){D.push(J);}});D.reverse();postChallengeComments(A,D,C,G,0);});}function submitBulletinChallenge(B,A,D){var C=opensocial.newDataRequest();C.add(C.newFetchPersonRequest("VIEWER"),"viewer");C.send(function(F){var E=F.get("viewer").getData();postChallengeBulletin(E,B,A,D);});}function postChallengeBulletin(C,B,A,F){var E=opensocial.newMessage(A);var D={};E.setField(opensocial.Message.Field.TITLE,F);E.setField(opensocial.Message.Field.TYPE,opensocial.Message.Type.NOTIFICATION);opensocial.requestSendMessage(C,E,function(G){if(G&&!G.hadError()&&G.getData()==1){var H=getPersonId(C);D["ids"+H]=H;}var J={};var I=D;I["challenge"]="1";J[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(I);J[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;displayPage(B,J);});}function postChallengeBulletinAndComments(D,C,A,G,B,H,E){var F=opensocial.newMessage(B);F.setField(opensocial.Message.Field.TITLE,H);F.setField(opensocial.Message.Field.TYPE,opensocial.Message.Type.NOTIFICATION);opensocial.requestSendMessage(D.getField(opensocial.Person.Field.ID),F,function(I){if(I&&!I.hadError()&&I.getData()==1){var J=getPersonId(D);E["ids"+J]=J;}postChallengeComments(C,A,G,E,0);});}var g_commentRecipients;var g_commentIds;var g_commentUrl;var g_commentText;function postChallengeComments(B,C,H,A,G){g_commentRecipients=C;g_commentUrl=B;g_commentText=H;g_commentIds=A;if(G>1&&C.length>0){document.getElementById("white_overlay").style.display="block";document.getElementById("challenge_instructions_background").style.display="block";document.getElementById("challenge_instructions_padding").style.display="block";document.getElementById("challenge_instructions_continue").style.display="block";return ;}var F=C.pop();var I=(F==undefined?undefined:getPersonId(F));if(F==undefined){var E={};var D=A;D["challenge"]="1";E[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(D);E[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;displayPage(B,E);}else{if(I==329353963||I==6221){A["ids"+I]="";postChallengeComments(B,C,H,A,G);}else{var J=opensocial.newMessage(H);J.setField(opensocial.Message.Field.TYPE,opensocial.Message.Type.PUBLIC_MESSAGE);opensocial.requestSendMessage(F,J,function(K){if(K&&(K.hadError()||K.getData()==0)){A["ids"+I]="";if(K.getData()==0){G=G+1;}}else{G=0;}postChallengeComments(B,C,H,A,G);});}}}function cancelChallengeComments(C,A,D){var B=A.pop();if(B==undefined){var F={};var E=D;E["challenge"]="1";F[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(E);F[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;displayPage(C,F);}else{D["ids"+getPersonId(B)]="";cancelChallengeComments(C,A,D);}}function postActivity(A,F,J,I,H){var D="";for(var B in F){if(D.length>0){D+=", ";}D+="["+B+"]:["+F[B]+"]";}var C={};C[opensocial.Activity.Field.TITLE_ID]=A;C[opensocial.Activity.Field.TEMPLATE_PARAMS]=F;if(J.length>0){var G=[];for(var E=0;E<J.length;E++){G.push(opensocial.newMediaItem("",J[E]));}C[opensocial.Activity.Field.MEDIA_ITEMS]=G;}var K;if(I||H){K=function(L){if(I){var N={};var M={"id":A};if(!L||L.hadError()||L.getData()==-1){M["result"]=-1;}else{if(L.getData()==0){M["result"]=0;}else{if(L.getData()==1){M["result"]=1;}}}N[gadgets.io.RequestParameters.POST_DATA]=gadgets.io.encodeValues(M);N[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;gadgets.io.makeRequest(I,function(){if(H){navigateTo(H);}},N);}else{navigateTo(H);}};}opensocial.requestCreateActivity(opensocial.newActivity(C),opensocial.CreateActivityPriority.HIGH,K);}function addFetchViewerFriendsRequest(D,C){var B={};B[opensocial.IdSpec.Field.USER_ID]=opensocial.IdSpec.PersonId.VIEWER;B[opensocial.IdSpec.Field.GROUP_ID]=opensocial.IdSpec.GroupId.FRIENDS;var A=opensocial.newIdSpec(B);D.add(D.newFetchPeopleRequest(A),C);}function getPersonId(A){var C=A.getField(opensocial.Person.Field.ID);var B=C.indexOf(":");if(B!=-1){C=C.substring(B+1);}return C;}function getHeight(){var A;if(typeof (document.height)!="undefined"){A=document.height;}else{if(document.body&&typeof (document.body.scrollHeight)!="undefined"){A=document.body.scrollHeight;}}if(!A){if(gadgets.views.getCurrentView().getName()==gadgets.views.ViewType.CANVAS){A="2000";}else{A="300";}}return A;}function display(){var C=gadgets.views.getParams();var A=gadgets.views.getCurrentView();var B=C["page"];if(B){displayPage(B,{});}else{displayPage("/surface/"+A.getName().toLowerCase()+".jsp",{});}}function displayPage(A,B){showPageLoadingTimer();B[gadgets.io.RequestParameters.AUTHORIZATION]=gadgets.io.AuthorizationType.SIGNED;gadgets.io.makeRequest(MS_HOST+A,function(I){if(!I||!I.data){document.getElementById("content").innerHTML='<center><br /><br /><h1> MySpace had a problem processing your request.</h1><h1><a href="'+document.location.href+'"><div style="text-decoration: underline;">Click here to try again.</div></a></h1></center>';showPageContent();return ;}document.getElementById("content").innerHTML=I.data;var K=document.getElementById("redirect");if(K){navigateTo(K.value);}else{showPageContent();var D=gadgets.views.getCurrentView();if(D.getName()==gadgets.views.ViewType.CANVAS){ctrAdd(document.getElementById("content"));}var L=document.getElementById("analytics");if(L){var H=_gat._getTracker(L.value);H._initData();var E=document.getElementById("analyticsPage");if(E){H._trackPageview(E.value);}else{H._trackPageview();}}var C=document.getElementById("scrollToTopId");if(C){C.focus();C.blur();}var O=document.getElementById("activity_title_id");if(O){O=O.value;var F=document.getElementById("activity_template_params");if(F){F=F.value;}var Q=document.getElementById("activity_media_items");if(Q){Q=Q.value;}var J=document.getElementById("activity_callback_url");if(J){J=J.value;}var G=document.getElementById("activity_redirect_page");if(G){G=G.value;}var M=(F?F.evalJSON(true):{});var R=(Q?Q.evalJSON(true):[]);postActivity(O,M,R,J,G);}var P=document.getElementById("ve_ad");if(P){if(viewer){display_ve_ad();}else{var N=opensocial.newDataRequest();N.add(N.newFetchPersonRequest("VIEWER"),"viewer");N.send(function(S){viewer=S.get("viewer").getData();display_ve_ad();});}}}},B);}function no_ve_ad(B){var A=document.getElementById("ve_ad_outer");A.innerHTML='<div class="mj_container" style="position:relative;width:300px;height:250px;padding-bottom:5px;">'+'<iframe style="position:absolute;top:0px;left:0px;" width="300px" height="250px" frameborder="0" src="'+MS_HOST+'/index_rect_iframe1.jsp" smartsize="false" scrolling="no"></iframe>'+"</div>";}function display_ve_ad(){if(viewer){var C=viewer.getField(opensocial.Person.Field.GENDER);var A=viewer.getField(opensocial.Person.Field.AGE);if(C){C=C.toLowerCase();if(C=="male"){C="m";}if(C=="female"){C="f";}}var B={vg:C,va:A,publisher:VE_PUBLISHER,site:VE_SITE,area:VE_AREA,width:300,height:250,alternate:no_ve_ad,parentElement:"ve_ad"};var D=new videoegg.AdManager(B);}}function toggle_high_scores(){if(document.getElementById("friend_high_scores_table").style.display!="none"){document.getElementById("friend_high_scores_table").style.display="none";document.getElementById("global_new_high_scores_table").style.display="";}else{document.getElementById("global_new_high_scores_table").style.display="none";document.getElementById("friend_high_scores_table").style.display="";}}function toggle_recently_played(){if(document.getElementById("friends_recently_played_table").style.display!="none"){document.getElementById("friends_recently_played_table").style.display="none";document.getElementById("your_recently_played_table").style.display="";}else{document.getElementById("your_recently_played_table").style.display="none";document.getElementById("friends_recently_played_table").style.display="";}}