function ImageSwitch( s )
{
	this.s = s;
	this.c;
	this.p;
	this.i;
	
	this._construct = function()
	{
		//alert(this.s);
		try {
			this.i = this.s != null ? 1 : 0 ;
			//alert(this.s);
			this.c = this.s != null ? this.s.getElementsByTagName("img") : $$(".subnews img") ;	
			
			try {
				this.p = document.getElementById("counter");
				this.setCounter();
			} catch (e){
				null;
			}
			this.setClickAreas();	
		} catch(e){
			//alert(e);
			null;
		}
	}
	
	this.setClickAreas = function()
	{
		var p = this;
		
		if(this.s!=null)
		{
			this.s.onmouseover = function()
			{
				try {
					p.c[0].style.display = "none";
					p.c[( p.i <= 0 ? 1 : p.i )].style.display = "block";	
				} catch(e){
					null;
				}
				
			}
		}
		
		
		try {
			var iB = document.getElementById("ImageBox");
			var iA = document.getElementById("arrow");
			
			iB.onmouseup = function ( e )
			{
				e = window.event ? window.event : e ;
				d = e.offsetX ? e.offsetX/this.offsetWidth : e.layerX/this.offsetWidth;
				d < 0.5 ? p.backward() : p.forward(); 
				p.setCounter();
			}
			
			iB.onmouseover = function(e)
			{
				iA.style.display = "block";
			}
			
			iB.onmouseout = function(e)
			{
				iA.style.display = "none";
			}
			
			
			iB.onmousemove = function ( e )
			{
				
				e = window.event ? window.event : e ;
				var d = e.offsetX ? e.offsetX/this.offsetWidth : e.layerX/this.offsetWidth;
				
				var x = e.offsetX ? e.offsetX : e.layerX; 
				var y = e.offsetY ? e.offsetY : e.layerY; 
				
				iA.style.left = x>0 ? (x-20)+"px" : iA.style.left ;
				iA.style.top  = y>0 ? (y-45)+"px" : iA.style.top ;
				
				/*iA.innerHTML = (iA.style.left+"<br/>"+iA.style.top);*/
				
				iA.style.background = d < 0.5 ? "url('../media/layout/pfeil-li.png') center left no-repeat" : "url('../media/layout/pfeil-re.png') center left no-repeat" ;
			}	
			
		} catch(e){
			for(i=0; this.c[i]; i++)
			{
				if(i==0)
				{
						
				}else{
					this.overHandle(this.c[i]);
				}
				
				this.c[i].onmouseup = function( e )
				{
					e = window.event ? window.event : e ;
					d = e.offsetX ? e.offsetX/this.offsetWidth : e.layerX/this.offsetWidth;
					d < 0.5 ? p.backward() : p.forward(); 
					p.setCounter();
				}	
			}
				
		}
			
	}
	
	this.overHandle = function( i )
	{
		var p = this;
		if( this.s != null )
		{	
			i.onmouseout = function()
			{
				this.style.display = "none";
				p.c[0].style.display = "block";
			}
		}
		
	}
	
	this.backward = function()
	{
		this.c[this.i].style.display = "none";
		if(this.s!=null)
		{
			this.i = this.i < 2 ? this.c.length-1 : this.i-1 ;
		}else{
			this.i = this.i < 1 ? this.c.length-1 : this.i-1 ;	
		}
		
		this.c[this.i].style.display = "block";
	}
	
	this.forward = function()
	{
		
		this.c[this.i].style.display = "none";
		
		if(this.s!=null)
		{
			this.i = this.i >= (this.c.length-1) ? 1 : this.i+1 ;
		}else{
			this.i = this.i >= (this.c.length-1) ? 0 : this.i+1 ;	
		}
		
		this.c[this.i].style.display = "block";
		//alert(this.i);
	}
	
	this.setCounter = function()
	{
		try {
			this.p.innerHTML = ( ( this.i+1 ) < 10 ? '0'+( this.i+1 ) : (this.i+1) )+"/"+(this.c.length < 10 ? '0'+this.c.length : this.c.length );	
		} catch (e) {
			null;
		}
		
	}
	
	this._construct();
}
