$.noConflict();
jQuery(document).ready(function($) {
								
	$('#jsmenu').show();
	$(this).addClass('sfHover' );
	
	var ItemNum=$('#menu li.title').size();
	if (ItemNum==5){
		$('#menu li.title').addClass('fiveCol');	
	}

function megaHoverOver(){	
	$(this).find(".sub").stop().fadeTo(99, 1).show();
	$("select").blur();
	var mDD = $(this).find(".sub");
	
	if(mDD.children().size()>0){
		$("#navFrame").stop().fadeTo(99, 1).show();
		var menuItemLeft=$(this).position().left;
		var menuItemRight=menuItemLeft+$(this).width();			
		var menuWidth=$('#menu').width();		
		var borderWidth=parseInt($('#menu').css("borderLeftWidth"), 10 )+parseInt($('#menu').css("borderRightWidth"), 10 );
		menuWidth +=borderWidth;	
		var menuCenter=menuWidth/2-(borderWidth/2);
		var colmnNum=$(this).find(".sub li div").size();
		var columnWidth=$(this).find(".sub li div").width();
		var w =colmnNum*columnWidth;		
		w +=parseInt($(this).find(".sub li div").css("margin-left"), 10) + parseInt($(this).find(".sub li div").css("margin-right"), 10)*(colmnNum) ;
		mDDWidth=w;			
		w+=parseInt(mDD.css("padding-left"), 10) + parseInt(mDD.css("padding-right"), 10);	
		w +=parseInt(mDD.css("borderLeftWidth"), 10 )+parseInt(mDD.css("borderRightWidth"), 10 );	
		mDDTotalWidth=w;
		mDDLeft=parseInt(menuCenter-(mDDTotalWidth/2));			
		
	   $(this).find(".sub").css('margin-left','0px'); 
	   $("#navFrame").css('margin-left','0px'); 
	   
		if(mDDLeft > menuItemLeft || (menuItemLeft-mDDLeft)<15){	
		  mDDLeft=menuItemLeft;
		 $(this).find(".sub").css('margin-left','8px');	
		 $("#navFrame").css('margin-left','8px');
		}
		var mDDRight=mDDLeft+mDDTotalWidth;	
		
		if (mDDRight< menuItemRight ) {		
			 mDDLeft=mDDLeft+(menuItemRight-mDDRight);	
		  
		}
		
		$(this).find(".sub").css('width',mDDWidth);		 
	    $(this).find(".sub").css('left',mDDLeft);
	    $(this).addClass('sfHover' );	
		var mHeight=mDD.height();
		var mTop=mDD.position().top;
		
		$("#navFrame").css('width',mDDTotalWidth);
		$("#navFrame").css('left',mDDLeft);
		$("#navFrame").css('top',mTop);
		mHeight+=parseInt(mDD.css("padding-top"), 10) + parseInt(mDD.css("padding-bottom"), 10);
		$("#navFrame").css('height',mHeight);	
			
	}
		
	
}
	
function megaHoverOut(){ 	 
	  $(this).find(".sub").stop().fadeTo(99, 0, function() {
		  $(this).hide(); 
	  });	  
	  $("#navFrame").stop().fadeTo(99, 0, function() {
		  $("#navFrame").hide();
	  });
	  
	   $(this).removeClass('sfHover' );
	}

	var config = {    
		 sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)    
		 interval:100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#menu li .sub").css({'opacity':'0'});	
	$("#navFrame").css({'opacity':'0'});	
	$("ul#menu li.title").hoverIntent(config);	
	
	
});
