$(document).ready(function(){var a="false",g="false";$("#frmCreate").submit(function(){if(g=="false"){a="false";$("#step1_error").hide();for(var c=$("#id").val(),b=0;b<c;b++)if(document.getElementById("word"+b)!=null){$("input#word"+b).val($("input#word"+b).val().replace(/[^a-zA-Z 0-9]+/g,""));if($.trim($("input#word"+b).val()).match(" ")==null){if($.trim($("#word"+b).val()).length==0){c="Please correct the following errors:<br /><br />Please provide word to create crossword.<br />";$("#step1_error_message").html(c);
$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#word"+b).focus();a="true";break}if($.trim($("#word"+b).val()).length>12){c="Please correct the following errors:<br /><br />Please provide a word not more than 12 characters.<br />";$("#step1_error_message").html(c);$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#word"+b).select();a="true";break}if($.trim($("#clue"+b).val()).length==0){c="Please correct the following errors:<br /><br />Please provide hint to create crossword.<br />";
$("#step1_error_message").html(c);$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#clue"+b).focus();a="true";break}}else{c="Please correct the following errors:<br /><br />Space is not allowed between words.<br />";$("#step1_error_message").html(c);$("#step1_error").hide();$("#step1_error").fadeIn("slow");$("#word"+b).select();a="true";break}}if(a=="true")return false;else if($("#loginAttempt").val()=="FALSE"){$("#basic-modal-content").modal();$("#loginForm").submit(function(){a="false";
var d="",e=$.trim($("#luname").val()),h=$.trim($("#lpass").val());if(e==""){d="You didn't enter your username.<br />";a="true"}if(h==""){d+="You didn't enter your password.";a="true"}if(a=="true"){$("#_login_error_message").html(d);$("#_login_error").hide();$("#_login_error").fadeIn("slow");$("#luname").focus();return false}else{$("#_login_error").hide();$.ajaxSetup({cache:false});var f="";$("#loader_login").html("<img src='/games/images/aloader.gif' alt='logging in, please wait...' />");$("#loader_login").show();
$.post("../../api/ajax_login_register.php",{u:e,p:h,d:"login"},function(i){f=i;if(f=="TRUE"){$.modal.close();g="true";$("#frmCreate").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 d="",e=$.trim($("#runame").val()),h=$.trim($("#rpass").val()),f=$.trim($("#remail").val());if(document.registerForm.rage.checked==
false){d="Please confirm your age.";a="true"}var i=/^[^@]+@[^@.]+\.[^@]*\w\w$/,j=/[\(\)\<\>\,\;\:\\\"\[\]]/;if(f==""){d="Please enter an email address.";a="true"}else if(i.test(f)){if(f.match(j)){d="The email address contains illegal characters.";a="true"}}else{d="Please enter a valid email address.";a="true"}if(h==""){d="Please provide your password.";a="true"}j=/\W/;if(e==""){d="Please provide your username.";a="true"}else if(e.length<5||e.length>15){d="The username should be more than 5 and less than 15 characters.";
a="true"}else if(j.test(e)){d="The username contains illegal characters.";a="true"}if(a=="true"){$("#_register_error_message").html(d);$("#_register_error").hide();$("#_register_error").fadeIn("slow");$("#runame").focus();return false}else{$("#_register_error").hide();$.ajaxSetup({cache:false});var k="";$("#loader_register").html("<img src='/games/images/aloader.gif' alt='loading...' />");$("#loader_register").show();$.post("../../api/ajax_login_register.php",{u:e,p:h,e:f,d:"register"},function(l){k=
l;if(k=="TRUE"){$.modal.close();g="true";$("#frmCreate").submit()}else{$("#_register_error_message").html(k);$("#_register_error").hide();$("#loader_register").hide();$("#_register_error").fadeIn("slow")}},"html")}return false});return false}else return true}else return true});$("#frmCreateFirst").submit(function(){a="false";var c="Please correct the following errors:<br /><br />";$("#loader").css("width","auto");if($.trim($("#gametitle").val()).length==0){c+="&nbsp;&nbsp;&nbsp;- Title is missing.<br />";
a="true"}else $.ajax({url:_mainRoot+"ajxspam/",type:"POST",data:{sw:$("#gametitle").val(),ft:"s"},cache:false,async:false,success:function(b){if(b!=""){c=c+"&nbsp;&nbsp;&nbsp;- Please remove the following bad words from game title: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:red'>"+b+"</span><br />";a="true"}}});if($.trim($("#descr").val()).length==0){c+="&nbsp;&nbsp;&nbsp;- Description is missing.<br />";a="true"}else $.ajax({url:_mainRoot+"ajxspam/",type:"POST",data:{sw:$("#descr").val(),
ft:"s"},cache:false,async:false,success:function(b){if(b!=""){c=c+"&nbsp;&nbsp;&nbsp;- Please remove the following bad words from description: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:red'>"+b+"</span><br />";a="true"}}});if($.trim($("#tags").val()).length==0){c+="&nbsp;&nbsp;&nbsp;- Tags is missing.<br />";a="true"}else $.ajax({url:_mainRoot+"ajxspam/",type:"POST",data:{sw:$("#tags").val(),ft:"s"},cache:false,async:false,success:function(b){if(b!=""){c=c+"&nbsp;&nbsp;&nbsp;- Please remove the following bad words from tags: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:red'>"+
b+"</span><br />";a="true"}}});if(a=="true"){$("#loader").css("width","0");$("#step2_error_message").html(c);$("#step2_thanks").hide();$("#step2_error").hide();$("#step2_error").fadeIn("slow");$("#gametitle").focus();return false}else return true})});
function addFormField(){var a=document.getElementById("id").value,g=document.getElementById("trows").value;$("#wordsclues").append("<tr id='row"+a+"'><td id='tdword"+a+"' valign='middle'><input type='text' class='formfields' style='width:200px; margin-bottom:10px;' name='word"+a+"' id='word"+a+"'></td><td id='tdword"+a+"' valign='middle'><input type='text' class='formfields'  style='margin-bottom:10px;' name='clue"+a+"' id='clue"+a+"'></td>&nbsp;&nbsp;<a href='#' class='deleteCMT' title='Delete this word and clue' onClick='removeFormField(\"#row"+
a+"\"); return false;'></a></tr>");$("#row"+a).highlightFade({speed:1E3});a=a-1+2;g+=1;document.getElementById("id").value=a;document.getElementById("trows").value=g}function removeFormField(a){$(a).remove();a=document.getElementById("trows").value;a-=1;document.getElementById("trows").value=a};
