// JavaScript Document

var abstand;
var a;
var aktu_pos;

function groesse(){
	if(document.all){
		a=document.body.clientHeight;
		c=document.body.clientWidth;
		b = (a-650)/2;
		c = (c-1000)/2;
	}
	else{
		a=window.innerHeight;
		c=window.innerWidth;
		b = (a-650)/2;
		c = (c-1000)/2;
	}
	if(b>0) document.getElementById('main').style.top = b+"px";
	if(c>0) document.getElementById('main').style.left = c+"px";
	
	alert(b);
}

function getSpan(){
	if(document.all){
		a=document.body.clientHeight;
		c=document.body.clientWidth;
		b = (a-650)/2;
		c = (c-1000)/2;
	}
	else{
		a=window.innerHeight;
		c=window.innerWidth;
		b = (a-650)/2;
		c = (c-1000)/2;
	}
	
	if(b>0) var details = " top:"+b+"px; ";
	else var details = " top:0px; ";
	
	if(c>0) details += " left:"+c+"px; ";
	else details += " left:0px; ";
	
	return(details);
	
}



function load_img(pfad){
	
	abstand = ((a-650)/2)+40;
	document.getElementById('tablette').style.marginTop = abstand+"px";
	
	function test(){
			document.getElementById('container').src = img.src;
			document.getElementById('loader').innerHTML = "Der Photograf - Photogalerie";
	}
	
	var img = new Image();
	img.src = pfad;
	img.onLoad = test();

}

function show(pfad, index){
	aktu_pos = index;
	document.getElementById('galerie').style.visibility = "visible";
	load_img(pfad);
}
function hide(){
	document.getElementById('galerie').style.visibility = "hidden";
	document.getElementById('container').src = "";
	document.getElementById('loader').innerHTML = "Loading...";
	document.getElementById('container').src = "images/loading.gif";
}

function move(direction,arry){
	document.getElementById('container').src = "images/loading.gif";
	switch(direction){
		case "p":
		 aktu_pos--;
		 break;
		case "n":
		 aktu_pos++;
		 break;
	}
	if(aktu_pos>arry.length-1){
		aktu_pos = 0;
	}
	else if(aktu_pos==-1){
		aktu_pos = arry.length-1;	
	}
	show("img/galerie/"+arry[aktu_pos], aktu_pos);
}


function preload(pfad){
	var img = new Image();
	img.src = "img/"+pfad;
	done++;
	if(done==8)
	 setTimeout('linking()',4000);
}

function linking(){
	location.href = "main.php";	
}
