function initFisheye(){$(document).ready(function(){$(".fisheyeLite").fisheyeLite(10,"img",false)})}function showStep(b){b-=1;var a=Math.round((b/$("div.wizardPanel").length)*100);$("#progress").progressbar("value",a);$("#wizDisplay div.wizardPanel").css("display","none").appendTo("#wizardBlock");$("#wizDisplay").html("");$("#wizardBlock div.wizardPanel[step='"+(b+1)+"']").appendTo("#wizDisplay").fadeIn("normal",initFisheye);$("#stepsBlock a").unbind("click").removeClass("disabled").removeClass("ladderColor").eq(b).addClass("ladderColor").click(function(){return false});$("#stepsBlock a:gt("+b+")").add(".permDis").click(function(){return false}).addClass("disabled");$("#stepsBlock a:eq("+b+")").removeClass("disabled").addClass("ladderColor");x_getWizHeader(b,b==1?$("#platformID").value():$("#gameID").value(),hdr_cb);$("#errorDiv").empty();scroll(0,0)}function getWizGames(a,b){$("#platformID").value(a);$("#wizDisplay div.wizardPanel").fadeOut();x_getWizGamesAll(a,b?games_cb_ns:games_cb)}function games_cb(a){$("#gamesPanel").html(a);x_getCustomGames($("#platformID").value(),customgame_cb)}function games_cb_ns(a){$("#gamesPanel").html(a);x_getCustomGames($("#platformID").value(),customgame_cb)}function customgame_cb(a){var b=$("#gamesPanel").html();b+=a;$("#gamesPanel").html(b);$(document).ready(function(){$("div.bottomDiv").css("display","none");$("div.topDiv").css("cursor","pointer").click(function(){$("div.bottomDiv").slideToggle()});$("#btnNewGame").disable().click(setCustomGame);var d=function(){if(this.value.length>=3){$("#btnNewGame").enable()}else{$("#btnNewGame").disable()}};var c=function(){if(this.selectedIndex==0){$("#customGameName").trigger("keypress").enable()}else{$("#btnNewGame").enable();$("#customGameName").disable()}};$("#customGame").bind("change",c);$("#customGameName").bind("keyup",d)});showStep(2)}function setCustomGame(){var a=$("#customGame").get(0);if(a.selectedIndex==0){x_addCustomGame($("#customGameName").value(),$("#platformID").value(),addcg_cb)}else{setGame(a.options[a.selectedIndex].value)}}function addcg_cb(output){eval(output);if(jsonData.error){$("#errorDiv").html(jsonData.error);return}else{setGame(jsonData.gameID)}}function hdr_cb(a){if(!a){return}$(".headerBlock").replaceWith(a)}function setGame(a){$("#gameID").value(a);showStep(3)}function getChallengerList(a){$("#whoChall").empty();if(a.selectedIndex>0){x_getChallengerList(a.selectedIndex,1,chall_cb)}else{$("#btnSave").enable()}}function getAcceptList(a){if(a){x_getChallengerList(a,0,chall_cb)}}function chall_cb(output){eval(output);if(jsonData.error){$("#errorDiv").html(jsonData.error);$("#btnSave").disable();return}else{$("#whoChall").html(jsonData.output);if(parseInt(jsonData.count)){$("#btnSave").enable()}else{$("#btnSave").disable()}}}function postChallenge(c){var e=document.getElementById("who");var a=document.getElementById("challengerID");var d=a?a.options[a.selectedIndex].value:0;var b=document.getElementById("allowInvites");if(!c){c=0}$("#btnSave").disable();x_postChallenge(c,$("#gameID").value(),e.options[e.selectedIndex].value,d,$("#title").value(),$("#detail").value(),$("#preferred").value(),$("#credits").value(),$("#expireDate").value(),0,(b.checked?1:0),post_cb)}function post_cb(output){eval(output);$("#btnSave").enable();if(jsonData.error){$("#errorDiv").html(jsonData.error);return}else{window.location=jsonData.success}}function initWizard(){var b=$("#platformID").value();var a=$("#gameID").value();if(b){getWizGames(b,!a?false:true);if(!a){return}}showStep(g_step)}function initHome(){var a=document.createElement("a");a.href="#";a.innerHTML="&nbsp;Filter Prove-It Challenges";$(a).addClass("minMax").addClass("max").click(function(c){var b=$(this).data("collapsed");if(b==null){b=true}if(!b){$(this).addClass("max")}else{$(this).removeClass("max")}$(this).data("collapsed",!b);$("#subFilter").slideToggle("normal");return false}).prependTo("#filterDiv")}function getChallenges(){$("#challengeContent").setWorking();x_getChallenges(challview_cb)}function challview_cb(a){$("#challengeContent").html(a)}function getFilterGames(a){x_getFilterGames(a.options[a.selectedIndex].value,filtergame_cb)}function filterChallenges(){var b=document.getElementById("platform");var a=document.getElementById("game");var c=document.getElementById("typeID");$("#challengeContent").setWorking();x_getChallenges(b.options[b.selectedIndex].value,(a==null?0:a.options[a.selectedIndex].value),c.options[c.selectedIndex].value,$("#credits").value(),challview_cb)}function filtergame_cb(a){$("#filterGame").html(a);filterChallenges()}function getComms(a){$("#match_setup_requests").setWorking();x_getComms(a,comm_cb)}function comm_cb(a){$("#match_setup_requests").html(a)}function processRequest(b,a){x_processRequest(b,a,rq_cb)}function rq_cb(output){eval(output);if(jsonData.success){window.location.reload(true)}else{$("#errorDiv").html(jsonData.error)}}function getMatchDetail(a){x_getMatchDetail(a,match_cb)}function match_cb(output){if(!output){return}eval(output);$("td.creditCell").html(jsonData.creditDisp);$("td.schedCell").html(jsonData.schedDisp);if(jsonData.enableReport){$("#btnRpt").removeAttr("disabled")}}function postRequest(a){$("#btnAccept").attr("disabled","disabled");x_postRequest(a,$("#challDate").value(),$("#challTime").value(),$("#challCredits").value(),$("#challNote").value(),postreq_cb)}function postreq_cb(output){eval(output);$("#btnAccept").removeAttr("disabled");if(jsonData.error){$("#errorDiv").html(jsonData.error);return}window.location.reload(true)}function setHighlight(a){var c=document.getElementsByName("match[wID]");var b=c[0].checked?c[1]:c[0];$("div.winLossDiv").removeClass("winLossSelect",500);$(b).parent().addClass("winLossSelect",500)}function checkSelect(){var a=document.getElementsByName("match[wID]");if(!a[0].checked&&!a[1].checked){alert("You must select an option above to specify the outcome of this match!");return false}return true}function getScreenshots(a){$("#screenshotDiv").setWorking();x_getPMatchScreenshots(a,ss_cb)}function ss_cb(a){$("#screenshotDiv").html(a)}var _element="fileToUpload";function ajaxFileUpload(a){$("#loading").ajaxStart(function(){$("#"+_element).hide();$(this).show()}).ajaxComplete(function(){$("#"+_element).show();$(this).hide()});$.ajaxFileUpload({url:"proveit.ajax?action=uploadScreenshot&matchID="+a,secureuri:false,fileElementId:_element,dataType:"json",success:function(c,b){if(typeof(c.error)!="undefined"){if(c.error!=""){alert(c.error)}else{document.getElementById(_element).value="";alert("Screenshot Successfully Uploaded!");getScreenshots(a)}}},error:function(c,b,d){alert(d)}});return false}function deleteScreenshot(a){x_deletePMatchSS(a,deletess_cb)}function deletess_cb(output){eval(output);if(jsonData.error){alert(jsonData.error);return}else{getScreenshots(jsonData.matchID)}};