var URL_FAVORITE_MOVIE="/ajax/";var URL_FLAG_MOVIE="/ajax/flagMovie";var URL_DELETE_MOVIE="/ajax/deleteMovie";var URL_REJECT_MOVIE="/ajax/rejectMovie";var URL_DELETE_FAVORITE="/ajax/deleteFavorite";var URL_STAFFPICKS_MOVIE="/ajax/addStaffpicksMovie";var URL_ADD_FEATUED_ANIMATION="/ajax/addFeaturedAnimation";var URL_SET_COPYABLE="/ajax/setcopyable";var URL_SET_PUBLISHED="/ajax/setpublished";var URL_SET_PRIVATE_SHARE="/ajax/setprivateshare";var URL_SET_PUBLISHED_PSHARE="/ajax/setpublishedpshare";var URL_CHECK_MOVIE_COPY="/ajax/checkCopyMovie";var URL_SUBMIT_POLL="/ajax/submitPoll";var URL_CHECK_MOVIE_EDIT="/ajax/checkEditMovie";var URL_SET_ALLOW_DOWNLOAD="/ajax/setAllowDownload";var _publishStatusHistory=new Array();var _pshareStatusHistory=new Array();function checkEditMovie(A){new Ajax.Request(URL_CHECK_MOVIE_EDIT+"/"+A,{method:"post",onSuccess:function(C){var B=C.responseText;checkEditMovieComplete(B)},onFailure:function(){displayFeedback("1Error contacting the server")}})}function checkEditMovieComplete(A){parseResponse(A);if(typeof responseArray.json.url!="undefined"){if(responseArray.json.url=="reload"){window.location=window.location}else{window.location=responseArray.json.url}}else{if(responseArray.code=="0"){var B="";B=responseArray.html;if(view_name=="school"){jQuery("#OG_title").html(GT.gettext("Recover Animation"));jQuery("#OG_content").html(B);showOG()}else{showHTMLBox("Recover Animation",180,B,"autosave_dialog",undefined,true)}$("altime").innerHTML=autosaveTimeFormat($("altime").innerHTML);$("alatime").innerHTML=autosaveTimeFormat($("alatime").innerHTML)}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()}function autosaveTimeFormat(D){var C=convertTime(D);var B=new Date(D*1000);var A=B.getFullYear();var E=C.indexOf(A);if(E>0){C=C.replace(A,A+"<br/>")}return C}function convertTime(E){var C=new Date(E*1000);var A=C.toLocaleString();var F=C.getTimezoneOffset();var D=A.indexOf("(");if(D>0){A=A.substring(0,D)}if(A.indexOf("GMT")<0){var B=Math.abs(F/60);if(B<10){B="0"+B}B=B+"00";if(F>0){A=A+" GMT-"+B}else{A=A+" GMT+"+B}}return A}function favoriteMovie(D,C,B,A){pageTracker._trackPageview("/pageTracker/ajax/favoriteMovie");new Ajax.Request(URL_FAVORITE_MOVIE+C+"/"+D,{method:"post",onSuccess:function(F){var E=F.responseText;favoriteMovieComplete(E,C,B,A)},onFailure:function(){displayFeedback("1"+GT.gettext("Error contacting the server"))}})}function flagMovie(A){pageTracker._trackPageview("/pageTracker/ajax/flagMovie");new Ajax.Request(URL_FLAG_MOVIE+"/"+A,{method:"post",onSuccess:function(C){var B=C.responseText;flagMovieComplete(B)},onFailure:function(){displayFeedback("1"+GT.gettext("Error contacting the server"))}})}function favoriteMovieComplete(B,D,C,A){parseResponse(B);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){if(D=="deleteFavorite"){displayFeedback(responseArray.code+GT.gettext("Animation removed from your recommendations"))}else{displayFeedback(responseArray.code+GT.gettext("Animation added to your recommendations"))}$(C).style.display="none";$(A).style.display="block"}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()}function flagMovieComplete(A){parseResponse(A);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+GT.gettext("Animation flagged as inappropriate"))}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()}function deleteMovie(D,A,E,C){var G=GT.gettext("You will not be able to watch this animation any more!");if(!confirm(G)){return }else{if(A&&E&&C){var F=$(E).innerHTML-0;var B=URL_DELETE_MOVIE+"/"+D+"/"+A+"/"+F}else{var B=URL_DELETE_MOVIE+"/"+D}new Ajax.Request(B,{method:"post",onSuccess:function(I){var H=I.responseText;parseResponse(H);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+GT.gettext("Animation has been deleted"));if(A!="undefined"&&E!="undefined"&&C!="undefined"){$(C).innerHTML=responseArray.html}}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1Error contacting the server")}})}}function rejectMovie(B){var C="Are you sure you want to reject this animation?";if(!confirm(C)){return }else{var A=URL_REJECT_MOVIE+"/"+B;new Ajax.Request(A,{method:"post",onSuccess:function(E){var D=E.responseText;parseResponse(D);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+"Animation has been rejected")}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1Error contacting the server")}})}}function deleteFavorite(C,A,D,B){var F=GT.gettext("Are you sure you want to remove this movie from your favorite list?");if(!confirm(F)){return }else{var E=$(D).innerHTML-0;new Ajax.Request(URL_DELETE_FAVORITE+"/"+C+"/"+A+"/"+E,{method:"post",onSuccess:function(H){var G=H.responseText;parseResponse(G);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+GT.gettext("Animation has been removed from your recommendations"));$(B).innerHTML=responseArray.html}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1"+GT.gettext("Error contacting the server"))}})}}function copyMovie(B,A){var C="This movie was not created on this site.\nAre you sure to copy it to this site?";if(confirm(C)){checkCopyMovie(B,A)}}function editMovie(A){var B="To edit this movie, you are about to leave this site.\nDo you want to continue?";if(confirm(B)){location.href=A}}function staffpicksMovie(A){var B="Are you sure to Staffpicks this Animation?";if(!confirm(B)){return }else{new Ajax.Request(URL_STAFFPICKS_MOVIE+"/"+A,{method:"post",onSuccess:function(D){var C=D.responseText;parseResponse(C);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+"The animation has been added to Staffpicks")}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1Error contacting the server")}})}}function featureAnimation(A){var B="Are you sure to feature this Animation?";if(!confirm(B)){return }else{new Ajax.Request(URL_ADD_FEATUED_ANIMATION+"/"+A,{method:"post",onSuccess:function(D){var C=D.responseText;parseResponse(C);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){displayFeedback(responseArray.code+"The animation has been added as featured animation")}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1Error contacting the server")}})}}function registerMoviePublishStatusHistory(B,A){_publishStatusHistory[B]=A}function getMoviePublishStatusHistory(A){if(!_publishStatusHistory[A]){return null}return _publishStatusHistory[A]}function registerMoviePshareStatusHistory(B,A){_pshareStatusHistory[B]=A}function getMoviePshareStatusHistory(A){if(!_pshareStatusHistory[A]){return null}return _pshareStatusHistory[A]}function updateMovieStatus(F,H,G,E,B,D,A){pageTracker._trackPageview("/pageTracker/ajax/"+F+"/"+B);var C;switch(F){case"copy":C=URL_SET_COPYABLE+"/"+E+"/"+B;break;case"publish":C=URL_SET_PUBLISHED+"/"+E+"/"+B;break;case"pshare":C=URL_SET_PRIVATE_SHARE+"/"+E+"/"+B;break;case"publishpshare":C=URL_SET_PUBLISHED_PSHARE+"/"+E+"/"+B;break}new Ajax.Request(C,{method:"post",onSuccess:function(J){var I=J.responseText;parseResponse(I);if(typeof responseArray.json.url!="undefined"){window.location=responseArray.json.url}else{if(responseArray.code=="0"){if($("movie_thumb_"+E)){$("movie_thumb_"+E).src="/static/go/img/v2/"+D+"_overlay.gif"}if($(H)){$(H).show()}if($(G)){$(G).hide()}if(F=="pshare"){registerMoviePshareStatusHistory(E,B);if(B=="1"){if($(A)){$(A).triggerPshareStatusChange(E,true)}}else{if($(A)){$(A).triggerPshareStatusChange(E,false)}}}if(F=="publish"){registerMoviePublishStatusHistory(E,B);if(B=="1"){if($(A)){$(A).triggerPublishStatusChange(E,true)}}else{if($(A)){$(A).triggerPublishStatusChange(E,false)}}}if(F=="publishpshare"){registerMoviePshareStatusHistory(E,B);registerMoviePublishStatusHistory(E,B);if(B=="1"){if($(A)){$(A).triggerPshareStatusChange(E,false);$(A).triggerPublishStatusChange(E,true)}}else{if($(A)){$(A).triggerPublishStatusChange(E,false);$(A).triggerPshareStatusChange(E,true)}}}}else{displayFeedback(responseArray.code+responseArray.json.error)}}resetResponse()},onFailure:function(){displayFeedback("1Error contacting the server")}})}function updatePrivateSharing(A,B,C){if(A){$(C).hide();$(B).show()}else{$(C).show();$(B).hide()}}function setPrivateSharing(A){is_private_sharing=A;return }function checkCopyMovie(B,A){new Ajax.Request(URL_CHECK_MOVIE_COPY+"/"+A,{method:"post",onSuccess:function(E){var C=E.responseText;parseResponse(C);if(responseArray.json.free=="true"){location.href=B}else{var D=GT.gettext("This animation contains premium character(s)\nThe cost to copy this movie is:\n");if(responseArray.json.money_points>0&&responseArray.json.sharing_points>0){D=D+responseArray.json.money_points+" GoBucks and "+responseArray.json.sharing_points+" GoPoints."}else{if(responseArray.json.money_points>0){D=D+responseArray.json.money_points+" GoBucks."}else{if(responseArray.json.sharing_points>0){D=D+responseArray.json.sharing_points+" GoPoints."}}}if(responseArray.json.notenoughpoints=="true"){D=D+"\n\n"+GT.gettext("You do not have sufficient points to copy this animation.");alert(D)}else{D=D+"\n\n"+GT.gettext("Would you like to buy it?");if(confirm(D)){location.href=B}}}},onFailure:function(){displayFeedback("1"+GT.gettext("Error contacting the server"))}})}function toggleGigya(){if($("divWildfirePost").visible()){$("divWildfirePost").hide()}else{$("divWildfirePost").show()}}var to;function toggleUserStats(){showHideContent("1");$("toggleLink").writeAttribute("expanded",1-($("toggleLink").readAttribute("expanded")||"0"));if($("toggleLink").readAttribute("expanded")=="1"){$("toggleLink").innerHTML=GT.gettext("minimize");$("short_description").hide();$("join_date").style.display="block";$("userstats").style.height="55px"}else{$("toggleLink").innerHTML=GT.gettext("more");$("join_date").style.display="none";$("short_description").show();$("userstats").style.height="27px"}}function toggleMessagePreview(A,C,B){if(B){$(A).style.display="block";$(C).style.display="block"}else{$(A).style.display="none";$(C).style.display="none"}}function sendFBContent(){new Ajax.Request("/ajax/boxChannel/"+jQuery("#channel-dropdown").getSSKey(),{method:"post",onSuccess:function(B){var A=B.responseText;parseResponse(A);$("channel_content_div").innerHTML=responseArray.html},onFailure:function(){displayFeedback("1Error contacting the server")}})}function showSurveyOverlay(B){var A=currPos();A[1]=A[1]+100;$("surveyoverlay").style.display="block";$("overlayObject").style.margin=A[1]+"px 0px 0px 0px";if(B){grayOut(true,"showSurvey")}else{grayOut(false,"showSurvey")}}function hideSurvey(){grayOut(false,"showSurvey");$("surveyoverlay").style.display="none"}function submitPoll(){for(i=0;i<document.surveyForm.answer.length;i++){if(document.surveyForm.answer[i].checked){ans=document.surveyForm.answer[i].value}}other=document.surveyForm.other.value;if(ans!="no"&&ans!="yes"){other=ans;ans="yes"}new Ajax.Request(URL_SUBMIT_POLL+"/"+ans+"/"+other,{method:"post",onSuccess:function(B){var A=B.responseText;parseResponse(A);hideSurvey()},onFailure:function(){displayFeedback("1Error contacting the server")}})}function submitPollKeyPress(B){document.surveyForm.answer[2].checked=true;var A;if(B&&B.which){B=B;A=B.which}else{B=event;A=B.keyCode}if(A==13){submitPoll();return false}else{return true}}function setAllowDownload(B,A){new Ajax.Request(URL_SET_ALLOW_DOWNLOAD+"/"+B+"/"+A,{method:"post",onSuccess:function(D){var C=D.responseText;parseResponse(C);if(A){jQuery("#downloadable").hide();jQuery("#notDownloadable").show()}else{jQuery("#downloadable").show();jQuery("#notDownloadable").hide()}},onFailure:function(){displayFeedback("1Error contacting the server")}})};
