$(document).ready
(
	function()
	{
		$('#uid').keyup(uid_check);
		$('#email').keyup(email_check);
	}
);

function uid_check()
{	
	var uid = $('#uid').val();
	if(uid == "" || uid.length < 5)
	{
		$('#uidtick').hide();
		$('#uid').css('background-color', '#FFF');
	} else {

		jQuery.ajax
		(
			{
				type: "POST",
				url: "/scgi-bin/login.pl",
				data: 'action=ajax_check&check=uid&data='+ uid,
				cache: false,
				success: function(response)
				{
					if(response == 1)
					{
						$('#uid').css('background-color', '#C33');	
						$('#uidtick').hide();
						$('#uidcross').fadeIn();
						$('#submit').attr('disabled', 'disabled');
					} else if (response == 0 ) {
						$('#uid').css('background-color', '#5f5');
						$('#uidcross').hide();
						$('#uidtick').fadeIn();
						$('#submit').attr('disabled', '');
				  	} else {
						$('#uid').css('background-color', '#ff5');
						$('#uidcross').hide();
						$('#uidtick').hide();
						$('#submit').attr('disabled', 'disabled');
					}
				}
			}
		);
	}
}

function email_check()
{	
	var email = $('#email').val();
	if(email == "" || email.length < 16)
	{
		$('#emailtick').hide();
		$('#email').css('background-color', '#FFF');
	} else {

		jQuery.ajax
		(
			{
				type: "POST",
				url: "/scgi-bin/login.pl",
				data: 'action=ajax_check&check=email&data='+ email,
				cache: false,
				success: function(response)
				{
					if(response == 1)
					{
						$('#email').css('background-color', '#C33');	
						$('#emailtick').hide();
						$('#emailcross').fadeIn();
						$('#submit').attr('disabled', 'diabled');
					} else if (response == 0) {
						$('#email').css('background-color', '#5f5');
						$('#emailcross').hide();
						$('#emailtick').fadeIn();
						$('#submit').attr('disabled', '');
				  	} else {
						$('#email').css('background-color', '#ff5');
						$('#emailcross').hide();
						$('#emailtick').hide();
						$('#submit').attr('disabled', 'disabled');
					}
				}
			}
		);
	}
}

