$(document).ready(function () {

$('.easyForm').find(':text,:radio,:checkbox,:textarea').not(":button").each(function(){

if($(this).attr("type") == "text"){
$(this).addClass("field");
}

if($(this).is(".required")){
$(this).focus(function () {
$(this).removeClass("default");
$(this).removeClass("acceptable");
$(this).removeClass("unacceptable");
if($(this).val() == $(this)[0].title){
$(this).val("");						   
}
});

$(this).blur(function(){
$(this).addClass("default");
if ($(this).val() == ""){
$(this).val($(this)[0].title);
}else if($(this).val() != $(this)[0].title){
$(this).removeClass("default");
$(this).addClass("acceptable");
}
});
}else{
$(this).addClass("default");
}
});

$(".required").blur();

$("#button").click(checkForm);

});

var checkForm = function(){
var submitOk = true;
$('.easyForm').find(':text,:radio,:checkbox,:textarea').not(":button").each(function(){

if($(this).is(".required")){
$(this).removeClass("default");
if($(this).val() == $(this).attr("title") || $(this).val() == ""){
$(this).addClass("unacceptable");
submitOk = false;
}else{
$(this).addClass("acceptable");
}
}
});

if(submitOk == false){return false;}

$.ajax({
type: $("form.easyForm:first").attr("method"),
url: $("form.easyForm:first").attr("action"),
data: $("form.easyForm:first").serialize(),  
success: function(msg) {
$("form.easyForm:first > fieldset").fadeTo("slow", 0.30);
$('button#button').replaceWith('<p id="confirmation">'+ msg +'</p>');
}  
});
return false;

};
