/* 
function for slide show kindly provided by Jon Raasch
http://jonraasch.com/blog/a-simple-jquery-slideshow
*/
function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {// shortcut for the $(document).ready(callback) notation

//Start the slide show stuff
setInterval( "slideSwitch()", 5000 );
	
//filter for adding icon to file links
$("#intro a[href*=doc]").addClass("ic_word");
$("#intro a[href*=xls]").addClass("ic_excel");
$("#intro a[href*=pdf]").addClass("ic_pdf");
$("#intro a[href*=html]").addClass("ic_web");
$("#blog_lists a[href*=doc]").addClass("ic_word");
$("#blog_lists a[href*=xls]").addClass("ic_excel");
$("#blog_lists a[href*=pdf]").addClass("ic_pdf");
$("#blog_lists a[href*=html]").addClass("ic_web");

//filter for adding icon to race condition list for all race listings
$("#blog_lists dd[title*=Trail]").addClass("offroad");
$("#blog_lists dd[title*=Road]").addClass("road");
$("#blog_lists dd[title*=Hills]").addClass("hills");
$("#blog_lists dd[title*=Flat]").addClass("flat");
$("#blog_lists dd[title*=Rural]").addClass("rural");
$("#blog_lists dd[title*=Urban]").addClass("city");

// more details heading to show and hide paragraph
$('.race_description').hide().end().find('h4[title*=View]').click(function() {
$(this).next().slideToggle();
});
   // make h4 act like a link
$('h4[title*=View]').addClass("race_detail_toggle");// adds icon to link
$('h4[title*=View]').css("cursor", "pointer");
   
$('h4[title*=View]').click(function(){
$(this).toggleClass("active_toggle");
});
   
$('h4[title*=View]').hover(function(){
$(this).css("color", "#fff184");
},function(){
$(this).css("color", "#feb231");
});


$("#club_events").find("h4").hover(function(){
$(this).parent("li").addClass("events_over");
}, function(){
$(this).parent("li").removeClass("events_over");
});

$("#latest_news").find("h4").hover(function(){
$(this).parent("li").addClass("news_over");
}, function(){
$(this).parent("li").removeClass("news_over");
});

$("#notice").find("h4").hover(function(){
$(this).parent("li").addClass("notice_over");
}, function(){
$(this).parent("li").removeClass("notice_over");
});

$("#jnotice").find("h4").hover(function(){
$(this).parent("li").addClass("jnotice_over");
}, function(){
$(this).parent("li").removeClass("jnotice_over");
});

$("#blog_entries").find("h4").hover(function(){
$(this).parent("li").addClass("blog_over");
}, function(){
$(this).parent("li").removeClass("blog_over");
});

$(".gallery").find("a").hover(function(){
$(".gallery").addClass("gallery_over");							 
}, function(){
$(".gallery").removeClass("gallery_over");
});



}); // CLOSE : $(document).ready(callback)
