/*********************
//* 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={

arrowimage: {classname: 'downarrowclass', src: '/templates/aeinf/images/down.gif', leftpadding: 5}, //customize down arrow image
animateduration: {over: 100, out: 50}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid) {
	jQuery(document).ready(function($) {
		var $mainmenu = $("#"+menuid+">ul")
		$mainmenu.find("ul").addClass("sub")
		var $headers = $mainmenu.find("ul").parent();

		$headers.each ( function(i) {
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.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().eq(0).is('a') ? $curobj.children().eq(0).children().eq(0).children().eq(0) : $curobj.children().eq(0).children().eq(0);
            /*
			$innerheader.append(
				'<img src="'+ droplinemenu.arrowimage.src
				+'" class="' + droplinemenu.arrowimage.classname
				+ '" style="border:0; padding-left: '+droplinemenu.arrowimage.leftpadding+'px">'
			)
			*/
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")

					if ($targetul.queue().length<=1) { //if 1 or less queued animations
						if (this.istopheader)
							$targetul.css({left: $curobj.offset().left, top: $mainmenu.offset().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)
                    	//var w = 0;
						//$targetul.children("li").each ( function(i) { w = w > $(this).outerWidth()?w:$(this).outerWidth(); } )
						//w = $curobj.outerWidth() > w ? $curobj.outerWidth() : w;
						//$targetul.css({width: w })
					}
				},
				function(e){
					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'})

        var $lis = $mainmenu.find("li");
        $lis.each ( function(i) {
         	var $curobj=$(this)
			$curobj.hover(
				function(e){
					if($(this).parent().hasClass("sub"))
						$(this).parent().parent().addClass("hover")
					$(this).addClass("hover")
				},
				function(e){
					//if($(this).parent().hasClass("sub"))
					//	$(this).parent().parent().removeClass("hover")
					//else
						$(this).removeClass("hover")
				}
			) //end hover
        }) //end $headers.each()
	}) //end document.ready
}
}


