function ckusername()
{
	var username = $.trim($('#username').val());
	var ck = $('#ckusername');
	var ulen = username.replace(/[^\x00-\xff]/g, "**").length;
	if(ulen < reg_minname || ulen > reg_maxname)
	{
		cktip(ck, reg_name_len);
	}
    CKAjax(ck, 'type=ckusername&verifyhash=' + verifyhash + '&username=' + encodeURIComponent(username));
}
function ckemail()
{
	var email = $.trim($('#email').val());
	var ck = $('#ckemail');
	var reg = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|info)$/i;
	if(reg.test(email))
	{
		CKAjax(ck, 'type=ckemail&verifyhash=' + verifyhash + '&email=' + email);
	}
	else
	{
		cktip(ck, reg_email_error);
	}
}
function ckpw()
{
	var password = $.trim($('#password').val());
	var ck = $('#ckpw');
	if(password.length < 6 || /[\'\"\\]/.test(password))
	{
		cktip(ck, reg_pw_error);
	}
	else
	{
		ck.css('display', 'none');
	}
}
function ckrpw()
{
	var password = $.trim($('#password').val());
	var rpassword = $.trim($('#rpassword').val());
	var ck = $('#ckrpw');
	if(password != rpassword)
	{
		cktip(ck, reg_pw_nmatch);
	}
	else
	{
		ck.css('display', 'none');
	}
}
function ckinvite()
{
	var invite = $.trim($('#invite').val());
	var ck = $('#ckinvite');
	if(/^[a-z0-9]{18}$/.test(invite))
	{
		ck.css('display', 'none');
	}
	else
	{
		cktip(ck, reg_invite_error);
	}
}
function ckcaptcha()
{
	var captcha = $.trim($('#captcha').val());
	var ck = $('#ckcaptcha');
	if(/^[a-z0-9]{4}$/.test(captcha))
	{
		CKAjax(ck, 'type=ckcaptcha&verifyhash=' + verifyhash + '&captcha=' + captcha);
	}
	else
	{
		cktip(ck, captcha_error);
	}
}
function ckprivacy(obj)
{
	var ck = $('#ckprivacy');
	var submit = $('#submit');
	if(obj.checked)
	{
		ck.css('display', 'none');
		submit.attr('disabled', '');
	}
	else
	{
		submit.attr('disabled', 'disabled');
		cktip(ck, reg_privacy_error);
	}
}
function cktip(obj, message)
{
	obj.css('display','').html(message).addClass('warning');
}
function CKAjax(obj, param)
{
	obj.html(ajax_response_loading);
	$.ajax({
		type: 'GET',
		url: pb_url+'ajax.php',
		dataType: 'json',
		data: param + '&random=' + Math.random(),
		error: function(var1,var2,var3)
		{
			alert(var1.responseText);
			obj.html(ajax_response_failed);
		},
		success: function(data)
		{
			if (data[0]=='1')
			{
	            obj.html('<img src="' + pb_url + 'templates/' + pb_template + '/images/check_right.gif" width="13" height="13" />');
			}
			else
			{
				obj.html(data[1]);
			}
		}
	});
	return;
}
function regsubmit(obj)
{
	$('#submit').css('display', 'none');
	$('#registsending').css('display', '');
	return true;
}
function loginsubmit()
{
	$('#submit').attr('disabled', 'true');
	return true;
}