$(document).ready(function(){
        
    $('.categoryLinkContainer').hover(function(){
        $(this).children('.subSectionMenu').show();
    }, function(){
        $(this).children('.subSectionMenu').hide();
    })
    
    if ($.browser.msie) {
        if ($.browser.version == 7.0) {
             $('.subSectionMenu').each(function(){
                 var newMargin = $(this).parent('.categoryLinkContainer').width();
                 $(this).css('margin-left','-'+newMargin+'px');
             })
                
        }
    }
    
    var timerAmount = 12500;
    var transitionSpeed = 'slow';
    
    var sliderWidth = $('#featuredCauses .causeSlide').outerWidth(true);
    var sliderAmount = $('#featuredCauses .causeSlide').length;
    var completeWidth = sliderWidth*sliderAmount;
    var lastReference = completeWidth-sliderWidth;
    var animatorTracker = 1;
    
    $('#causesSlideContainer').css('width',completeWidth);
    $('#causesSlideContainer').scrollLeft(0);
    
    function animateCauses() {
        
        //recheck current position
        currentScroll = $('#featuredCauses').scrollLeft();
        
        //move to original position
        if (currentScroll == lastReference) {
            currentScroll = -sliderWidth;
        }
        
        $('#featuredCauses').animate({
            'scrollLeft':currentScroll+sliderWidth
        }, transitionSpeed, function(){
            if (animatorTracker == sliderAmount-1) {
                animatorTracker = 0;
            } else {
                animatorTracker++;
            }
            //this calls itself recursively
            setTimeout(animateCauses, timerAmount);
        })
    }
   
    setTimeout(animateCauses, timerAmount);
    
    $('.faqQuestion').click(function(){
        $(this).siblings('.faqAnswer').slideToggle();
    })
    
    $('.faqAnswer').click(function(){
        $(this).slideToggle();
    }) 
    
    $('#search-term').click(function() {
        
        var currentText = $(this).val()
        $(this).val('');
        var newText = '';
        
        $(this).blur(function(){
            newText = $(this).val();
            if (newText == '') {
                $(this).val(currentText);
            }
        })
    
    })
    
})
