/*
  start Form Validator
*/
$(document).ready(function(){
	$("#signups").submit(function(){

		var email = $("#email").val();
		var error = "false";
		
		// reset errors
		document.getElementById("rslt").innerHTML = '';
		$("#email").css({"border": "1px solid #000"});

		
	   //Validate login form
		if (email == "" || email == "Enter your e-mail"){
			$("#email").css({"border": "1px solid #F00"});
			var error = "true";
		}

		//If there are no problems
		if (error == "false"){
			var dataString = "email=" + email;

			$.ajax({
			   cache: false,
			   url: "signup.php",
			   type: "POST",
			   data: dataString,
			   success: function (output) {
				   if (!output){
					   document.getElementById('rslt').innerHTML = '<span>Error, try again</span>';
				   } else {
					   
						document.getElementById('rslt').innerHTML = output;
				   }
			   },
			   error: function() { //If the code can't find the php file
				   document.getElementById('rslt').innerHTML = '<span>Error, try again</span>';
			   }
			});
			return false
		}
		return false
	});
});
