

	$(document).bind("ready", function()
	{
		$("ul.tabs").tabs("http://www.omroep.nl/radio2/live64.asx");
	});
	
	$.tabs =
	({
			lpTimer : 0
		,	daletTimer : 0
		,	build : function ( activeStream )
			{
				$.tabs.lpTimer = setTimeout( function()
				{
					$("div.player").html("<EMBED TYPE=\"application/x-mplayer2\" SRC=\""+activeStream+"\" WIDTH=\"295\" HEIGHT=\"68\" AUTOSTART=\"1\" SHOWCONTROLS=\"1\" ShowStatusBar=\"1\" showdisplay=\"0\"></EMBED>");
				}, 1000);
				
				getDaletInfo();
				
				$.tabs.daletTimer = setInterval( function()
				{
					getDaletInfo();
				}, 10000);
			
				$("div.footerColumn a").bind("click", function(){ return $.tabs.openLink( $(this).attr("href") ); });
				$("div.tabsMoreInfo a").bind("click", function(){ return $.tabs.openLink( $(this).attr("href") ); });
				
				$("span.link a").bind("mousedown", function(){ return false; });
				$("span.link a").bind("click", function(){ return $.tabs.openLink( $(this).attr("href") ); });
				$("a.logoLink").bind("click", function(){ return $.tabs.openLink( $(this).attr("href") ); });
				$("span.linkTo a").bind("click", function(){ return $.tabs.openLink( $(this).attr("href") ); });
				
				var	tabObj = $(this);
				
				$("li a", this).bind("click", function()
				{
					/** CLEAR PLAYER TIMER **/
					clearTimeout($.tabs.lpTimer);
					
					/** MANAGE TABS **/
					$("li", tabObj).removeClass("active");
					$(this).parent().addClass("active");
					
					var	activeTab = $(this).attr("href").split("#");
					
					/** MANAGE CONTENT **/
					$("div.content div").hide();
					$("div.content").find("."+activeTab[0]).show();
					
					
					/** MANAGE TAB CONTENT **/
					$("div.tabsContent div").hide();
					$("div.tabsContent").find("."+activeTab[0]).show();
					
					/** MANAGE TAB FOOTER LINK **/
					$("div.tabsMoreInfo a").attr("href", activeTab[3]);
					
					
					//$("a.tabsMoreInfo").attr("href", );
					
					/** SET TABS FOOTER **/
					$("div.tabsFooter").html(activeTab[1]);
					
					/** SET PLAYER **/
					$.tabs.lpTimer = setTimeout( function()
					{
						$("div.player").html("<EMBED TYPE=\"application/x-mplayer2\" SRC=\""+activeTab[4]+"\" WIDTH=\"295\" HEIGHT=\"68\" AUTOSTART=\"1\" SHOWCONTROLS=\"1\" ShowStatusBar=\"1\" showdisplay=\"0\"></EMBED>");
					}, 1000);
					
					/** SET CONCERT STREAMS **/
					$("select.streams").bind("change", function()
					{
						var stream = $(this).val();
						$.tabs.lpTimer = setTimeout( function()
						{
							$("div.player").html("<EMBED TYPE=\"application/x-mplayer2\" SRC=\""+stream+"\" WIDTH=\"295\" HEIGHT=\"68\" AUTOSTART=\"1\" SHOWCONTROLS=\"1\" ShowStatusBar=\"1\" showdisplay=\"0\"></EMBED>");
						}, 1000);
					});
					
					return false;
				});
			}
			
		,	openLink : function( url )
			{
				if(url.indexOf("mailto") == -1)
					window.open(url, "blank_window", "width=800,height=600,scrollbars=yes,toolbar=yes,location=yes, resizable=yes")
					//window.open(url, "blank_photo","scrollbars=auto, resizable=yes, toolbar=yes, status=yes, width=800, height=600 ");
				else
					location.href = url;
				
				return false;
			}
	});
	
	$.fn.extend
	({
			tabs : $.tabs.build
	});
	

	