$(document).ready(function(){$("#title").focus();var a="false",g="false";$("#imageURL").focus(function(){$("#imageURL").val("")});$("#create_game").click(function(){a="false";if($.trim($("#uploadImage").val()).length==0&&($.trim($("#imageURL").val()).length==0||$.trim($("#imageURL").val())=="type or paste your image URL here")){$("#step1_error_message").html("Please provide an image from one of the option below.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#imageURL").focus();a=
"true"}if($.trim($("#imageURL").val()).length==0||$.trim($("#imageURL").val())=="type or paste your image URL here")if($.trim($("#uploadImage").val()).length>0){var b=$.trim($("#uploadImage").val()).split(".")[1].toLowerCase();if(b!="jpg"&&b!="jpeg"&&b!="gif"&&b!="png"){$("#step1_error_message").html("Invalid Image File. Supported Formats are: JPG, GIF or PNG.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");a="true"}}if(a=="true"){$("#loader").css("width","0");return false}else $("#loader").css("width",
"auto")});$("#create_game1").click(function(){a="false";if($.trim($("#uploadImage").val()).length==0&&($.trim($("#imageURL").val()).length==0||$.trim($("#imageURL").val())=="type or paste your image URL here")){$("#step1_error_message").html("Please provide an image from one of the option below.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#imageURL").focus();a="true"}if($.trim($("#imageURL").val()).length==0||$.trim($("#imageURL").val())=="type or paste your image URL here")if($.trim($("#uploadImage").val()).length>
0){var b=$.trim($("#uploadImage").val()).split(".")[1].toLowerCase();if(b!="jpg"&&b!="jpeg"&&b!="gif"&&b!="png"){$("#step1_error_message").html("Invalid Image File. Supported Formats are: JPG, GIF or PNG.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");a="true"}}if(a=="true"){$("#loader").css("width","0");return false}else $("#loader").css("width","auto")});$("#create_game2").click(function(){a="false";if($.trim($("#uploadImage").val()).length==0&&($.trim($("#imageURL").val()).length==
0||$.trim($("#imageURL").val())=="type or paste your image URL here")){$("#step1_error_message").html("Please provide an image from one of the option below.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#imageURL").focus();a="true"}if($.trim($("#imageURL").val()).length==0||$.trim($("#imageURL").val())=="type or paste your image URL here")if($.trim($("#uploadImage").val()).length>0){var b=$.trim($("#uploadImage").val()).split(".")[1].toLowerCase();if(b!="jpg"&&b!="jpeg"&&b!="gif"&&
b!="png"){$("#step1_error_message").html("Invalid Image File. Supported Formats are: JPG, GIF or PNG.");$("#step1_error").hide();$("#step1_error").fadeIn("slow");a="true"}}if(a=="true"){$("#loader").css("width","0");return false}else $("#loader").css("width","auto")});$("#frmCreateSecond").submit(function(){if(g=="false"){a="false";var b="Please correct the following errors:<br /><br />";if($.trim($("#gameTitle").val()).length==0){b+="&nbsp;&nbsp;&nbsp;- Title is missing.<br />";a="true"}if($.trim($("#gameDesc").val()).length==
0){b+="&nbsp;&nbsp;&nbsp;- Description is missing.<br />";a="true"}if($.trim($("#gameTags").val()).length==0){b+="&nbsp;&nbsp;&nbsp;- Tags is missing.<br />";a="true"}if(a=="true"){$("#step2_error_message").html(b);$("#step2_thanks").hide();$("#step2_error").hide();$("#step2_error").fadeIn("slow");$("#gameTitle").focus();return false}else if($("#loginAttempt").val()=="FALSE"){$("#basic-modal-content").modal();$("#loginForm").submit(function(){a="false";var c="",d=$.trim($("#luname").val()),f=$.trim($("#lpass").val());
if(d==""){c="You didn't enter your username.<br />";a="true"}if(f==""){c+="You didn't enter your password.";a="true"}if(a=="true"){$("#_login_error_message").html(c);$("#_login_error").hide();$("#_login_error").fadeIn("slow");$("#luname").focus();return false}else{$("#_login_error").hide();$.ajaxSetup({cache:false});c=_mainRoot+"api/ajax_login_register.php";var e="";$("#loader_login").html("<img src='/games/images/aloader.gif' alt='logging in, please wait...' />");$("#loader_login").show();$.post(c,
{u:d,p:f,d:"login"},function(h){e=h;if(e=="TRUE"){$.modal.close();g="true";$("#frmCreateSecond").submit()}else{$("#_login_error_message").html("Wrong Username or Password. Please Try Again.");$("#_login_error").hide();$("#loader_login").hide();$("#_login_error").fadeIn("slow")}},"html")}return false});$("#registerForm").submit(function(){a="false";var c="",d=$.trim($("#runame").val()),f=$.trim($("#rpass").val()),e=$.trim($("#remail").val());if(document.registerForm.rage.checked==false){c="Please confirm your age.";
a="true"}var h=/^[^@]+@[^@.]+\.[^@]*\w\w$/,i=/[\(\)\<\>\,\;\:\\\"\[\]]/;if(e==""){c="Please enter an email address.";a="true"}else if(h.test(e)){if(e.match(i)){c="The email address contains illegal characters.";a="true"}}else{c="Please enter a valid email address.";a="true"}if(f==""){c="Please provide your password.";a="true"}i=/\W/;if(d==""){c="Please provide your username.";a="true"}else if(d.length<5||d.length>15){c="The username should be more than 5 and less than 15 characters.";a="true"}else if(i.test(d)){c=
"The username contains illegal characters.";a="true"}if(a=="true"){$("#_register_error_message").html(c);$("#_register_error").hide();$("#_register_error").fadeIn("slow");$("#runame").focus();return false}else{$("#_register_error").hide();$.ajaxSetup({cache:false});c=_mainRoot+"api/ajax_login_register.php";var j="";$("#loader_register").html("<img src='/games/images/aloader.gif' alt='loading...' />");$("#loader_register").show();$.post(c,{u:d,p:f,e:e,d:"register"},function(k){j=k;if(j=="TRUE"){$.modal.close();
g="true";$("#frmCreateSecond").submit()}else{$("#_register_error_message").html(j);$("#_register_error").hide();$("#loader_register").hide();$("#_register_error").fadeIn("slow")}},"html")}return false});return false}else return true}else return true})});
