$(document).ready(function() {  
      
    //if submit button is clicked  
    $('#comment-submit').click(function () {

		var error = '';
		var data = '';
        var comment = $('textarea[name=comment_text]'); 

		if($("#name"))
		{
			var name = $("#name").val();
			if (name == "") {
				error += "<li>Name not entered</li>";
			}
			else
			{
				data += 'name=' + name;
			}
		}
		if($("#email"))
		{
			var email = $("#email").val();
			if (email != "" && !email.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)) {
				error += "<li>Valid Email not entered</li>";
			}
			else
			{
				data += '&email=' + email;
			}
		}
		if($("#website"))
		{
			var website = $("#website").val();
			if (website != "" && !website.match(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/)) {
				error += "<li>Valid URL entered</li>";
			}
			else
			{
				data += '&website=' + website;
			}
		}

		if (comment.val() == "") {
			error += "<li>Comment text not entered</li>";
		}
		else
		{
			data += '&comment_text=' + comment.val();
		}
			
			
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		data += '&comment-submit=submit&type=' + $("#type").val() + '&slug=' + $("#slug").val();
		data += '&ip=' + $("#ip").val() + '&reply=' + $("#reply").val() + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
          
        //disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "/comment-submit.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
	//			comment.val(html);
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
    });   
	
	
	 $('#ability-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name = $("#name2").val();
		var desc = $("#description").val();
		var requires = $("#requires").val();
		var ab_class = $("#class2").val();
		var rank = $("#rank2").val();
		var action_cost = $("#action_cost").val();
		var tp_cost = $("#tp_cost").val();
		var cast_time = $("#cast_time").val();
		var recast_time = $("#recast_time").val();
		var mp_cost = $("#mp_cost").val();
		var attributes = $("#attributes").val();
		
		if (name == "") {
				error += "<li>Name not entered</li>";
		}
		if (desc == "") {
				error += "<li>Description not entered</li>";
		}
		if (requires == "") {
				error += "<li>Requires value not entered</li>";
		}
		if (ab_class == -1) {
				error += "<li>Class not selected</li>";
		}
		if (!rank.match(/^([0-9]+)$/)) {
				error += "<li>Valid Rank not entered</li>";
		}
		if (!action_cost.match(/^([0-9]+)$/)) {
				error += "<li>Valid Acion Cost value not entered</li>";
		}
		if (!tp_cost.match(/^([0-9]+)$/)) {
				error += "<li>Valid TP Cost value not entered</li>";
		}
		if (!cast_time.match(/^([0-9]+)$/)) {
				error += "<li>Valid Cast Time value not entered</li>";
		}
		if (!recast_time.match(/^([0-9]+)$/)) {
				error += "<li>Valid Recast Time value not entered</li>";
		}
		if (!mp_cost.match(/^([0-9]+)$/)) {
				error += "<li>Valid MP Cost value not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}

		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		
		data += '&ability-submit=submit&name2=' + name + '&description=' + desc + '&requires=' + requires + '&class2=' + ab_class + '&rank2=' + rank + '&action_cost=' + action_cost + '&tp_cost=' + tp_cost + '&cast_time=' + cast_time + '&recast_time=' + recast_time + '&mp_cost=' + mp_cost + '&attributes=' + attributes + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
	 
	 $('#armour-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name = $("#name2").val();
		var type = $("#type").val();
		var base = $("#base").val();
		var finish = $("#finish").val();
		var slot = $("#slot").val();
		var favours = $("#favours").val();
		var class2 = $("#class2").val();
		var rank2 = $("#rank2").val();
		var defence = $("#defence").val();
		var magic_defence = $("#magic_defence").val();
		var evasion = $("#evasion").val();
		var resilience = $("#resilience").val();
		var air = $("#air").val();
		var water = $("#water").val();
		var ice = $("#ice").val();
		var earth = $("#earth").val();
		var fire = $("#fire").val();
		var lightning = $("#lightning").val();
		var wear = $("#wear").val();
		//not checked
		var damage_cut = $("#damage_cut").val();
		var repair_materials = $("#repair_materials").val();
		var repaired_by = $("#repaired_by").val();
		var obtained = $("#obtained").val();
		var unique = $("#unique").val();
		var untradable = $("#untradable").val();
		var stats = $("#stats").val();
		
		if (name == "") {
				error += "<li>Name not entered</li>";
		}
		if (type == "") {
				error += "<li>Type not entered</li>";
		}
		if (base == "") {
				error += "<li>Base not entered</li>";
		}
		if (slot == -1) {
				error += "<li>Slot not selected</li>";
		}
		if (favours == "") {
				error += "<li>Favours value not entered</li>";
		}
		if (class2 == -1) {
				error += "<li>Class not selected</li>";
		}
		if (!rank2.match(/^([0-9]+)$/)) {
				error += "<li>Valid Rank not entered</li>";
		}
		if (!defence.match(/^([0-9]+)$/)) {
				error += "<li>Valid Defence value not entered</li>";
		}
		if (!magic_defence.match(/^([0-9]+)$/)) {
				error += "<li>Valid Magic Defence value not entered</li>";
		}
		if (!evasion.match(/^([0-9]+)$/)) {
				error += "<li>Valid Evasion value not entered</li>";
		}
		if (!resilience.match(/^([0-9]+)$/)) {
				error += "<li>Valid Resolience value not entered</li>";
		}
		if (!air.match(/^([0-9]+)$/)) {
				error += "<li>Valid Air Resistence value not entered</li>";
		}
		if (!water.match(/^([0-9]+)$/)) {
				error += "<li>Valid Water Resistence value not entered</li>";
		}
		if (!ice.match(/^([0-9]+)$/)) {
				error += "<li>Valid Ice Resistence value not entered</li>";
		}
		if (!earth.match(/^([0-9]+)$/)) {
				error += "<li>Valid Earth Resistence value not entered</li>";
		}
		if (!fire.match(/^([0-9]+)$/)) {
				error += "<li>Valid Fire Resistence value not entered</li>";
		}
		if (!lightning.match(/^([0-9]+)$/)) {
				error += "<li>Valid Lightning Resistence value not entered</li>";
		}
		if (wear == "") {
				error += "<li>Wear value not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		data += '&armour-submit=submit&name2=' + name + '&type=' + type + '&base=' + base + '&finish=' + finish + '&slot=' + slot + '&favours=' + favours +'&class2=' + class2;
		data += '&rank2=' + rank2 +'&defence=' + defence +' &magic_defence=' + magic_defence + '&evasion=' + evasion + '&resilience=' + resilience + '&air=' + air +'&water=' + water;
		data += '&ice=' + ice +'&earth=' + earth + '&fire=' + fire + '&lightning=' + lightning + '&wear=' + wear + '&damage_cut=' + damage_cut + '&repair_materials=' + repair_materials;
		data += '&repaired_by=' + repaired_by + '&obtained=' + obtained  + '&unique=' + unique  + '&untradable=' + untradable + '&stats=' + stats + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
	 
	  $('#item-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name = $("#name2").val();
		var classification = $("#classification").val();
		var type2 = $("#type2").val();
		var stack = $("#stack").val();
		var obtained = $("#obtained").val();
		var rank2 = $("#rank2").val();
		var class2 = $("#class2").val();
		var description = $("#description").val();
		//not checked
		var stats = $("#stats").val();
		var unique = $("#unique").val();
		var untradable = $("#untradable").val();
		
		if (name == "") {
				error += "<li>Name not entered</li>";
		}
		if (classification == "") {
				error += "<li>Classification value not entered</li>";
		}
		if (type2 == -1) {
				error += "<li>Class not selected</li>";
		}
		if (stack == "") {
				error += "<li>Stack value not entered</li>";
		}
		if (!rank2.match(/^([0-9]+)$/)) {
				error += "<li>Valid Rank not entered</li>";
		}
		if (class2 == -1) {
				error += "<li>Class not selected</li>";
		}
		if (description == "") {
				error += "<li>Description not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		
		
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		
		data += '&item-submit=submit&name2=' + name + '&classification=' + classification + '&type2=' + type2 + '&stack=' + stack + '&obtained=' + obtained + '&rank2=' + rank2 + '&class2=' + class2 + '&description=' + description + '&stats=' + stats + '&unique=' + unique + '&untradable=' + untradable + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
	 
	 $('#npc-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name2 = $("#name2").val();
		var role2 = $("#role2").val();
		var rank = $("#rank").val();
		var x = $("#x").val();
		var y = $("#y").val();
		var zone2 = $("#zone2").val();
		var agressive = $("#agressive").val();
		var description = $("#description").val();
		var race = $("#race").val();
		
		if (name2 == "") {
				error += "<li>Name not entered</li>";
		}
		if (role2 == -1) {
				error += "<li>Role  not selected</li>";
		}
		if (rank != "" && !rank.match(/^([0-9]+)$/)) {
				error += "<li>Invalid Rank entered</li>";
		}
		if (x != "" && !x.match(/^([0-9]+)$/)) {
				error += "<li>Invalid X-Coordinate entered</li>";
		}
		if (y != "" && !y.match(/^([0-9]+)$/)) {
				error += "<li>Invalid Y-Coordinate entered</li>";
		}
		if (zone2 == -1) {
				error += "<li>Zone not selected</li>";
		}
		if (agressive == -1) {
				error += "<li>Aggression value not selected</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		
		data += '&npc-submit=submit&name2=' + name2 + '&role2=' + role2 + '&rank=' + rank + '&x=' + x + '&race=' + race + '&y=' + y + '&zone2=' + zone2 + '&agressive=' + agressive + '&description=' + description + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
	 
	 $('#guide-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';

		var guide = $("#guide").val();
		var id = $("#id").val();
		var slug = $("#slug").val();
		
		if (guide == "") {
				error += "<li>Guide not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		
		data += '&guide-submit=submit&guide=' + guide + "&id=" + id + "&slug=" + slug + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
	 
	 $('#tool-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name2 = $("#name2").val();
		var attacks = $("#attacks").val();
		var base = $("#base").val();
		var slot2 = $("#slot2").val();
		var class2 = $("#class2").val();
		var rank2 = $("#rank2").val();
		
		var craftsmanship = $("#craftsmanship").val();
		var magic_craftsmanship = $("#magic_craftsmanship").val();
		var control = $("#control").val();
		var scanning = $("#scanning").val();
		var gathering = $("#gathering").val();
		var output = $("#output").val();
		
		var air = $("#air").val();
		var water = $("#water").val();
		var ice = $("#ice").val();
		var earth = $("#earth").val();
		var fire = $("#fire").val();
		var lightning = $("#lightning").val();
		var wear = $("#wear").val();
		//not checked
		var repair_materials = $("#repair_materials").val();
		var repaired_by = $("#repaired_by").val();
		var obtained = $("#obtained").val();
		var unique = $("#unique").val();
		var untradable = $("#untradable").val();
		
		if (name2 == "") {
				error += "<li>Name not entered</li>";
		}
		if (attacks != "" && !attacks.match(/^([0-9]+)$/)) {
				error += "<li>Valid Number of Attacks not entered</li>";
		}
		if (base == "") {
				error += "<li>Base not entered</li>";
		}
		if (slot2 == -1) {
				error += "<li>Slot not Selected</li>";
		}
		if (class2 == -1) {
				error += "<li>Class not selected</li>";
		}
		if (!rank2.match(/^([0-9]+)$/)) {
				error += "<li>Valid Rank not entered</li>";
		}
		if (!craftsmanship.match(/^([0-9]+)$/)) {
				error += "<li>Valid Craftsmanship value not entered</li>";
		}
		if (!magic_craftsmanship.match(/^([0-9]+)$/)) {
				error += "<li>Valid Magic Craftsmanship value not entered</li>";
		}
		if (!control.match(/^([0-9]+)$/)) {
				error += "<li>Valid Control value not entered</li>";
		}
		if (!scanning.match(/^([0-9]+)$/)) {
				error += "<li>Valid Scanning value not entered</li>";
		}
		if (!gathering.match(/^([0-9]+)$/)) {
				error += "<li>Valid Gathering value not entered</li>";
		}
		if (!output.match(/^([0-9]+)$/)) {
				error += "<li>Valid Output value not entered</li>";
		}
		if (!air.match(/^([0-9]+)$/)) {
				error += "<li>Valid Air Resistence value not entered</li>";
		}
		if (!water.match(/^([0-9]+)$/)) {
				error += "<li>Valid Water Resistence value not entered</li>";
		}
		if (!ice.match(/^([0-9]+)$/)) {
				error += "<li>Valid Ice Resistence value not entered</li>";
		}
		if (!earth.match(/^([0-9]+)$/)) {
				error += "<li>Valid Earth Resistence value not entered</li>";
		}
		if (!fire.match(/^([0-9]+)$/)) {
				error += "<li>Valid Fire Resistence value not entered</li>";
		}
		if (!lightning.match(/^([0-9]+)$/)) {
				error += "<li>Valid Lightning Resistence value not entered</li>";
		}
		if (wear == "") {
				error += "<li>Wear value not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		data += '&tool-submit=submit&name2=' + name2 + '&slot2=' + slot2 + '&attacks=' + attacks + '&base=' + base +'&class2=' + class2;
		data += '&rank2=' + rank2 +'&craftsmanship=' + craftsmanship +' &magic_craftsmanship=' + magic_craftsmanship + '&control=' + control + '&scanning=' + scanning + '&gathering=' + gathering + '&output=' + output + '&air=' + air +'&water=' + water;
		data += '&ice=' + ice +'&earth=' + earth + '&fire=' + fire + '&lightning=' + lightning + '&wear=' + wear + '&repair_materials=' + repair_materials;
		data += '&repaired_by=' + repaired_by + '&obtained=' + obtained  + '&unique=' + unique  + '&untradable=' + untradable + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
				$('#obtained').val(html);
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });

		 $('#weapon-submit').click(function () {
	 
		// validate
		var error = '';
		var data = '';
		
		var name2 = $("#name2").val();
		var type = $("#type").val();
		var base = $("#base").val();
		var finish = $("#finish").val();
		var slot2 = $("#slot2").val();
		var attack = $("#attacks").val();
		var class2 = $("#class2").val();
		var rank2 = $("#rank2").val();
		
		var accuracy = $("#accuracy").val();
		var attack_power = $("#attack_power").val();
		var critical_hit = $("#critical_hit").val();
		var defence = $("#defence").val();
		var magic_accuracy = $("#magic_accuracy").val();
		var magic_potency = $("#magic_potency").val();
		
		var air = $("#air").val();
		var water = $("#water").val();
		var ice = $("#ice").val();
		var earth = $("#earth").val();
		var fire = $("#fire").val();
		var lightning = $("#lightning").val();
		var wear = $("#wear").val();
		//not checked
		var damage_type = $("#damage_type").val();
		var repair_materials = $("#repair_materials").val();
		var repaired_by = $("#repaired_by").val();
		var obtained = $("#obtained").val();
		var unique = $("#unique").val();
		var untradable = $("#untradable").val();
		
		if (name2 == "") {
				error += "<li>Name not entered</li>";
		}
		if (type == "") {
				error += "<li>Type not entered</li>";
		}
		if (base == "") {
				error += "<li>Base not entered</li>";
		}
		if (slot2 == -1) {
				error += "<li>Slot not selected</li>";
		}
		if (attack != "" && !attack.match(/^([0-9]+)$/)) {
				error += "<li>Invalid Attack value entered</li>";
		}
		if (class2 == -1) {
				error += "<li>Class not selected</li>";
		}
		if (!rank2.match(/^([0-9]+)$/)) {
				error += "<li>Valid Rank not entered</li>";
		}
		if (!accuracy.match(/^([0-9]+)$/)) {
				error += "<li>Valid Accuracy value not entered</li>";
		}
		if (!attack_power.match(/^([0-9]+)$/)) {
				error += "<li>Valid Attack Power value not entered</li>";
		}
		if (!critical_hit.match(/^([0-9]+)$/)) {
				error += "<li>Valid Critical_hit value not entered</li>";
		}
		if (!defence.match(/^([0-9]+)$/)) {
				error += "<li>Valid Defence value not entered</li>";
		}
		if (!magic_accuracy.match(/^([0-9]+)$/)) {
				error += "<li>Valid Magic Accuracy value not entered</li>";
		}
		if (!magic_potency.match(/^([0-9]+)$/)) {
				error += "<li>Valid Magic Potency value not entered</li>";
		}
		
		if (!air.match(/^([0-9]+)$/)) {
				error += "<li>Valid Air Resistence value not entered</li>";
		}
		if (!water.match(/^([0-9]+)$/)) {
				error += "<li>Valid Water Resistence value not entered</li>";
		}
		if (!ice.match(/^([0-9]+)$/)) {
				error += "<li>Valid Ice Resistence value not entered</li>";
		}
		if (!earth.match(/^([0-9]+)$/)) {
				error += "<li>Valid Earth Resistence value not entered</li>";
		}
		if (!fire.match(/^([0-9]+)$/)) {
				error += "<li>Valid Fire Resistence value not entered</li>";
		}
		if (!lightning.match(/^([0-9]+)$/)) {
				error += "<li>Valid Lightning Resistence value not entered</li>";
		}
		if (wear == "") {
				error += "<li>Wear value not entered</li>";
		}
		
		if (error != "") {
			$("#error_list").fadeIn("slow");  
			$("#error_list").html(error);
			return false;
		}
		challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();
		
		
		
		data += '&weapon-submit=submit&name2=' + name2 + '&type=' + type + '&base=' + base + '&finish=' + finish + '&slot2=' + slot2 + '&attack=' + attack +'&class2=' + class2;
		data += '&rank2=' + rank2 +'&accuracy=' + accuracy +' &attack_power=' + attack_power + '&critical_hit=' + critical_hit + '&defence=' + defence  + '&magic_accuracy=' + magic_accuracy  + '&magic_potency=' + magic_potency + '&air=' + air +'&water=' + water;
		data += '&ice=' + ice +'&earth=' + earth + '&fire=' + fire + '&lightning=' + lightning + '&wear=' + wear + '&damage_type=' + damage_type + '&repair_materials=' + repair_materials;
		data += '&repaired_by=' + repaired_by + '&obtained=' + obtained  + '&unique=' + unique  + '&untradable=' + untradable + "&recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField;
		
		//disabled all the text fields  
        $('.text').attr('disabled','true');  
         
		$("#error_list").fadeOut("slow");  
		 
        //show the loading sign  
        $('.loading').show();  
          
        //start the ajax  
        $.ajax({  
            //this is the php file that processes the data  
            url: "../item-add.php",   
              
            //GET method is used  
            type: "GET",  
  
            //pass the data           
            data: data,       
              
            //Do not cache the page  
            cache: false,  
              
            //success  
            success: function (html) {   
				
                //if process.php returned 1/true (send mail success)  
                if (html == true) { 
                    //show the success message  
                    $('.success').fadeIn('slow');  
					
					//clear fields
					$('.text').val('');
                      
                //if process.php returned 0/false (send mail failed)  
                } else {
					alert("An error occured. Check the verification text was entered correctly or the item doesn't already exist.");          
				}
				//hide the loading sign  
				$('.loading').hide();  
				
				//un-disable all the text fields  
				$('.text').removeAttr("disabled");
		//		$('#damage_type').val(html);
            }         
        });  
          
        //cancel the submit button default behaviours  
        return false;  
	 });
});  
