// wait for the DOM to be ready, which is a little sooner than when the page loads for the user
$(document).ready(function() {
    // hide the specified element
    $('.slide_contents').hide();
    // hide the specified element
    $('#javascript_error').hide();
    // show the specified element
    $('.startOpen').show();
    // add a click handler to the specified element
    $('a.slide_link').click(function() {
        /*
           crawl up the DOM tree by finding the ancestor element of
           of the one that was just clicked. then, go to the sibling
           element (next), and then toggle that element 
        */
        $(this).parents('.slide_parent').next('.slide_contents').slideToggle('fast');
    });
    // fill the specified element with some code
    $('#toggle_background').html('<label for="all_slide_toggle">Check box item</label>\n<input id="all_slide_toggle" type="checkbox" tabindex="0" /> Checking this box will expand all the submenus.');
    // add a click handler to the specified element
    $('#all_slide_toggle').click(function() {
        // toggle all of the specified elements
        $('.slide_contents').slideToggle('fast');
    });
    
    $('#all_finals').click(function() {
        $('.toggle').toggleClass('offstate-a');
        $('.toggle').toggleClass('offstate-b');
    });
    
    // add title text to the specified element
    $('.slide_link').attr({title: "click to expand"});
});

function toggle(id) {
    var elementId = document.getElementById(id);
    if (elementId.style.display != 'none') {
        elementId.style.display = 'none';
    } else {
        elementId.style.display = '';
    }
}

/*
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
*/

/*
 * menu.js code taken from a Web tutorial by Joseph De Araujo.
 * http://www.interspire.com/content/articles/10/1/Building-An-Expanding-DHTML-Menu-With-CSS-and-JavaScript
 * Thank you!
 */

menu_status = new Array();

function showHide(theid)
{
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'onstate-a') {
           switch_id.className = 'onstate-a';
           menu_status[theid] = 'onstate-a';
        }else{
           switch_id.className = 'offstate-a';
           menu_status[theid] = 'offstate-a';
        }
    }
}

/*
 * menu_status2 written by CSU Staff by modifying menu_status to work with drop-down select elements.
 */

menu_status2 = new Array();

function showHide2(dropdown)
{

    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value

    if (document.getElementById) {
    var switch_id = document.getElementById(SelValue);

        if(menu_status2[SelValue] != 'onstate-a') {
           switch_id.className = 'onstate-a';
           menu_status2[SelValue] = 'onstate-a';
        }else{
           switch_id.className = 'offstate-a';
           menu_status2[SelValue] = 'offstate-a';
        }
    }
}