// JavaScript Document
// type = 1 => empty (text)
// type = 2 => email
// type = 3 => url
// type = 4 = > number
// type = 5 => postal code
// type = 6 => captcha
// type = 7 => money
// type = 8 => name
$(document).ready(function() {
	// type = text (check empty)
	$('.type-text').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 1}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// email
	$('.type-email').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 2}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// url
	$('.type-url').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 3}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// number
	$('.type-number').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 4}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// zipcode
	$('.type-zipcode').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 5}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// CAPTCHA
	$('#captcha-answer').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 6, 'question' : $('#captcha-question').val()}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// จำนวนเงิน
	$('.type-money').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 7}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
	// ชื่อ-นามสกุล
	$('.type-name').bind('keyup change blur', function()	{
		var msgid = $(this).next('a').attr('id');
		$.post('/system/snipplets/check.php', {'value' : this.value, 'type' : 8}, function(data)	{
			$('#' + msgid).html(data);
		});
	});
});
