$(document).ready(function(){
	$(".formfield :input").focus(function() {
		fieldLabel = $(this).attr("title");
		thisID = $(this).attr('id');
		$(this).parents('div.formfield').addClass("focused");
		if($(this).val() == fieldLabel){
			$(this).val("");
		}
	}).blur(function() {
		if(!this.value.length) {
			$(this).val(fieldLabel);
		}
		$(this).parents('div.formfield').removeClass("focused");
	});
	$(".formbutton").click(function() {
		$(".formfield :input.required").each(function(){
			fieldLabel = $(this).attr("title");
			if($(this).val() == fieldLabel){
				$(this).val("");
			}
		});
	});	
	var container = $('.errMsg');
	$("#onlineform").validate({
		errorContainer: container,
		submitHandler: function(form) {
			$(".formfield :input").each(function(){
				fieldLabel = $(this).attr("title");
				if($(this).val() == fieldLabel){
					$(this).val("");
				}
			});
		   form.submit();
		}
	});
});