$(document).ready(function() { $(".hasDropDown").hover( function() { $(this).addClass("dropDownShowing"); var thisDropDown = $(this).find(".dropDownMenu"); thisDropDown.show(); }, function() { $(this).removeClass("dropDownShowing"); var thisDropDown = $(this).find(".dropDownMenu"); thisDropDown.hide(); } ); $(".mainMenuItem").hover( function() { $(this).find(".MMIA").css("color","#fcd204"); $(this).find(".arrow").css("border-color","black transparent transparent transparent"); }, function() { $(this).find(".MMIA").css("color","white"); $(this).find(".arrow").css("border-color","#777 transparent transparent transparent"); } ); $(".mailingVal").focus(function() { if ($(this).val() == "Enter your email address") { $(this).val(""); $(this).css("color","black"); } }); $(".mailingVal").blur(function() { if ($(this).val() == "") { $(this).css("color","gray"); $(this).val("Enter your email address"); } }); $(".mailingButton").live('click', function() { var email = $(".mailingVal").val(); var checkbox = "" var comment = "" if ($(".mailingTextarea").length == 0 ){ checkbox = "yes" comment = "none" } else { comment = $(".mailingTextarea").val(); if ($("#the_checkbox").is(":checked")) { checkbox = "yes" } else { checkbox = "no" } } var email_regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if (!email_regex.test(email)) { $(".error").show(); return false; } else if (email == "") { $(".error").show(); return false; } else { $.ajax({ type: "post", url: "http://qualityhousewines.com/wp-content/themes/QH_theme/send.php", data: "email=" + email + "&comment=" + comment + "&checkbox=" + checkbox, error: function() { $('.error').show(); }, success: function () { $('.success').show(); } }); } return false; }); });