$(document).ready(function(){
	
	setInterval("detijd()",5000);
	
	$(".link").livequery("click",function(){
		l = $(this).attr("l");
		if(l!=""){
			content(l);
			window.location.hash = l;
		}
	});
	
	$(".duimnagel").livequery("click",function(){
		id = $(this).attr("id");
		openproject(id);
		$(".container").scrollTo(0);
		window.location.hash = "item/"+id;
	});
	
	if(hashf(0)!="-" && hashf(1)!="-"){
		if(hashf(0)=="item" && hashf(1)!="-"){
			openproject();
		} else {
			$(".link[l='"+hashf(0)+"']").click();
		}
	} else { 
		$(".link[l='intro']").click();
	};
	
	$(".frame").width($(window).width()-120);
	
	$(".random").livequery("click",function(){
		$(".link[l='intro']").click();
	})	
})

function hashf(slash){
	hash = window.location.hash;
	hash = hash.split("#");
	if(hash[1]){
		hash = hash[1];
		hash = hash.split("/");
		if(hash[slash]!="" || hash[slash]!="UNDEFINED"){
			return hash[slash];
		} else {
			return "-";
		}
	} else {
		return "-";
	}
}

function detijd(){
	var d = new Date();
	$(".link").each(function(){
		if($(this).attr("l")=="bstn_info"){
			$(this).load("ajax.php",{"f":["bstn"]})
		}
	})
}

function getHex(dec){

	var hexArray = new Array( "0", "1", "2", "3", 
	                          "4", "5", "6", "7",
	                          "8", "9", "A", "B", 
	                          "C", "D", "E", "F" );

 


	var code1 = Math.floor(dec / 16);
	var code2 = dec - code1 * 16;


	var decToHex = hexArray[code2];


	return (decToHex);
}

function content(l){
	$(".content").load("ajax.php",{"f":[l]});
}

function openproject(id){
	$(".content").load("ajax.php",{"f":["project"],"id":[id]});	
}
