$(document).ready(function(){

	var activeHover;
	//setup drop downs = = = = = = = = = = = = = = = = = = = = = = 
	
	$('.dropper').addClass('active2');
	$('.shadowmask').each(function(){
		$(this).width(($(this).parents('.dropper').first().outerWidth()-16));
	});
	$('.dropper').removeClass('active2');
	$('.dropdown').hide();
	
	$(document).mouseleave(function(event){
		removeDropDown('left document');
	});
	$('.dropper').bind('mousedown mouseover', function(event){	
		if(this!=activeHover){
			removeDropDown('mousedown/over ');
			$('#submenu'+(this.id.replace(/[^0-9]+/,''))).show();
			$(this).addClass('active2');
			activeHover=this;
		}
	});
	$('.dropdown').mouseleave(function(event) {
		//need to stop this if I've just entered the triggering button??
		removeDropDown('left dropdown');
	});
	$('.dropper').mouseleave(function(event){
		if(event.pageY<140){
			removeDropDown('left above');
		}
	});
	
	function removeDropDown(reason){
		$('.dropdown').hide();
		if(activeHover){
			$(activeHover).removeClass('active2');
			activeHover='';
			//console.log('removed '+reason);
		}	
	}
	
	// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
});
