
var $j = jQuery.noConflict();

//maak links voor alle menudingen
$j(document).ready(function()
{
	
	//let all a elements lose their focus
	$j("a").focus( function() { $j("a").blur(); } );
	$j("area").focus( function() { $j("area").blur(); } );
	
	$j(".j_harmonica").children("li").children("a").each(function(i)
	{	
		if( $j(this).attr("class") != "selected" )
		{
			$j(this).parent().find("ul").hide();
		}
		$j(this).click(function(e)
		{
			//rest of menu
			$j(".j_harmonica").children("li").children("a").each(function(i)
			{
				$j(this).removeClass("selected");
				$j(this).parent().find("ul").slideUp("fast");
			});
			//selected
			$j(this).addClass("selected");
			$j(this).parent().find("ul").slideDown("slow");
			return false;
		});
		//change img
		$j(this).parent().find("ul").children("li").children("a").each(function(i)
		{
			$j(this).click(function(e)
			{
				var href = $j(this).attr("href");

				$j.getJSON( $j(this).attr('href') + "&JSON", function(data)
				{
					$j(".pdf_links").fadeOut("fast");
					$j("#route_img").fadeOut("fast",function()
					{
						if( data.r.image != "undefined" || data.r.image != '' )
							$j("#route_img").attr("src", data.r.image );
						
						if( data.r.imp == "undefined" || data.r.imp == ''  )	
							$j("#schedule_import").hide();
						else
						{
							$j("#schedule_import").attr("href", data.r.imp );
							$j("#schedule_import").show();
						}
						if( data.r.exp == "undefined" || data.r.exp == ''  )	
							$j("#schedule_export").hide();
						else
						{
							$j("#schedule_export").attr("href", data.r.exp );
							$j("#schedule_export").show();
						}
						
						$j("#schedule_extra").empty();
						if( data.r.extra != "undefined" || data.r.extra != '' )
						{
							$j("#schedule_extra").append( data.r.extra );
							$j("#schedule_extra").show();
						}
						
					});
					$j("#route_img").fadeIn("slow");
					$j(".pdf_links").fadeIn("slow");

					
				});
				

				return false;
			});
		});
	});
});

function route( x )
{
	document.getElementById('route_img').src = 'img/' + x;
}
