function show_full_pic(path, desc){
	scrollTo(0,0);
	create_elements();
	set_style();
	show_loader();
	load_image(path, desc);
}

function create_elements(){
	var back = document.createElement("div");	
	back.setAttribute("id", "gallery_back");
	
	
	var img_container = document.createElement("div");	
	img_container.setAttribute("id", "gallery_img_container");
	
	var img_loader = document.createElement("div");	
	img_loader.setAttribute("id", "gallery_loader_box");
	
	var full_image = document.createElement("img");	
	full_image.setAttribute("id", "gallery_full_image");
	full_image.onclick = close_full_image;
	
	var description = document.createElement("div");	
	description.setAttribute("id", "gallery_description");
	
	document.body.appendChild(back);
	document.body.appendChild(img_container);
	img_container.appendChild(full_image);
	img_container.appendChild(img_loader);
	img_container.appendChild(description);
}

function set_style(){
	// back
	var back_style = document.getElementById("gallery_back").style;
	back_style.position = 'absolute';
	back_style.top = '0px';
	back_style.left = '0px';
	back_style.width = '100%';
	back_style.height = document.getElementsByTagName('body')[0].scrollHeight+'px';
	back_style.opacity = '0.5';
	back_style.filter = 'alpha(opacity=50)';
	back_style.background = 'black';
	back_style.zIndex = '1000';
	
	// img container
	var img_container_style = document.getElementById("gallery_img_container").style;
	img_container_style.position = 'absolute';
	img_container_style.top = '50px';
	img_container_style.left = '50%';
	img_container_style.width = '200px';
	img_container_style.marginLeft = '-100px';
	img_container_style.background = 'white';
	img_container_style.zIndex = '1001';
	img_container_style.padding = '5px';
	img_container_style.minHeight = '200px';
	
	// gallery_loader_box
	var loader_box_style = document.getElementById("gallery_loader_box").style;
	loader_box_style.textAlign = 'center';
	loader_box_style.width = '100';
	loader_box_style.marginTop = '70px';

	// gallery_full_image
	var full_image_style = document.getElementById("gallery_full_image").style;
	full_image_style.cursor = 'pointer';
	full_image_style.display = 'none';

	// gallery_description
	var description_style = document.getElementById("gallery_description").style;
	description_style.marginTop = '10px';
	description_style.textAlign = 'left';
	description_style.color = '#333';
}

function show_loader(){
	document.getElementById("gallery_loader_box").innerHTML = "<img src='bilder/layout/loader.gif' />";
}

function load_image(path, desc){
	var img_path = path;
	var image = new Image();

	image.onload = function() {
		document.getElementById("gallery_loader_box").style.display = "none";
		document.getElementById("gallery_img_container").style.width = image.width+"px";
		document.getElementById("gallery_img_container").style.marginLeft = "-"+image.width/2+"px";
		show_image(path);
		show_desc(desc);
	}

	image.src = img_path;	
}

function show_image(path){
	document.getElementById("gallery_full_image").src = path;
	document.getElementById("gallery_full_image").style.display = "inline";
}

function show_desc(desc){
	if(desc == ""){
		document.getElementById("gallery_description").style.display = "none";
	}else{
		document.getElementById("gallery_description").innerHTML = desc;
		document.getElementById("gallery_description").style.display = "block";
	}
	
}

function close_full_image(){
	document.body.removeChild(document.getElementById("gallery_back"));
	document.body.removeChild(document.getElementById("gallery_img_container"));
}