﻿// Accordion Javascript
var accordions = new Array();
accordions[0] = 'accordion_yellow';
accordions[1] = 'accordion_blue';
$(document).ready(function(){
        accordion_count = accordions.length;
        for(i=0; i<=accordion_count; i++)
        {
            temp = $("body").find("ul").hasClass(accordions[i]);
            if(temp)    {
                the_accordion = accordions[i];
                make_accordion(the_accordion);
            }
        }
    });
    
function make_accordion(acc)    {    
    // Hide all sections but first, set top-most section to current                           
    $("ul." + acc + " li ul:not(:first)").hide();
    $("ul." + acc + " li h3 a").css({ backgroundImage : "url('/static/eu/accordion_yellow_plus.jpg')" });
    $("ul." + acc + " li:first").attr("id", "current");
    $("li#current h3 a").css({ backgroundImage : "url('/static/eu/accordion_yellow_minus.jpg')" });
    $("li#current ul li:last").css("borderBottom", "none");
    $("ul." + acc + " li:last").css("borderBottom", "none");
    
    // Click to open other sections
    $("ul." + acc + " li h3 a").click(function(){    
        parent_li = $(this).parent().parent();                                       
        if(parent_li.attr("id") != "current")    {                
            $("ul." + acc + " li").removeAttr("id");
            $("ul." + acc + " li h3 a").css({ backgroundImage : "url('/static/eu/accordion_yellow_plus.jpg')" });
            $("ul." + acc + " li ul:visible").slideUp("slow");
            parent_li.attr("id", "current");                
            $("#current h3 a").css({ backgroundImage : "url('/static/eu/accordion_yellow_minus.jpg')" });                                                            
            $("#current ul").slideDown("slow");
            $("li#current ul li:last").css("borderBottom", "none");
            return false;
        }
    });
}