/*********************
//* jQuery Drop Line Menu- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last updated: June 27th, 09'
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

var droplinemenu={

animateduration: {over: 150, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			if (!this.istopheader)
				$subul.css({left:0, top:this._dimensions.h})
			var $innerheader=$curobj.children('a').eq(0)
			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
			
			$curobj.click(	
			
				function(e){
					
					var $targetul=$(this).children("ul:eq(0)")
					
					// 	Make clicked menu item dark
					//$subul.toggleClass("clicked");
					
					//$curobj.addClass("clicked")
					
					
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						if (this.istopheader)
							$targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h})
						if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
							$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
						$targetul.slideDown(droplinemenu.animateduration.over)	
						
				},
				function(e){
					//$curobj.removeClass("clicked")
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(droplinemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
	}) //end document.ready
}
}


// easing animation stuff

  //document.documentElement.className += " js"; // Add js class to the HTML element
  $(function(){
    var $containers = $("#animators > div").hide();
    var $menus = $("#droplinetabs1 > div").hide();

	$('ul li a').each(function(i,el){
      var idx = i;
      $(this).click(function(e){
							 
		//$curobj.find('a:eq(0)').css("color", "#cfe5e4")
		
        var $target = $containers.filter(':eq(' + idx + ')');
		
		// Remove dark class from all menus (this is an ugly cluge, but the coffee is wearing off)
			$("#mpeople").removeClass("dark");
			$("#mrecent").removeClass("dark");
			$("#mwork").removeClass("dark");
			$("#mcontact").removeClass("dark");
			$("#mplaces").removeClass("dark");

		// If intro is visible, fade it out and the copyright footer
		if ( $('#intro').is(':visible')){
			$('#intro').fadeOut();
			$('#footer').fadeOut();
		}
        if($containers.filter(':visible').not($target).length){
        	$containers.filter(':visible').fadeOut();
        }
		if ( $target.is("#archive")) {
			$("#people").fadeIn();
			// Make people menu item dark to show selected menu item
			$("#mpeople").addClass("dark");
		}
		else {
		// Fade in new div if not already showing
        	$target.not(':visible').fadeIn();
			$(this).addClass("dark");
		}
        e.preventDefault();
      })
    })
  });

