/**
 * @project CFD27.com
 * @version 1.0 
 * @author Grace Pok (www.gracepok.com)
 * 
 * Contains: Catalog navigation menu.  Actually calls 
 * 
 */

//namespace
if ((typeof POK) == 'undefined') {
	var POK = {};
}

//Category Menu
var POK_CatMenu = new function() {
	
	
	//ID names referenced in HTML
	this.wrapname = 'catalogmenuwrap';
	this.toggleclassname = 'viewtoggle';
	this.trigger = 'navcat';
	this.catbodyID = 'pgcatalog'; 	//name of the category page
	
	//slide down/up the menu items
	//subcategories are done via CSS, not javascript
	this.togglemenu = function(){
		if ($(POK_CatMenu.wrapname).hasClassName(POK_CatMenu.toggleclassname)){
			Effect.SlideUp(POK_CatMenu.wrapname,  { duration: 0.5 }); 
		}
		else {
			Effect.SlideDown(POK_CatMenu.wrapname,  { duration: 0.5 }); 
		}
		$(POK_CatMenu.wrapname).toggleClassName(POK_CatMenu.toggleclassname);
		$(POK_CatMenu.trigger).toggleClassName(POK_CatMenu.toggleclassname)
	};
	
	//calling this in the beginning makes default setting to be on.
	//show the menu without animation
	this.setdefaulton = function(){
		$(POK_CatMenu.wrapname).show();
		$(POK_CatMenu.wrapname).toggleClassName(POK_CatMenu.toggleclassname);
		$(POK_CatMenu.trigger).toggleClassName(POK_CatMenu.toggleclassname);
	}
	this.disableToggle = function(){
		$(POK_CatMenu.trigger).stopObserving('click');
	}
}


Event.observe(window, "load", function(){
	//hookup Catalog Menu 
	if ($(POK_CatMenu.trigger) && !$(POK_CatMenu.catbodyID)){
		$(POK_CatMenu.trigger).observe('click', POK_CatMenu.togglemenu);
	}
	
});