$(document).ready(function() {
    $('form#contactform').attr("action","");
    $('input#send').click(function () {$(this).validatesend();return false;});
    $('input#name').focus(function () {$(this).css("background-color","#FFFFFF");});
    $('input#name').blur(function () {if ($(this).val() == "") {$(this).css("background-color","#FB6960");}});
    $('input#email').focus(function () {$(this).css("background-color","#FFFFFF");});
    $('input#email').blur(function () {if ($(this).val() == "") {$(this).css("background-color","#FB6960");}});
    $('textarea#message').focus(function () {$(this).css("background-color","#FFFFFF");});
    $('textarea#message').blur(function () {if ($(this).val() == "") {$(this).css("background-color","#FB6960");}});
});
var sendingsmall = false;
$.fn.validatesend = function () {
    if (sendingsmall == false) {
        sendingsmall = true;
        var nm = $('input#name').val();
        var em = $('input#email').val();
        var ms = $('textarea#message').val();
        if (nm == "") {$('input#name').css('background-color','#FB6960');sendingsmall=false;}
        if (em == "") {$('input#email').css('background-color','#FB6960');sendingsmall=false;}
        if (ms == "") {$('textarea#message').css('background-color','#FB6960');sendingsmall=false;}
        if (nm == "") {$('input#name').focus(); return false;} else if (em == "") {$('input#email').focus();return false;} else if (ms == "") {$('textarea#message').focus();return false;}
        else {
            var poststr = "name=" + nm + "&email=" + em + "&message=" + ms + "&ajax=true" + "&sum=" + $("#sum").val();
            $.post("/wp-content/themes/rosieandlee/contact/contactsmall.php",poststr,function (data) {sendingsmall = false;if (data == false) {alert("sorry, there was an error submitting your message. Please call us to get in touch.");} else if (data !== "true") {alert(data);} else {$('form#contactform').html('<span class="replaceme" style="width:90%;margin:auto;font-size:16px;color:#FB6960;">Thank you for your message! We will be in touch shortly.</span><script type="text/javascript">Cufon.replace("span.replaceme");Cufon.now();</script>');}});
        }
    }

}
