
function thisPicture(file) {
	
	var splitSource = file.split("/");
	var key;
	
	for (i in files) {
		if (files[i] == splitSource[3])
			key = parseInt(i);
	}
	
	var previous = key-1;
	var next = key+1;
	
	if (key == files.length-1)
		next = 0;
	if (key == 0)
		previous = files.length-1;
	
	var img = new Image();
	document.getElementById('loader').style.display = "block";
	var source = file;
	img.onload = function() {
		document.getElementById("bildercontainer").innerHTML = "<div class='pfeil' id='nextL'>" +
		"<a href=\"javascript:thisPicture(\'" + splitSource[0] +
		"/" + splitSource[1] +
		"/" + splitSource[2] + "/" + files[previous] + "\')\"><img src='img/Layout/blank.gif' width='50' height='50' /></a></div>" +
		"<div class='pfeil' id='nextR'>" +
		"<a href=\"javascript:thisPicture(\'" + splitSource[0] + "/" +
		splitSource[1] + "/" +
		splitSource[2] + "/" + files[next] + "\')\"><img src='img/Layout/blank.gif' width='50' height='50' /></a></div>" +
		"<div id=\"gross\">" +
		"<img src='" + file + "' alt='" + file + "' />" +
		"</div>";
		
		
		var bubs = document.location.href;
		var unterlinks = document.getElementById('unterlinks');
		var photoEvent = splitSource[2];
		unterlinks.innerHTML = "<a href=\"?section=bilder\">bilder</a> &gt; <a href=\"?section=bilder&amp;event=" + photoEvent +
		"\">" + photoEvent +
		"</a> &gt; <a href='#" + splitSource[3] +
		"' id='active'>" + splitSource[3] + "</a>";
		
		document.getElementById('loader').style.display = "none";
	};
	img.src = source;
	document.location.hash = splitSource[3];
};

function hashPictures() {
	if (document.location.hash && document.location.href.indexOf("event") != -1) {
		var bubsi = document.location.href;
		var hash = bubsi.split("#");
		thisPicture("Bilder/events/" + bubsi.substring(bubsi.indexOf("event")+6,bubsi.indexOf("#")) + "/" + hash[1]);
	}	
};
