/***********************************************************************************************************************
DOCUMENT: includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 3/26/2009
UPDATED: 3/25/2010
DESCRIPTION: This is the JavaScript required to create the accordion style menu.  Requires jQuery library
NOTE: Because of a bug in jQuery with IE8 we had to add an IE stylesheet hack to get the system to work in all browsers. I hate hacks but had no choice :(.
************************************************************************************************************************/
jquery(document).ready(function() {

    /*
    jquery("div.accordionButton").click(function() {
    if ($(this).is(".accordionButtonSelected")){
    jquery("div.accordionContent").slideUp("normal");
    } else {
    jquery("div.accordionContent").slideUp("normal");
    jquery(this).next().slideDown("normal");
    jquery("div.accordionButtonSelected").removeClass().addClass("accordionButton");
    jquery(this).removeClass().addClass("accordionButtonSelected");
    }
    });
    */

    //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
    jquery('.accordionButton').click(function() {

        //REMOVE THE ON CLASS FROM ALL BUTTONS
        jquery('.accordionButton').removeClass('on');


        //NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
        jquery('.accordionContent').slideUp(1000);


        //IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
        if (jquery(this).next().is(':hidden') == true) {

            //ADD THE ON CLASS TO THE BUTTON
            jquery(this).addClass('on');

            //OPEN THE SLIDE
            jquery(this).next().slideDown(1000);
        }

    });


    /*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/

    //ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
    jquery('.accordionButton').mouseover(function() {
        jquery(this).addClass('over');

        //ON MOUSEOUT REMOVE THE OVER CLASS
    }).mouseout(function() {
        jquery(this).removeClass('over');
    });

    /*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/


    /********************************************************************************************************************
    CLOSES ALL S ON PAGE LOAD
    ********************************************************************************************************************/

    jquery('.accordionContent').hide();

    /*
    var x = document.getElementById('mBobby');
    jquery(x).addClass('on')
    jquery(x).click();
    jquery(x).next().slideDown(1000);
    */
    try {
    for (var i = 0; i < jquery('.accordionButton').length; i++) {
    if (jquery('.accordionButton')[i].id == v)
    var x = document.getElementById(v);
    jquery(x).addClass('on')
    jquery(x).next().slideDown(1000);
    }
    }
    catch(e)
    {
    }



});

