// ------------------------------------------------------------------------------
// Copyright 2010 (c) BIZAMAJIG
// Version: 2.3.0
// ------------------------------------------------------------------------------

//<![CDATA[
<!--
var bzmjg_ui_menu_dropline={

// referenct to down arrow image to queue user there are submenu items
arrowimage: {classname: 'downarrowclass', src: '/resources/bizamajig/art/down.gif', leftpadding: 7}, //customize down arrow image

// duration in ms of slide up/down animation
animateduration: {watch_mouseover: 200, watch_mouseout: 100}, 

// render the menu markup
bzmjg_ui_render_menu_dropline:function(div_menu_id) {
	jQuery(document).ready(function($) {
		var $mainmenu=$("#"+div_menu_id+">ul");
		var $items=$mainmenu.find("ul").parent();

// START TRAIL MANAGEMENT
		$("#"+div_menu_id+" li.current").children("ul").css("left", "0px").show(); // show selection
		$("#"+div_menu_id+" li.current").children(":first-child").css("background-color", "#79a7c8"); // set background-color for selection
// END TRAIL MANAGEMENT

		$items.each(function(i) {
			var $current_object=$(this);
			var $child_ul=$(this).find('ul:eq(0)');
			this._dimensions={h:$current_object.find('a:eq(0)').outerHeight()};
			this.top_level_item=$current_object.parents("ul").length==1? true : false;
			if (!this.top_level_item) {
				$child_ul.css({left:0, top:this._dimensions.h});
			}
			var $inner_item=$current_object.children('a').eq(0);
			$inner_item=($inner_item.children().eq(0).is('span'))? $inner_item.children().eq(0) : $inner_item; // use SPAN of inner item
			$inner_item.append(
				'<img src="'+ bzmjg_ui_menu_dropline.arrowimage.src
				+'" class="' + bzmjg_ui_menu_dropline.arrowimage.classname
				+ '" style="border:0; padding-left: '+bzmjg_ui_menu_dropline.arrowimage.leftpadding+'px" />'
			);
			$current_object.click(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					if ($targetul.queue().length<=1) { // if 1 or less queued animations
						if (this.top_level_item) {
							$targetul.css({left: $mainmenu.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.top_level_item)? 'hidden' : 'visible'});
					}
					$targetul.slideDown(bzmjg_ui_menu_dropline.animateduration.watch_mouseover);
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(bzmjg_ui_menu_dropline.animateduration.out)
				}
			), //end hover
			$current_object.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(bzmjg_ui_menu_dropline.animateduration.out)
				}
			) //end hover
		}); // end $items.each()

// START TRAIL MANAGEMENT
		$("#"+div_menu_id+" li").hover(
//
//	Set colors to selected state, walking forward on the trail.
//
			function() {
				if(this.className.indexOf("current") == -1) {
					getCurrent = $(this).parent().children("li.current:eq(0)");
					if(this.className.indexOf("top") != -1) {
						$(this).children("a:eq(0)").css("color","#000000"); // top-level li - selected color
//						$(this).children("a:eq(0)").css("background-color","#999999"); // top-level li - selected background-color
						$(this).children("a:eq(0)").css("background-color","#959CA1"); // top-level li - selected background-color
					}
					else {
						$(this).children("a:eq(0)").css("color","#000000");
					}
//	Don't need to manage visibility here, only css changes
//					if (getCurrent = 1 ) {
//						$(this).parent().children("li.current:eq(0)").children("ul").hide();
//					}
//					$(this).children("ul:eq(0)").css("left", "0px").show();
				}
			},
//
//	Reset colors to default state, covering up tracks behind our walking along the trail.
//
			function() {
				if(this.className.indexOf("current") == -1) {
					getCurrent = $(this).parent().children("li.current:eq(0)");
					if(this.className.indexOf("top") != -1) {
						$(this).children("a:eq(0)").css("color","#ffffff"); // top-level li - default color
//						$(this).children("a:eq(0)").css("background-color","#cccccc"); // top-level li - default background-color
						$(this).children("a:eq(0)").css("background-color","#b2b7bb"); // top-level li - default background-color
					}
					else {
						$(this).children("a:eq(0)").css("color","#ffffff"); // reset sub-level li menu items to default color
					}
//	Don't need to manage visibility here, only css changes
//					if (getCurrent = 1 ) {
//						$(this).parent().children("li.current:eq(0)").children("ul").show();
//					}
//					$(this).children("ul:eq(0)").css("left", "-99999px").hide();
				}
			}
		);
// END TRAIL MANAGEMENT



		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()});
	}); //end document.ready
}
}

//-->
//]]>

