var timer = .8;
//Timer to show & hide in seconds

//Timer ID to clear timed hide of main menus
var timerID = null;

var current = "";




	function addEvent( obj, type, fn ) {
		if (obj.addEventListener) {
			obj.addEventListener( type, fn, false );
			EventCache.add(obj, type, fn);
		}
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn] );
			EventCache.add(obj, type, fn);
		}
		else {
			obj["on"+type] = obj["e"+type+fn];
		}
	}
		
	var EventCache = function(){
		var listEvents = [];
		return {
			listEvents : listEvents,
			add : function(node, sEventName, fHandler){
				listEvents.push(arguments);
			},
			flush : function(){
				var i, item;
				for(i = listEvents.length - 1; i >= 0; i = i - 1){
					item = listEvents[i];
					if(item[0].removeEventListener){
						item[0].removeEventListener(item[1], item[2], item[3]);
					};
					if(item[1].substring(0, 2) != "on"){
						item[1] = "on" + item[1];
					};
					if(item[0].detachEvent){
						item[0].detachEvent(item[1], item[2]);
					};
					item[0][item[1]] = null;
				};
			}
		};
	}();
	
	function $() {
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++) {
			var element = arguments[i];
			if (typeof element == 'string')
				element = document.getElementById(element);
			if (arguments.length == 1)
				return element;
			elements.push(element);
		}
		return elements;
	}
	

	
function show() {
		var showType = 'block';
		temphideall();
		if (timerID){
			clearTimeout(timerID);
		}
		for ( i=0; i < arguments.length; i++ ) {
			var obj = $(arguments[i]);
			if((obj.style.display == 'none') || ((obj.style.display=='') && (obj.offsetWidth==0))) {
				obj.style.display = showType;
			} 
		}
}


//Function that temporarily hides all menus
//called from show

function temphide() {
		var showType = 'none';
		for ( i=0; i < arguments.length; i++ ) {
				var obj = $(arguments[i]);
				if((obj.style.display == 'block') || ((obj.style.display=='') && (obj.offsetWidth==0))) {
						obj.style.display = showType;
					} else {
					 obj.style.display = showType;
				}
		}
}


//Function that calls temporarily hiding all menus

function temphideall(){
	temphide('handbags_sub','aboutus_sub','press_sub','stores_sub');
}



//Function that hides all menus but shows current one
	
function hide() {
		var showType = 'none';
		var currentType = 'block';
		for ( i=0; i < arguments.length; i++ ) {
			if (arguments[i] != current){
				var obj = $(arguments[i]);
				if((obj.style.display == 'block') || ((obj.style.display=='') && (obj.offsetWidth==0))) {
						obj.style.display = showType;
					} else {
					 obj.style.display = showType;
				}
			} else {
				var obj = $(arguments[i]);
				if((obj.style.display == 'none') || ((obj.style.display=='') && (obj.offsetWidth==0))) {
					obj.style.display = currentType;
				} 
			}
		}
}
		



//Function that calls hiding all menus
//called from hidetime

function hideall(){
	hide('handbags_sub','aboutus_sub','press_sub','stores_sub');
}

// Function to call menuhide with timer
// called from onmouseout
function hidetime(){ 
	timerID = setTimeout("hideall();",timer*1000);
}



	
	
	var togglers = {
		init : function() {
			addEvent($('handbags'),'mouseover',this.handbags_on);
			addEvent($('handbags'),'mouseout',hidetime);
			addEvent($('crystal'),'mouseover',this.handbags_on);
			addEvent($('crystal'),'mouseout',hidetime);
			addEvent($('satin'),'mouseover',this.handbags_on);
			addEvent($('satin'),'mouseout',hidetime);
			
			addEvent($('aboutus'),'mouseover',this.aboutus_on);
			addEvent($('aboutus'),'mouseout',hidetime);
			addEvent($('companyprofile'),'mouseover',this.aboutus_on);
			addEvent($('companyprofile'),'mouseout',hidetime);
			addEvent($('productcare'),'mouseover',this.aboutus_on);
			addEvent($('productcare'),'mouseout',hidetime);
			
			addEvent($('press'),'mouseover',this.press_on);
			addEvent($('press'),'mouseout',hidetime);
			addEvent($('redcarpet'),'mouseover',this.press_on);
			addEvent($('redcarpet'),'mouseout',hidetime);
			addEvent($('editorspicks'),'mouseover',this.press_on);
			addEvent($('editorspicks'),'mouseout',hidetime);
			
			addEvent($('stores'),'mouseover',this.stores_on);
			addEvent($('stores'),'mouseout',hidetime);
			addEvent($('newyork'),'mouseover',this.stores_on);
			addEvent($('newyork'),'mouseout',hidetime);
			addEvent($('costamesa'),'mouseover',this.stores_on);
			addEvent($('costamesa'),'mouseout',hidetime);
			addEvent($('lasvegas'),'mouseover',this.stores_on);
			addEvent($('lasvegas'),'mouseout',hidetime);
		},
		handbags_on : function() {
			show('handbags_sub');
		},
		aboutus_on : function() {
			show('aboutus_sub');
		},
		press_on : function() {
			show('press_sub');
		},
		stores_on : function() {
			show('stores_sub');
		}
	}

	


	
	
	
	
	
	function pageLoaders() {
		togglers.init();
	}
	
	addEvent(window,'unload',EventCache.flush);
	addEvent(window,'load',pageLoaders);