
/// detect navigator and modify last menus offset */
/*If you have different number of items in the menu you will have to modify the offset of the submenu layers depending on each browser*/
if ((screen.width==1024)) {

	if (navigator.appName == 'Netscape') {

			var offsetLastMenu1 = 125;
			var offsetLastMenu2 = 2;
	}

	else if (navigator.appName.indexOf('Explorer')) {

		var offsetLastMenu1 = 0;
		var offsetLastMenu2 = 0;
	}

}

else 


if (navigator.appName == 'Netscape') {

		var offsetLastMenu1 = 125;
		var offsetLastMenu2 = 112;
	}

else if (navigator.appName.indexOf('Explorer')) {


	var offsetLastMenu1 = 101;
	var offsetLastMenu2 = 88;
	}



var lastMenuId1 = 'lastMenu1';
var lastMenuId2 = 'lastMenu2';

var jqueryslidemenu={

animateduration: {over: 1, out: 1}, //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)')
			//alert(this.id == 'lastLi');
			//var offsetIE =(isExplorer()?2:0);
			var offsetIE =(isExplorer()?2:0);
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight-offsetIE, subulw:$subul.outerWidth(),subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})

			$curobj.hover(
				function(e){

					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					//Right Menu Correction
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft

					//patch to solve last menu options
					if(lastMenuId1==this.id) {menuleft-=offsetLastMenu1;};
					if(lastMenuId2==this.id) {menuleft-=offsetLastMenu2;};

					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="carRange" on page:
jqueryslidemenu.buildmenu("carRange")