/********************
general.js
Copyright: Zane Hooper ( ZaneHooper.com )
********************/

$(function(){
	$(':input:not(.spec)').each(function(){
		var v = $(this).attr('value');
		$(this).attr('title', v);
	}).focus(function(){
		$(this).addClass('active');
		if ( $(this).attr('value') == $(this).attr('title') ) $(this).attr('value', '');
	}).blur(function(){
		if ( $(this).attr('value') == '' ) {
			var title = $(this).attr('title');
			$(this).removeClass('active');
			$(this).attr('value', title);
		}
	});
	$(':input[type=submit][alt]').each(function(){
		var alt_tag = $(this).attr('alt');
		var alt_exp = alt_tag.split('{');
		var sub_name = alt_exp[1].replace('}', '');
		var current = $(this);
			
		var input = $(':input[name=' + sub_name + ']');
		input.bind('keyup', function(){
			var value = $(this).attr('value');
					
			if ( !value ) {
			
				var new_value = 'Please enter a value.';
				current.attr('disabled', 'disabled');
			
			} else {
			
				var new_value = alt_exp[0] + value;
				current.attr('disabled', '');
			
			}
			
			current.attr('value', new_value );
		});
		
		if ( !input.hasClass('spec') ) $(this).attr('disabled', 'disabled');
	});
});