﻿$(document).ready(function() { 
    // insert here any js not needed for navigation or layout
    $("body.faqIndex ol#faqs > li").mouseover(function() { $(this).addClass("hover"); });
    $("body.faqIndex ol#faqs > li").mouseout(function() { $(this).removeClass("hover"); });
    $("body.faqIndex ol#faqs > li").click(function() { $("> div",this).toggle(); });
    
    $("div.contactBlock h3.revealer").click(function(ev){
        $("div.contactBlock p.contactFeedback").each(function(){
            $(this).empty();
        });
        var matches = $(this).attr('class').match(/\breveal-(.+?)\b/);
        if(matches.length>0) {
            var revealer = $(this);
            var revealerId = $(this).attr('id');
            var revealeeId = "#"+matches[1];
            if(revealer.hasClass("revealed")) {
                $(revealeeId).slideUp();
                revealer.removeClass("revealed");
            }
            else {
                $(revealeeId).slideDown();
                revealer.addClass("revealed");
            }
        }        
    });
    
    // move the feedback request to the end of the block so that it's visible!
    if($("div.contactBlock * p.contactFeedback")) {
        $("div.contactBlock").append($("div.contactBlock * p.contactFeedback"));
        $("div.contactBlock > p.contactFeedback").fadeIn();
        
        if($("p.questionSuccess").length > 0) {
            pageTracker._trackPageview("/send-email/success/");
        }
        else if($("p.callbackSuccess").length > 0) {
            pageTracker._trackPageview("/request-callback/success/");
        }
    }
});


