/** Feedback Form Code */
$(function() 
{ 
    //Show the forms
    $("form.comment-form, form.email-form").show().upgradeForm();
    
    $("form.comment-form, form.email-form").bind("send", function() {
        $(":input", this).attr("disabled", "disabled");
        $("button", this).addClass("working");
    });
    $("form.comment-form, form.email-form").bind("success", function() {
        $(":input", this).removeAttr("disabled");
        $("button", this).removeClass("working");
    });
    $("form.comment-form, form.email-form").bind("serverError", function() {
        $("button", this).removeClass("working");
        $("button", this).addClass("error");
        alert("error");
    });
    $("form.comment-form, form.email-form").bind("timeoutError", function() {
        $("button", this).removeClass("working");
        $("button", this).addClass("error");
    });

    //Enable Google Analytics Tracking of Form Actions    
    $("form.email-form").bind("success", function() {
        pageTracker_.trackPageview("/urchin/email");
    });
    $("form.comment-form").bind("success", function() {
        pageTracker_.trackPageview("/urchin/comment");
    });
    $("#subscribe-link").bind("success", function() {
        pageTracker_.trackPageview("/urchin/subscribe");
    });


    //Enable special form header click actions
    $("form.comment-form h3, form.email-form h3").toggle(
        function() { $(".form-fields", this.parentNode).slideDown("fast"); },
        function() { $(".form-fields", this.parentNode).slideUp("fast"); }
    ).css({cursor:"pointer"});
    
    
   //Enable Newsletter Signup
    $("form.newsletter-form").show().upgradeForm();
    
    $("form.newsletter-form").bind("send", function() {
        $(":input", this).attr("disabled", "disabled");
        $("button", this).addClass("working");
    });
    $("form.newsletter-form").bind("success", function() {
        $(":input", this).removeAttr("disabled");
        $("button", this).removeClass("working");
    });
    $("form.newsletter-form").bind("serverError", function() {
        $("button", this).removeClass("working");
        $("button", this).addClass("error");
        alert("error");
    });
    $("form.newsletter-form").bind("timeoutError", function() {
        $("button", this).removeClass("working");
        $("button", this).addClass("error");
    });
    
    //Enable Google Analytics Tracking of Form Actions and Subscriptions
    $("form.newsletter-form:not(.unsubscribe)").bind("success", function() {
        urchinTracker("/urchin/newsletter-subscribe");
    });
    $("form.newsletter-form.unsubscribe").bind("success", function() {
        urchinTracker("/urchin/newsletter-unsubscribe");
    });
});