function setOpacity(obj,value) {
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}

function imageList() {
	var imgArr=Array();
	var count=0;
	var current=0;
	var currentObj=null;
	
	var start_left = 75;
	var start_top = 35;
	var container_w = 441;
	var container_h = 295;
	
	var timeoutOut = 10;
	var timeoutIn = 0;
	
	var slideshow = 4; // in s
	var fadeTime = 300; // in ms
	
	var slideshow_turn = 0;
	
	this.add = function(s,w,h,d) {
		obj=document.createElement("img");
		obj.src=s;
		obj.alt=d;		
		
		obj.style.position='absolute';
		obj.style.height=h+'px';
		obj.style.width=w+'px';
		obj.style.display="none";
		
		setOpacity(obj,0);
		
		//if (w < container_w)
		obj.style.left = (start_left+(container_w-w)/2)+'px';
		//if (h < container_h)
		obj.style.top = (start_top+(container_h-h)/2)+'px';
		document.getElementById("myGallery").appendChild(obj);
		count++;
	}
	
	this.addDeffered = function(s,w,h,d) {
		window.setTimeout("event081124.add('"+s+"','"+w+"','"+h+"','"+d+"')",Math.round(Math.random()*500)+500);
	}

	this.fadeOut_start = function() {
		timeoutOut = 10;
		event081124.fadeOut(current);
		
	}
	
	this.fadeOut = function(nr) {
		currentObj=document.getElementById("myGallery").getElementsByTagName("img")[nr];
		setOpacity(currentObj,timeoutOut);
		timeoutOut--;
		if (timeoutOut>=0) setTimeout("event081124.fadeOut("+nr+")",fadeTime/10);
		else currentObj.style.display="none";
	}

	this.fadeIn_start = function() {
		timeoutIn = 0;
		setOpacity(currentObj,0)
		currentObj.style.display="inline";
		event081124.fadeIn(current);
	}

	this.fadeIn = function(nr) {
		currentObj=document.getElementById("myGallery").getElementsByTagName("img")[nr];
		setOpacity(currentObj,timeoutIn);
		timeoutIn++;
		if (timeoutIn<=10) setTimeout("event081124.fadeIn("+nr+")",fadeTime/10);
	}
	
	this.start = function() {
		current=0;
		currentObj=document.getElementById("myGallery").getElementsByTagName("img")[current];
		event081124.fadeIn_start();
		if (slideshow > 0) {
			setTimeout("event081124.slideshow(0)",slideshow*1000);
		}
	}
	
	this.slideshow = function(level) {
		if ((slideshow > 0) && (slideshow_turn == level)) {
			event081124.next();
		 	setTimeout("event081124.slideshow("+level+")",slideshow*1000);
		}
	}

	this.slideshow_toggle = function() {
		if (slideshow == 0) {
			slideshow = 4;
			setTimeout("event081124.slideshow("+slideshow_turn+")",slideshow*1000);
			document.getElementById("slideshow").innerHTML = "Slideshow stop";
		} else {
			slideshow = 0;
			slideshow_turn++;
			document.getElementById("slideshow").innerHTML = "Slideshow start";
		}
	}

	this.next = function() {
		event081124.fadeOut_start();
		if (current<count-1) current++; else current=0;
		currentObj=document.getElementById("myGallery").getElementsByTagName("img")[current];
		event081124.fadeIn_start();
	}

	this.prev = function() {
		event081124.fadeOut_start();
		if (current>0) current--; else current=count-1;
		currentObj=document.getElementById("myGallery").getElementsByTagName("img")[current];
		event081124.fadeIn_start();
	}
	
}

function wwidth() {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}


function wheight() {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function posFrame() {

  if (w_height != wheight())
  if ((wheight() < 800))
  {
  	document.getElementById("h_bgcontainer").style.top = "-10px";
  	document.getElementById("h_bgcontainer").style.marginTop = "-40px";
  } else {
  	document.getElementById("h_bgcontainer").style.top = "50%";
  	document.getElementById("h_bgcontainer").style.marginTop = "-401px";
  }

  if (w_width != wwidth())
  if ((wwidth() < 900))
  {
  	document.getElementById("h_bgcontainer").style.left = "-30px";
  	document.getElementById("h_bgcontainer").style.marginLeft = "-40px";
  } else {
  	document.getElementById("h_bgcontainer").style.left = "50%";
  	document.getElementById("h_bgcontainer").style.marginLeft = "-480px";
  }

  w_width=wwidth();
  w_height=wheight();
}

/* Überwachung von Netscape initialisieren */
if (!window.w_height && window.innerHeight) {
  var w_width=0;
  var w_height=0;
  window.onresize = posFrame;
}

function showLabelText(step) {
	
	posLeft=-0.5*step*step+40*step-800;
	
	el=document.getElementById("labeltext");
	el.style.left=(posLeft)+"px";
	el.style.display="block";

	step++;

	if (posLeft<0)
		window.setTimeout("showLabelText("+step+")",20);
	else {
		document.getElementById("labeltext").style.display="block";
		document.getElementById("label_btn_open").style.display="none";
		document.getElementById("label_btn_close").style.display="block";
	}
}

function hideLabelText(posLeft) {
	el=document.getElementById("labeltext");
	el.style.left=posLeft+"px";
	el.style.display="block";
	posLeft-=20;
	if (posLeft>=-800)
		window.setTimeout("hideLabelText("+posLeft+")",10);
	else {
		document.getElementById("labeltext").style.display="none";
		document.getElementById("label_btn_open").style.display="block";
		document.getElementById("label_btn_close").style.display="none";
	}
}

window.onload = posFrame;