// JavaScript Document
$(document).ready(function(){
	$("body").addClass("has_js");
	$("#home a.programme_jump").each(function(){
		var hr = $(this).attr("href");
		ta = hr.split("/").reverse()[0];
		ta = ta.split(".")[0];
		$(this).attr("href", "#" + ta);
		
	});
	$("#home a.programme_jump").click(function(e){
		$(this).blur();
		hash = $(this).attr("href").split("#").reverse()[0];
		if($(this).hasClass("active")){
			return;
		}
		$("a.active").removeClass("active");
		$(this).addClass("active");
		t = $(this);
		if($("div.active").length > 0){
			$("div.active").fadeOut(500, function(){
				$(this).removeClass("active");
				t.parent().find(".programme_snippet").fadeIn(500,function(){
					$(this).parent().find(".programme_snippet").addClass("active");
				});
			});
		} else {
			t.parent().find(".programme_snippet").fadeIn(500,function(){
					$(this).parent().find(".programme_snippet").addClass("active");
			});
		}
		$(".language a").each(function(){
			$(this).attr("href", $(this).attr("href").split("#")[0] + "#" + hash);
		});
	});
	$("#home .programme_snippet").hide();
	$(".language a").each(function(){
		$(this).attr("href", $(this).attr("href").split("#")[0] + location.hash);
	});
	var hash = location.hash;
	if(hash.length > 1){
		prog = hash.substr(1);
	
		$("#home a.programme_jump").each(function(){
			if($(this).attr("href").split("#").reverse()[0] == prog){
				$(this).click();
			}
		});
	} 
	else
	{
		$("#home a.programme_jump:first").click();
	}
});
