$(document).ready(function(){ var imageArray = new Array(); imageArray[0] = 4; imageArray[1] = 3; imageArray[2] = 5; imageArray[3] = 1; imageArray[4] = 2; var index = 0; //SET CURSOR $(".banner").css('cursor', 'pointer'); //HIDE HOVERS BY DEFAULT $('.banner_images_hovers').children().fadeTo('fast', 0, function () { $('.banner_images_hovers').children().css('display', 'block'); }); //HOVER STATES $('.banner_images_hovers').children().hover(function() { hover(this); }, function() { unhover(this); }); //HOVER STATE STAYS ACTIVE WHEN ELEMENT IS CLICKED $('.banner_images_hovers').children().click(function() { $(this).parent().children().each(function() { if($(this).hasClass("hovered")) { $(this).removeClass("hovered"); unhover(this); } }); $(this).toggleClass("hovered"); //GET THE APPROPRIATE ACCORDIAN INDEX FOR THE SLIDETOGGLE index = $(this).attr("class").substring(5, 6)-1; $("#accordian_" + imageArray[index]).slideToggle("slow"); }); //HIDE DIVS BY DEFAULT $(".accordian").hide(); //TOGGLE DIV ON CLICK $(".accordian_link").bind("click", function(e){ $(this).parent().next("p").next(".accordian").slideToggle("slow"); }); //TOGGLE DIV ON CLICK $(".accordian_link2").bind("click", function(e){ $(this).parent().next(".accordian").slideToggle("slow"); }); }); function hover(element) { if(!$(element).hasClass("hovered")) { var which = $(element).children('.hover'); $(element).fadeTo(500, 1); } } function unhover(element) { if(!$(element).hasClass("hovered")) { var which = $(element).children('.hover'); $(element).fadeTo(500, 0); } }