	
	
	/*
		Plugin :  Navigation
		Description : Navigation bar with dropdown menus
		Author : Dennis Laupman - (dennis[at]pluxbox.nl)
		Created : 16/09/2008
		
		CHANGES
		16/09/2008 - 14:38 | Dennis
		Total rewrite! Hover generation for IE
		
		08/11/2008 - 17:06 | Dennis
		Bugfix for IE(6)
		
		08/11/2008 - 21:03 | Dennis
		Repositioning last Pulldown menu
		
		08/11/2008 - 21:03 | Dennis
		Repositioning last Pulldown menu
	*/
	
	$.navigation =
	({
	 		activeItem : null
		,	subMenu : 0
		,	build : function( )
			{
				try
				{
					var subWidth = 275;
					var pObj = $(this);
					
					$.navigation.activeItem = $(this).find(".active");
					
					$("li", this).addClass("topic").find("li").removeClass("topic");
					
					$("li.topic", this).unbind("mouseenter").bind("mouseenter", function()
					{
						var	gObj = $(this).get(0);
						
						if($(this).get(0) && $(this).get(0).sT)
							clearTimeout($(this).get(0).sT);
						
						if($.navigation.subMenu)
							$.navigation.subDelay( $.navigation.subMenu );
				
						$.navigation.subMenu = $(this);
						
						if(!gObj.pos)
							gObj.pos = {w : gObj.offsetWidth , h : gObj.offsetHeight, x : gObj.offsetLeft, y : gObj.offsetTop };
	
						if((gObj.pos.w+(gObj.pos.x+subWidth)) > 940)
							$(this).find("ul").css( { left : ((gObj.pos.x+gObj.pos.w)-subWidth) } );
				
						$.navigation.activeItem.removeClass("active");
						$(this).addClass("hover").find("ul").show();
					});
					
					
					$("li.topic", this).unbind("mouseleave").bind("mouseleave", function()
					{
						if(!$(this).find("ul").get(0))
						{
							$(this).removeClass("hover");
							$.navigation.activeItem.addClass("active");
						}
						else
						{
							var	pObj = $(this);
							
							$(this).get(0).sT = setTimeout( function()
							{
								$.navigation.subDelay( pObj );
								$.navigation.activeItem.addClass("active");
							}, 500);
						}
					});
					
					
					/*
					$("li.topic", this).find("ul").unbind("mouseleave").bind("mouseleave", function()
					{
						var	pObj = $(this).parent();
						
						$(this).get(0).sT = setTimeout( function()
						{
							$.navigation.subDelay( pObj );
						}, 500);
					});
					*/
					
					$.navigation.log( "info", "Class \"navigation\" wordt geladen");
				}
				catch(err)
				{
					$.navigation.log( "error", "Class \"navigation\" wordt NIET geladen - " + err);
				}	
			}
			
		,	subDelay : function( obj )
			{
				obj.removeClass("hover").find("ul").css( { display:"none" } ); 
			
				return;
			}
			
		,	log : function( type, msg )
			{
				//Tijdelijk it omdat het log script niet geinclude
				//$.pbLog.debug( { title:"navigation", msgs : [{type:type, msg:msg }] } );
			}
	});
	
	$.fn.extend
	({
		navigation : $.navigation.build
	});
	
