//run on page load
$(document).ready( function() {
	//execute when an input, select or textarea is focused upon
	$("form ol li input, form ol li select, form ol li textarea").focus(function () {
		//set all li elements to have a normal background
		$(this).parent().parent().children().css("background-color","#ccc7b4");

		//change the background of this inputs parent li
		$(this).parent().css("background-color","#ada99b");
	});

	//Focus on the first input field automatically
	$("form ol li input:first").focus();

	//execute when the location select box is changed
	$("form ol li select#location").change(function(){checkLocation();});

	//run check location on page load too incase we have an invalid form
	checkLocation();
});

function checkLocation ()
{
	//check to see if our selected location is 'Other'
	if ( $("form ol li select#location").val() == "Other") {
		//show the 'other' box so the user can enter a custom location
		$("#otherLocality").css("visibility","visible");
		$("#otherLocality").css("display","block");

	}
	else {
		//hide the 'other' box as we have selected a normal location
		$("#otherLocality").css("visibility","hidden");
		$("#otherLocality").css("display","none");
	}
}

