
/* DIESER IMAGESWITCHER IST ABGEÄNDERT UND NICHT ORIGINAL. ANGEPASST AUF RuggellShop.LI */

function Picture(id,url,title,legend)
{
	this.id = id;
	this.url = url;
	this.title = title;
	this.legend = legend;
}

function ImageSwitcher(clientID) 
{
        this.arr = new Array();
		this.aktindex = 0;
		this.imageId = "bigimage";
		this.legendId = "commentdiv";
		this.titleId = "titlediv";
		this.statusId = "statusdiv";
		this.clientID = clientID;
		this.lastImage = null;
}

/* constructor */
ImageSwitcher.prototype.initialize = function() {
		this.arr = new Array();
		this.aktindex = 0;
		this.imageId = "bigimage";
		this.legendId = "commentdiv";
		this.titleId = "titlediv";
		this.statusId = "statusdiv";
   }
   
	/* add new picture */	
   ImageSwitcher.prototype.add = function(id,url,title,legend){
		
		var pic = new Picture(id,url,title,legend);
		this.arr[this.arr.length] = pic;
   }
   
   ImageSwitcher.prototype.remove = function(index){
		
   }
   
   ImageSwitcher.prototype.first = function(){
		this.aktindex = 0;
		this.setImage();
   }
   
   ImageSwitcher.prototype.previous = function(){
	
	this.aktindex--;
	
	if(this.aktindex < 0)
		this.aktindex =  this.arr.length - 1;
	 this.setImage();
   }
   
   ImageSwitcher.prototype.next = function(){
	
	this.aktindex++;
	
	if(this.aktindex >= this.arr.length)
		this.aktindex = 0;
		
	 this.setImage();
   }
   
   ImageSwitcher.prototype.last = function(){
	  this.aktindex = this.arr.length - 1;
	  this.setImage();
   }
   
   ImageSwitcher.prototype.setImage = function()
   {
	 var img = $(this.imageId);
	 var legend = $(this.legendId);
	 var title = $(this.titleId);
	 var status = $("statusdiv" + this.clientID);
	 var link = $("biglink" + this.clientID);
	
	 var pic = this.arr[this.aktindex];
	
	 if(pic == null)
	     return;
	     
	 if(img != null)img.src = pic.url;
	 if(legend != null) legend.innerHTML = pic.legend;
	 if(title != null) title.innerHTML = pic.title;
	 if(status != null) status.innerHTML = (this.aktindex + 1) + " / " + this.arr.length;
	 if(link != null) { link.href = pic.url.replace(/klein\\/,""); link.title = pic.title;}
	 
	 var image = $("img" + pic.id);
	 
	 if(image != null)
	 {
	 
	    if(this.lastImage != null)
	        this.lastImage.style.display = "none";
	        
	    image.style.display = "block";
	    
	    this.lastImage = image;
	 }
	 
	 if(onImageSet)
		onImageSet(pic.id);
   }
   
   ImageSwitcher.prototype.setImageByIndex = function(index)
   {
	 this.aktindex = index;
	 this.setImage();
   }
   
   ImageSwitcher.prototype.setImageById = function(picid)
   {
	 for(var i=0;i<this.arr.length;i++)
	 {
		if(this.arr[i].id == picid)
			this.aktindex = i;
	 }
	 this.setImage();
   }


function onImageSet(id){
    
}