//------cpPicSwitch---------------------------
cpPicSwitch = function(name,target){
	this.name=name;
	this.target=target;
	this.pics;
	this.max=0;
	this.current=0;
	this.last=0;
	this.alpha=0;

	this.create=function(){
		this.pics=document.getElementById(this.target).getElementsByTagName('img');
		this.max=this.pics.length-1;
		for(var i=0;i<this.pics.length;i++) this.pics[i].style.display='none';
		this.current=Math.floor(Math.random()*this.pics.length);
		this.next();
	}

	this.next=function(){
		for(var i=0;i<this.pics.length;i++) this.pics[i].style.display='none';
		this.pics[this.current].style.display='';
		this.last=this.current;
		this.current++;
		if(this.current>this.max) this.current=0;
		setTimeout(this.name+".fade();",9000);
	}

	this.fade=function(){
		this.alpha=this.alpha+20;
		if(this.alpha>100) {
			this.pics[this.current].style.filter = "";
			this.alpha=0;
			this.next();
		}
		else {
			this.pics[this.current].style.display='';
			this.pics[this.current].style.filter = "alpha(opacity:"+this.alpha+")";
			this.pics[this.current].KHTMLOpacity = this.pics[this.current].style.MozOpacity = this.pics[this.current].style.opacity = this.alpha/100;
			this.pics[this.last].style.filter = "alpha(opacity:"+(100-this.alpha)+")";
			this.pics[this.last].KHTMLOpacity = this.pics[this.last].style.MozOpacity = this.pics[this.last].style.opacity = (1-(this.alpha/100));
			this.pics[this.current].style.display='';
			setTimeout(this.name+".fade();",50);
		}
	}

	this.create();
}
