$(document).ready(function(){
	$("div#box").bind("mouseenter",function(){
		$(".description, .next, .prev").fadeIn("fast");
	}).bind("mouseleave",function(){
		$(".description, .next, .prev").fadeOut("fast");
	});
	$(".next, .prev").bind("mouseenter",function(){
		$(".description").fadeOut("fast");
	}).bind("mouseleave",function(){
		$(".description").fadeIn("fast");
	});
	var hash = window.location.hash.substr(1);
	var href = $('.description a').each(function() {
        var href = $(this).attr('href');
		var act = $(this).attr('href').substring(0, $(this).attr('href').indexOf("?"));
        if(hash==$(this).attr('href').substring($(this).attr('href').indexOf("=") + 1)){
            var toLoad = act+'?project='+hash;
			$('#holder').ajaxError(function() {
				$(this).html('<img src="gfx/update.jpg" width="880" height="440" alt="Coming soon" />');
			});
            $('#holder').load(toLoad)
			check();
        }
    });
	$('.description a').click(function() {					  
		// var toLoad = $(this).attr('href')+' #holder';
		var toLoad = $(this).attr('href');
		$('.loader').fadeIn('normal');		
		window.location.hash = $(this).attr('href').substring($(this).attr('href').indexOf("=") + 1);
		$('#holder').ajaxError(function() {
			$(this).html('<img src="gfx/update.jpg" />');
		});
		$('#holder').load(toLoad,'',showNewContent());
		check();
		function showNewContent() {
			$('#holder').show('normal',hideLoader());
		}
		function hideLoader() {
			$('.loader').fadeOut("normal");
		}
		return false;
	});
	if(!window.location.hash) {
		$('.description a:first').click();
	}
	function check() {
		var hash = window.location.hash.substr(1);
		var href = $('.description a').each(function(){
			$(this).removeClass("active-option");
        	var href = $(this).attr('href');
        	if(hash==$(this).attr('href').substring($(this).attr('href').indexOf("=") + 1)){
           		$(this).addClass("active-option");
            }
		});
	}	
});