inputs = new Object;

function list_form(form)
{
		var form_list = new Array;
		$('input, textarea, select', form).not('.btn, [type=submit]').each(function() {
			if(inputs[this.name]==this.value) this.value='';
			form_list.push(this.name+'='+this.value);
		})
		return form_list.join('&');
}

$(function() {
	$('form').live('submit', function() {
		$('input, textarea, select', this).not('.btn, [type=submit]').each(function() {
			if(inputs[this.name]==this.value)
			$(this).val('');
		})
	});

	$('input, textarea, select', this).not('.btn, [type=submit]').each(function() {		
		if(this.value=='' && inputs[this.name])
		this.value = inputs[this.name];
	})

	$('input, textarea, select', this).not('.btn, [type=submit]').live('blur', function() {		
		if(this.value=='' && inputs[this.name])
		{
			$(this).prev('.input_error_container').fadeIn();
			this.value = inputs[this.name];
		}
	})
	$('input, textarea, select', this).not('.btn, [type=submit]').live('focus', function() {		
		$(this).prev('.input_error_container').fadeOut();

		if(inputs[this.name] && this.value==inputs[this.name])
		this.value = '';
	})

	$('.checkbox').click(function() {

		if($('input', this).attr('checked')=='checked' )
		{
			$('.checkbox_input', this).removeClass('checked');
			$('input', this).attr('checked', false);
		}
		else
		{
			$('.checkbox_input', this).addClass('checked');
			$('input', this).attr('checked', 'checked');
		}
	});

	$('.radio').click(function() {
		$('.radio', $(this).parents('.radios')).removeClass('checked');

		$(this).addClass('checked');
		$('input', this).attr('checked', 'checked');
	});

	$('.radio input:checked').each(function() {
		$(this).parents('.radio').addClass('checked');
	})



	$('.checkbox').each(function() {
		$('input', this).hide();
		if($('input', this).attr('checked')=='checked')
		$('.checkbox_input', this).addClass('checked')
	});

	$('.input_error_container').click(function() {
		$(this).hide();
		$(this).parent().find('input').val('').focus();
	});
});
