Hello,

I found jkmegamenu (http://www.javascriptkit.com/script/...megamenu.shtml) beneficial for my website.

As there is a delay time for hiding the menu by default, however I could not succeed for the required modification to set an delay time prior to popup the menu.

I paste the code below and marked the part that I know to set something for the delay for mouse enter, in red.

I need your advice for the modification needed to be able to apply the same delay time prior to pop up the menu.

Thanks.

Code:
jQuery.noConflict();

var jkmegamenu={

effectduration: 0, //duration of animation, in milliseconds
delaytimer: 300, //delay after mouseout before menu should be hidden, in milliseconds

//No need to edit beyond here
megamenulabels: [],
megamenus: [], //array to contain each block menu instances
zIndexVal: 1000, //starting z-index value for drop down menu
jqshimobj: null,

addshim:function(jq){
	jq(document.body).append('<IFRAME id="outlineiframeshim" src="'+(location.protocol=="https:"? 'blank.htm' : 'about:blank')+'" style="display:none; left:0; top:0; z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
	this.jqshimobj=jq("#outlineiframeshim")
},

alignmenu:function(jq, e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var jqanchor=megamenu.jqanchorobj
	var jqmenu=megamenu.jqmenuobj
	var menuleft=(jq(window).width()-(megamenu.offsetx-jq(document).scrollLeft())>megamenu.actualwidth)? megamenu.offsetx : megamenu.offsetx-megamenu.actualwidth+megamenu.anchorwidth //get x coord of menu
	//var menutop=(jq(window).height()-(megamenu.offsety-jq(document).scrollTop()+megamenu.anchorheight)>megamenu.actualheight)? megamenu.offsety+megamenu.anchorheight : megamenu.offsety-megamenu.actualheight
	var menutop=megamenu.offsety+megamenu.anchorheight  //get y coord of menu
	jqmenu.css({left:265+"px", top:menutop-85+"px"})
	this.jqshimobj.css({width:megamenu.actualwidth+"px", height:megamenu.actualheight+"px", left:menuleft+"px", top:menutop+"px", display:"block"})
},

showmenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var jqmenu=megamenu.jqmenuobj
	var jqmenuinner=megamenu.jqmenuinner
	if (jqmenu.css("display")=="none"){
		this.alignmenu(jQuery, e, megamenu_pos)
		jqmenu.css("z-index", ++this.zIndexVal)
		jqmenu.show(this.effectduration, function(){
			jqmenuinner.css('visibility', 'visible')
		})
	}
	else if (jqmenu.css("display")=="block" && e.type=="click"){ //if menu is hidden and this is a "click" event (versus "mouseout")
		this.hidemenu(e, megamenu_pos)
	}
	return false
},

hidemenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var jqmenu=megamenu.jqmenuobj
	var jqmenuinner=megamenu.jqmenuinner
	jqmenuinner.css('visibility', 'hidden')
	this.jqshimobj.css({display:"none", left:0, top:0})
	jqmenu.hide(this.effectduration)
},

definemenu:function(anchorid, menuid, revealtype){
	this.megamenulabels.push([anchorid, menuid, revealtype])
},

render:function(jq){
	for (var i=0, labels=this.megamenulabels[i]; i<this.megamenulabels.length; i++, labels=this.megamenulabels[i]){
		if (jq('#'+labels[0]).length!=1 || jq('#'+labels[1]).length!=1) //if one of the two elements are NOT defined, exist
			return
		this.megamenus.push({jqanchorobj:jq("#"+labels[0]), jqmenuobj:jq("#"+labels[1]), jqmenuinner:jq("#"+labels[1]).children('ul:first-child'), revealtype:labels[2], hidetimer:null})
		var megamenu=this.megamenus[i]	
		megamenu.jqanchorobj.add(megamenu.jqmenuobj).attr("_megamenupos", i+"pos") //remember index of this drop down menu
		megamenu.actualwidth=megamenu.jqmenuobj.outerWidth()
		megamenu.actualheight=megamenu.jqmenuobj.outerHeight()
		megamenu.offsetx=megamenu.jqanchorobj.offset().left
		megamenu.offsety=megamenu.jqanchorobj.offset().top
		megamenu.anchorwidth=megamenu.jqanchorobj.outerWidth()
		megamenu.anchorheight=megamenu.jqanchorobj.outerHeight()
		jq(document.body).append(megamenu.jqmenuobj) //move drop down menu to end of document
		megamenu.jqmenuobj.css("z-index", ++this.zIndexVal).hide()
		megamenu.jqmenuinner.css("visibility", "hidden")
		megamenu.jqanchorobj.bind(megamenu.revealtype=="click"? "click" : "mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
			return jkmegamenu.showmenu(e, parseInt(this.getAttribute("_megamenupos")))
		})
		megamenu.jqanchorobj.bind("mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			if (e.relatedTarget!=menuinfo.jqmenuobj.get(0) && jq(e.relatedTarget).parents("#"+menuinfo.jqmenuobj.get(0).id).length==0){ //check that mouse hasn't moved into menu object
				menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
					jkmegamenu.hidemenu(e, parseInt(menuinfo.jqmenuobj.get(0).getAttribute("_megamenupos")))
				}, jkmegamenu.delaytimer)
			}
		})
		megamenu.jqmenuobj.bind("mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
		})
		megamenu.jqmenuobj.bind("click mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
				jkmegamenu.hidemenu(e, parseInt(menuinfo.jqmenuobj.get(0).getAttribute("_megamenupos")))
			}, jkmegamenu.delaytimer)
		})
	} //end for loop
	if(/Safari/i.test(navigator.userAgent)){ //if Safari
		jq(window).bind("resize load", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]
				var jqanchorisimg=(megamenu.jqanchorobj.children().length==1 && megamenu.jqanchorobj.children().eq(0).is('img'))? megamenu.jqanchorobj.children().eq(0) : null
				if (jqanchorisimg){ //if anchor is an image link, get offsets and dimensions of image itself, instead of parent A
					megamenu.offsetx=jqanchorisimg.offset().left
					megamenu.offsety=jqanchorisimg.offset().top
					megamenu.anchorwidth=jqanchorisimg.width()
					megamenu.anchorheight=jqanchorisimg.height()
				}
			}
		})
	}
	else{
		jq(window).bind("resize", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]	
				megamenu.offsetx=megamenu.jqanchorobj.offset().left
				megamenu.offsety=megamenu.jqanchorobj.offset().top
			}
		})
	}
	jkmegamenu.addshim(jq)
}

}

jQuery(document).ready(function(jq){
	jkmegamenu.render(jq)
})