Shadowbox.init();
jQuery.noConflict();
jQuery(document).ready(function()
{
	jQuery('.photo_group').jcarousel({
		scroll: 5,
		visible: 5
	});
	var validateUsername = jQuery('#validateUsername');
	jQuery('#username').keyup(function ()
	{
		var t = this;
		if (this.value != this.lastValue)
		{
			if (this.timer) clearTimeout(this.timer);
			validateUsername.removeClass('error').html('<img src="images/ajax-loader.gif" height="16" width="16" /> checking availability...');
			
			this.timer = setTimeout(function ()
			{
				jQuery.ajax({
					url: 'ajax/signup.php',
					data: 'action=check_username&username=' + t.value,
					dataType: 'json',
					type: 'post',
					success: function (j)
					{
						validateUsername.html(j.msg);
					}
				});
			}, 200);
			
			this.lastValue = this.value;
		}
	});
	var validateEmail = jQuery('#validateEmail');
	jQuery('#email').keyup(function ()
	{
		var t = this;
		if (this.value != this.lastValue)
		{
			if (this.timer) clearTimeout(this.timer);
			validateEmail.removeClass('error').html('<img src="images/ajax-loader.gif" height="16" width="16" /> checking...');
			
			this.timer = setTimeout(function ()
			{
				jQuery.ajax({
					url: 'ajax/signup.php',
					data: 'action=check_email&email=' + t.value,
					dataType: 'json',
					type: 'post',
					success: function (j)
					{
						validateEmail.html(j.msg);
					}
				});
			}, 200);
			
			this.lastValue = this.value;
		}
	});
	var validatePassword = jQuery('#validatePassword');
	jQuery('#password').keyup(function ()
	{
		var t = this;
		if (this.value != this.lastValue)
		{
			if (this.timer) clearTimeout(this.timer);
			validatePassword.removeClass('error').html('<img src="images/ajax-loader.gif" height="16" width="16" /> checking...');
			
			this.timer = setTimeout(function ()
			{
				jQuery.ajax({
					url: 'ajax/signup.php',
					data: 'action=check_password&password=' + t.value,
					dataType: 'json',
					type: 'post',
					success: function (j)
					{
						validatePassword.html(j.msg);
					}
				});
			}, 200);
			
			this.lastValue = this.value;
		}
	});
	var validateConfirm = jQuery('#validateConfirm');
	jQuery('#confirm').keyup(function ()
	{
		var t = this;
		if (this.value != this.lastValue)
		{
			if (this.timer) clearTimeout(this.timer);
			validateConfirm.removeClass('error').html('<img src="images/ajax-loader.gif" height="16" width="16" /> checking...');
			
			this.timer = setTimeout(function ()
			{
				if (jQuery('#confirm').attr('value') != jQuery('#password').attr('value'))
					validateConfirm.html('Your passwords do not match');
				else
					validateConfirm.html('Your passwords match');
			}, 200);
			
			this.lastValue = this.value;
		}
	});
});
