$(document).bind("ready", function(){
	
	$('body').addClass("javascript");
	
	$('div.video div.item').bind("click", function(){
		window.location.hash = $(this).find("a:first").attr("href").replace("/videos/", "");
		$('div.videofile:not(' + window.location.hash + ')').css("display", "none");
		$('div.videofile' + window.location.hash).css("display", "block");
		
		$(this).parent().find(".selected").removeClass("selected").each(function(){
			$(this).find("small").html($(this).find("small").attr("time"));
		});
		
		$(this).addClass("selected").each(function(){
			$(this).find("small").attr("time", $(this).find("small").html()).html("Now Playing");
		});
		
		return false;
	}).find("a").bind("click", function(){
		$(this).parent().click();
		return false;
	});
	
	$('div.content.video').each(function(){
										
		if(window.location.hash){
			hash = "/videos/" + window.location.hash.replace("#", "");
			$('a[href='+hash+']').parent().click();
		}
		
	});
	
	$('.font').click(function(){
		$('body').css("font-size", $(this).css("font-size"));
		$.get("/library/font-size.php", { 'font-size':$(this).css("font-size") });
		return false;
	});
	
	$('.news-link').live("click", function(){
		window.location.href = $(this).find('a:last').attr("href");
	}).hover(function(){
		$(this).css("cursor", "pointer");
		$(this).find("a:last").css("color", "#3b1e78");
	}, function(){
		$(this).find("a:last").css("color", "#9e289b");
	});
	
	$('.search').bind("focus", function(){
		if($(this).val() == "Search..") $(this).val("");
	});
	
	$('.search').bind("blur", function(){
		if($(this).val() == "") $(this).val("Search..");
	});

});