// JavaScript Document
// Used to contain all the JavaScript for the homepage
//
// By: Daniel Williams, daniel@sawleysturios.co.uk
// Copywrite: Whitesands Media Limited, www.whitesandsmedia.com
//


$(document).ready(function() {
	//Setup all the input boxes
	$('.inputWithInitialValue').addClass('greyOutControl').val(function() {
		return $(this).attr('InitialValue');
	});
	
	//On activate change the class
	$('.inputWithInitialValue').focus( function() {
		currentValue = $(this).val();
		initialValue = $(this).attr('InitialValue');
		if (currentValue == initialValue) {
			$(this).val('');
		}
		$(this).removeClass('greyOutControl').addClass('activeControl');
	});
	
	//On Blur if blank place the inital value back and return the class details
	$('.inputWithInitialValue').blur( function() {
		currentValue = $(this).val();
		initialValue = $(this).attr('InitialValue');
		if (currentValue == '' || currentValue.toLowerCase() == initialValue.toLowerCase()) {
			$(this).val(initialValue);
			$(this).removeClass('activeControl').addClass('greyOutControl');
		}
	});
	
	
});
