
	$.navigation = 
	{
			currentTopic : {}
		,	build : function()
			{
				$(this).find("li").addClass("topic");
				$(this).find("li.luister-live").removeClass("topic").unbind("mouseenter").unbind("mouseleave");

				$.navigation.currentTopic = $(this).parent().find("li.active");
	
				$("li.topic", this).bind("mousedown", function(){ return false; });			
				$("li.topic", this).bind("mouseenter", function()
				{
					$("ul.topics").find("li").removeClass("active");
					
					$(this).find("li").removeClass("topic").unbind("mouseenter").unbind("mouseleave");

					if($.browser.msie && parseInt($.browser.version) == 6)
						$(this).addClass("active");

					var subObj = $(this).find("ul");

					if($.browser.msie && parseInt($.browser.version) == 6)
						subObj.css({ top:40, width:$.navigation.getSubWidth( subObj ), left:(subPos)  });

					if(subObj.get(0))
					{
						var	subWidth = ($.browser.msie && parseInt($.browser.version) == 6) ? 900 : 780;		
						var	topicPos = (($(this).get(0).offsetWidth/2)+$(this).get(0).offsetLeft);
						var	subPos = (topicPos - (subObj.get(0).offsetWidth / 2));
							subPos = (subPos > 5) ? subPos : 5;
							subPos = ((subPos + subObj.get(0).offsetWidth) > subWidth) ? (subWidth - subObj.get(0).offsetWidth) : subPos;

							subObj.css({ left:subPos, top:40, width:(subObj.get(0).offsetWidth+1) }).hide().fadeIn("slow");
					}
				});
				
				$("li.topic", this).bind("mouseleave", function()
				{
					//$(this).find("ul").css({ top:20 });
					$(this).find("ul").css({ top:-999 });

					$("ul.topics").find("li").removeClass("active");
					$.navigation.currentTopic.addClass("active");
				});
				
			//	$.navigation.setSearch();
			}
		
		,	getSubWidth : function( subObj )
			{
				var	subWidth = 0;
				$("li", subObj).each( function()
				{
					subWidth = subWidth + $(this).get(0).offsetWidth;
				});

				return subWidth;
			}
			
		,	openLivePlayer : function()
			{
				window.open('http://top2008.radio2.nl/page/08_player', 'player', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=no,width=575,height=330');
			}
			
		,	top2000quiz : function()
			{
				if($.registration.uid)
					window.open('http://www.kro.nl/fun/top2000quiz?uid='+$.registration.uid+'&name='+$.registration.username,'top2000quiz','width=800,height=600');
				else
					window.open('http://www.kro.nl/fun/top2000quiz/', 'top2000quiz','width=800,height=600');
			}
				
			/*
		,	setSearch : function()
			{
				$("a.searchNow").bind("click", function()
				{
					if($("input.searchQ").val())
						top.location.href="http://top2008.radio2.nl/page/08_zoeken/"+$("input.searchQ").val();
					
					return false;
				});
				
				$("a.searchNowBig").bind("click", function()
				{
					if($("input.searchQBig").val())
						top.location.href="http://top2008.radio2.nl/page/08_zoeken/"+$("input.searchQBig").val();
					
					return false;
				});
			}
			*/
		
		,	userLink : function(url, anchors)
			{
				if(!$.registration.uid)
				{
					top.location.href="http://top2008.radio2.nl/page/08_inloggen";
					return false;
				}
				
				if(anchors && $("div.tab-content").get(0) && $("ul.body-tabs").find("."+anchors.split("_")[1] ).get(0))
				{
					$.bodyTabs.setActiveTab( $("ul.body-tabs"), anchors.split("_")[1] );
					
					return false;
				}
				
				top.location.href=url+$.registration.uid+"/#"+anchors;
	
				return false;
			}
			
		,	preferences : function()
			{
				try
				{
					if(!$.registration.uid)
						top.location.href="http://top2008.radio2.nl/page/08_inloggen";
					else
						top.location.href="/page/08_instellingen";
				}
				catch(err)
				{
					$.navigation.log( "error", "redir - " + err);
				}	
	
				return false;
			}
			
		,	log : function( type, msg )
			{
				
				$.pbLog.debug( { title:"navigation", msgs : [{type:type, msg:msg }] } );
			}
	};
	
	$.fn.extend
	({
			navigation : $.navigation.build
	});