 $(document).ready(function() {

$("#register").validate({
      messages: {
     first_name: "*",
     email: {
       required: "*",
       email: "Incorrect email format"
     },
     last_name:"*",
     password:"*",
     passconf:"*",
     nationality:"*",
     contact:"*",
	 year:"*",
	 country:"*"
      }
});
$("#create-admin").validate({
     messages: {
     username: "*",
     email: {
       required: "*",
       email: "Incorrect email format"
     },
     password:"*",
     passconf:"*"
     }
});
$("#adminlogin").validate({
    messages: {
        username:"*",
        password:"*"
    }
});
$('#registrationform').find('#reg_email').blur(function() {
    $.post('ajax/check_email',
      {'email':$('#reg_email').val()},
      function(result) {
       $('#bad_email').replaceWith('');
        if (result==1) {

          alert('That email is already taken. Please choose another');
        }if (result==3) {

          alert('Please enter an E-mail Address');
        }
		else
		{

		}
      }
    );
  });
 });

      function logout()
    {
        $.post('home/logout', {},
        function result(){
            if(result)
                {
                    location.reload();
                }
        });
    }
