
function initslidingboxes ()
{
	if($('three') && $('four'))
	{
		slide1 = new slidebox("three","slidebox");
		slide2 = new slidebox("four","slidebox");
		slide3 = new slidebox("two","wideslidebox");
	}
	else
	{
		slide4 = new slidebox("rightslidebox","slidebox");
	}
}



var slidebox = Class.create();
slidebox.prototype = {
	
  initialize: function(name,classname) 
  {
    
	this.slideInProgress = false;
	
	this.boxes = new Array();
	this.classname = classname;
	
	divs = $(name).getElementsByTagName("div");
	for(i=0;i<divs.length;i++)
	{
		if(divs[i].className == classname)
		{
			this.boxes.push(divs[i]);
		}
	}
	
	this.subboxes = new Array();
		
	for(i=0;i<this.boxes.length;i++)
	{
		this.subboxes[i] = new Array();
		elements = this.boxes[i].childNodes;
		for (e=0;e<elements.length;e++)
		{
			if(elements[e].className == "top minus")
			{
				this.subboxes[i]['topminus'] = elements[e];
			}
			else if (elements[e].className == "top plus")
			{
				this.subboxes[i]['topplus'] = elements[e];
			}
			else if (elements[e].className)
			{
				if (elements[e].className.indexOf("content") != -1)
				{
					this.subboxes[i]['content'] = elements[e];
				}
				else if (elements[e].className == "image" && this.classname == "wideslidebox")
				{
					this.subboxes[i]['image'] = elements[e];
				}
			}
		}
		
		if(i==0)
		{
			// erste Box ist aufgeklappt die anderen zu
			this.subboxes[i]['topminus'].style.display = "";
			this.subboxes[i]['topplus'].style.display = "none";
			this.boxes[i].style.height = "140px";
			if(this.classname == "wideslidebox")
			{
				this.boxes[i].style.height = '140px';
			}
			
		}
		else
		{
			this.subboxes[i]['topminus'].style.display = "none";
			this.subboxes[i]['topplus'].style.display = "";
			this.subboxes[i]['content'].style.display = "none";
			this.boxes[i].style.height = "25px";
			
			if(this.classname == "wideslidebox")
			{
				this.subboxes[i]['image'].style.display = 'none';
			}
		}
		
		// Events setzen
		this.subboxes[i]['topplus'].position = i;
		this.subboxes[i]['topplus'].myClass = this;
		this.subboxes[i]['topplus'].onclick = function ()
		{
			this.myClass.showSlidebox(this.position);
		}
	}
	
	this.openSlidebox = 0;
	this.tmpSlidebox = null;
  },

  showSlidebox: function(id) 
  {
    	if(this.slideInProgress == false)
		{
			this.slideInProgress = true;
			
			this.tmpSlidebox = id;
			this.subboxes[this.openSlidebox]['topminus'].style.display = "none";
			this.subboxes[this.openSlidebox]['topplus'].style.display = "";
			
			if(this.classname == "wideslidebox")
			{
				this.subboxes[this.openSlidebox]['image'].style.display = 'none';
				this.boxes[this.openSlidebox].style.height = '';
			}
			
			this.openId = id;
			
			this.subboxes[id]['content'].style.display = "";
			
			ex = new Animator({transition: Animator.makeEaseOut(3),duration: 1000, myClass: this, onComplete: function() { this.options.myClass.slideInProgress = false; this.options.myClass.subboxes[this.options.myClass.openSlidebox]['content'].style.display = "none"; this.options.myClass.setOpenSlidebox(); if(this.options.myClass.classname=="wideslidebox") { this.options.myClass.boxes[this.options.myClass.openId].style.height = '140px'; Effect.Appear(this.options.myClass.subboxes[this.options.myClass.openId]['image']); } }});
			ex.addSubject(new NumericalStyleSubject(this.boxes[this.openSlidebox], 'height', 140, 25));
			ex.addSubject(new NumericalStyleSubject(this.boxes[id], 'height', 25, 140));
			ex.play();
			
			this.subboxes[id]['topminus'].style.display = "";
			this.subboxes[id]['topplus'].style.display = "none";
		}
  },
  
  setOpenSlidebox : function ()
  {
	 this.openSlidebox = this.tmpSlidebox;
  }
  
};




/* webcam Slidebox functions */

var webcamSlidebox = Class.create();
webcamSlidebox.prototype = {
	
	initialize: function(webcams) 
  	{
		this.actualPosition = 0;	
		this.webcams = webcams;
	},
	
	toLeft : function ()
	{
		if(this.actualPosition > 0)
		{
			$("webcamSlidebox").style.backgroundImage = 'url(' + this.webcams[this.actualPosition - 1]['source'] + ')';
			$("webcamText").innerHTML = this.webcams[this.actualPosition - 1]['text'];
			this.actualPosition -= 1;
		}
	},
	
	toRight : function () 
	{
		if(this.actualPosition < this.webcams.length-1)
		{
			$("webcamSlidebox").style.backgroundImage = 'url(' + this.webcams[this.actualPosition + 1]['source'] + ')';
			$("webcamText").innerHTML = this.webcams[this.actualPosition + 1]['text'];
			this.actualPosition += 1;
		}
	}
}
