function Slideshow($divID, $autoSwitch, $autoSwitchTime, $zoomImgs){
	var div = $($divID)
	
	this.images = $("#"+$divID+ " ul.images li");
	this.texts = $("#"+$divID+ " ul.texts li");
	this.titles = $("#"+$divID+ " ul.titles li");
	if(this.titles.length==0)		this.titles = null
	this.navitems = $("#"+$divID+ " ul.nav li");
	if(this.navitems.length==0)	this.navitems = null
	this.pauseBtn = $("#"+$divID+ " .pause")[0];
	this.playBtn = $("#"+$divID+ " .play")[0];
	this.zoomBtn = $("#"+$divID+ " .zoom")[0];
	
	this.total = this.images.length
	this.zoomImgs = $zoomImgs
	this.divID = $divID
	this.actID = null
	this.isPlaying = true
	this.fadespeed = 12
	this.autoSwitch = $autoSwitch
	if($autoSwitchTime){
		this.autoSwitchTime = $autoSwitchTime
	}else{
		if(agent.browser=="ie" && agent.version <9)	this.autoSwitchTime = 4*30;		// IE7/8 JS engine runs alot slower..
		else														this.autoSwitchTime = 6*30;
	}
	
	if(!$autoSwitch)		this.pause()
	
	// navitems onclick: 
	for(var i=0; i<this.total; i++){
		this.navitems[i].slideshow_id = i
		this.navitems[i].slideshow_scope = this
		this.navitems[i].onclick = function(){		this.slideshow_scope.showImage(this.slideshow_id)	}
	}
	
	// play/pause-buttons onclick:
	if(this.pauseBtn){
		this.pauseBtn.slideshow_scope = this
		this.pauseBtn.onclick = function(){		this.slideshow_scope.pause()	}
	}
	if(this.playBtn){
		this.playBtn.slideshow_scope = this
		this.playBtn.onclick = function(){		this.slideshow_scope.play()	}
	}
	
	// zoom-button onclick:
	if(this.zoomBtn){
		this.zoomBtn.slideshow_scope = this
		this.zoomBtn.onclick = function(){
			this.slideshow_scope.pause()
			openZoom(this.slideshow_scope.zoomImgs[this.slideshow_scope.actID])
		}
	}
	
	// images openZoom() onclick:
	if(this.zoomImgs){
		for(var i=0; i<this.total; i++){
			var img = this.images[i].getElementsByTagName("img")[0]
			img.slideshow_scope = this
			img.onclick = function(){
				this.slideshow_scope.pause()
				openZoom(this.slideshow_scope.zoomImgs[this.slideshow_scope.actID])
			}
			setCss(img, "cursor", "pointer")
		}
	}
	
	// only 1 item:
	if(!(this.total >1)){
		if(this.pauseBtn){
			setCss(this.pauseBtn, "display", "none")
			this.pauseBtn = null
		}
		if(this.playBtn){
			setCss(this.playBtn, "display", "none")
			this.playBtn = null
		}
	}
	
	this.showImage(0, true, true)		// show first image
}

Slideshow.prototype.showImage = function($id, $auto, $skip){
	if($id != this.actID){
		// fade-speed
		var speed = this.fadespeed
		if($skip || agent.mobile)	speed = 0
		
		// texts
		if(this.actID != null)	setCss(this.texts[this.actID], "display", "none")
		setCss(this.texts[$id], "display", "block")
		
		// titles
		if(this.titles){
			if(this.actID != null)	setCss(this.titles[this.actID], "display", "none")
			setCss(this.titles[$id], "display", "block")
		}
		
		// navitem
		if(this.actID != null)	setClass(this.navitems[this.actID], "")
		setClass(this.navitems[$id], "active")
		
		// old image
		if(this.actID != null)	proto.tween(this.images[this.actID], {prop:"opacity", end:0, skip:0.2, onComplete:[this, this.hideImage, [this, this.actID]], duration:speed})
		
		// new image
		setCss(this.images[$id], "display", "block")
		proto.tween(this.images[$id], {prop:"opacity", start:0, end:1, skip:0.2, duration:speed})
		
		this.actID = $id
		
		// autoswitch:
		if(this.autoSwitch && this.total>1){
			if($auto)	this.addWait()
			else			this.pause()
		}
	}
}

Slideshow.prototype.hideImage = function($scope, $id){
	setCss($scope.images[$id], "display", "none")
}

Slideshow.prototype.pause = function(){
	if(this.isPlaying){
		proto.disposeWait(this.divID)
		this.autoSwitch = false
		this.isPlaying = false
		if(this.pauseBtn)	setCss(this.pauseBtn, "display", "none")
		if(this.playBtn)	setCss(this.playBtn, "display", "block")
	}
}
Slideshow.prototype.play = function(){
	if(!this.isPlaying){
		this.addWait()
		this.autoSwitch = true
		this.isPlaying = true
		if(this.pauseBtn)	setCss(this.pauseBtn, "display", "block")
		if(this.playBtn)	setCss(this.playBtn, "display", "none")
		this.autoNext()		// immediately show next
	}
}

Slideshow.prototype.addWait = function(){
	proto.wait(this.divID, {func:this.autoNext, duration:this.autoSwitchTime, scope:this})
}

Slideshow.prototype.autoNext = function(){
	if(this.actID < this.total-1)	this.showImage(this.actID+1, true)
	else									this.showImage(0, true)
}
