/* Expandable and Collapsible Nav v1.1 (09/26/08)- by Will Peavy */

(function(){

	 /* create cookies on section open */
    YAHOO.util.Event.on("section_1_closer", "click", function(){
		var newValue = "section_1_closer_actions";
        YAHOO.util.Cookie.set("section_1_closer", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_2_opener", "click", function(){
        var newValue = "section_2_open_actions";
        YAHOO.util.Cookie.set("section_2_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_3_opener", "click", function(){
        var newValue = "section_3_open_actions";
        YAHOO.util.Cookie.set("section_3_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_4_opener", "click", function(){
        var newValue = "section_4_open_actions";
        YAHOO.util.Cookie.set("section_4_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_5_opener", "click", function(){
        var newValue = "section_5_open_actions";
        YAHOO.util.Cookie.set("section_5_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_6_opener", "click", function(){
        var newValue = "section_6_open_actions";
        YAHOO.util.Cookie.set("section_6_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_7_opener", "click", function(){
        var newValue = "section_7_open_actions";
        YAHOO.util.Cookie.set("section_7_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_8_opener", "click", function(){
        var newValue = "section_8_open_actions";
        YAHOO.util.Cookie.set("section_8_open", newValue, {path: "/"});
    });
	YAHOO.util.Event.on("section_9_opener", "click", function(){
        var newValue = "section_9_open_actions";
        YAHOO.util.Cookie.set("section_9_open", newValue, {path: "/"});
    });
	
	/* remove cookies on section close */
	YAHOO.util.Event.on("section_1_opener", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_1_closer", {path: "/"}); 
	}); 
	YAHOO.util.Event.on("section_2_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_2_open", {path: "/"}); 
	}); 
	YAHOO.util.Event.on("section_3_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_3_open", {path: "/"}); 
	}); 
	YAHOO.util.Event.on("section_4_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_4_open", {path: "/"}); 
	}); 
	YAHOO.util.Event.on("section_5_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_5_open", {path: "/"}); 
	});
	YAHOO.util.Event.on("section_6_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_6_open", {path: "/"}); 
	});
	YAHOO.util.Event.on("section_7_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_7_open", {path: "/"}); 
	});
	YAHOO.util.Event.on("section_8_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_8_open", {path: "/"}); 
	});
	YAHOO.util.Event.on("section_9_closer", "click", function(){ 
	    YAHOO.util.Cookie.remove("section_9_open", {path: "/"}); 
	});
	
	/* look for cookies and update the dom depending on what cookies are present */
	function set_nav() {
		var value = YAHOO.util.Cookie.get("section_1_closer");
        if (value == "section_1_closer_actions") {
			hide('section_1');
			hide('section_1_closer'); 
			show('section_1_opener');
			};
		var value = YAHOO.util.Cookie.get("section_2_open");
        if (value == "section_2_open_actions") {
			show('section_2');
			show('section_2_closer'); 
			hide('section_2_opener');
			};
		var value = YAHOO.util.Cookie.get("section_3_open");
        if (value == "section_3_open_actions") {
			show('section_3');
			show('section_3_closer'); 
			hide('section_3_opener');
			};
		var value = YAHOO.util.Cookie.get("section_4_open");
        if (value == "section_4_open_actions") {
			show('section_4');
			show('section_4_closer'); 
			hide('section_4_opener');
			};
		var value = YAHOO.util.Cookie.get("section_5_open");
        if (value == "section_5_open_actions") {
			show('section_5');
			show('section_5_closer'); 
			hide('section_5_opener');
			};
		var value = YAHOO.util.Cookie.get("section_6_open");
        if (value == "section_6_open_actions") {
			show('section_6');
			show('section_6_closer'); 
			hide('section_6_opener');
			};
		var value = YAHOO.util.Cookie.get("section_7_open");
        if (value == "section_7_open_actions") {
			show('section_7');
			show('section_7_closer'); 
			hide('section_7_opener');
			};
		var value = YAHOO.util.Cookie.get("section_8_open");
        if (value == "section_8_open_actions") {
			show('section_8');
			show('section_8_closer'); 
			hide('section_8_opener');
			};
		var value = YAHOO.util.Cookie.get("section_9_open");
        if (value == "section_9_open_actions") {
			show('section_9');
			show('section_9_closer'); 
			hide('section_9_opener');
			};
    };
	 
	 set_nav();

})();