cpBusShowcase = function(name,files,titles,texts,start){
	this.name=name;
	this.start=start;
	this.files=files.split("$");
	this.titles=titles.split("$");
	this.texts=texts.split("$");
	this.count=this.files.length;
	this.itemRatio=117/110;
	this.width=822;
	this.height=402;
	this.y=60;
	this.itemWidth=this.width/(this.count+2);
	this.itemHeight=this.itemWidth/this.itemRatio;
	this.status='null';
	this.alpha=Array();
	this.timeout=null;

	this.close=function(){
		removeBGDiv(this.name);
		document.getElementsByTagName('body')[0].removeChild( document.getElementById(this.name+'ContentDiv') );
		cpBusShowcaseItem[this.name]=null;
	}

	this.showDiv=function(id){
		clearTimeout(this.timeout);
		cont=false;
		this.alpha[id]=Math.min(this.alpha[id]+10,100);
		if(this.alpha[id]<100) cont=true;
		if(this.alpha[id]>90) document.getElementById(this.name+'itemDiv'+id).style.filter = "";
		else document.getElementById(this.name+'itemDiv'+id).style.filter = "alpha(opacity:"+this.alpha[id]+")";
		document.getElementById(this.name+'itemDiv'+id).style.KHTMLOpacity = document.getElementById(this.name+'itemDiv'+id).style.MozOpacity = document.getElementById(this.name+'itemDiv'+id).style.opacity = this.alpha[id]/100;
		for(var i=0;i<this.count;i++) if(i!=id) {
			this.alpha[i]=Math.max(this.alpha[i]-10,0);
			if(this.alpha[i]>0) cont=true;
			document.getElementById(this.name+'itemDiv'+i).style.filter = "alpha(opacity:"+this.alpha[i]+")";
			document.getElementById(this.name+'itemDiv'+i).style.KHTMLOpacity = document.getElementById(this.name+'itemDiv'+i).style.MozOpacity = document.getElementById(this.name+'itemDiv'+i).style.opacity = this.alpha[i]/100;
		}
		if(cont==true) this.timeout=setTimeout("cpBusShowcaseItem['"+this.name+"'].showDiv("+id+");",50);
	}

	this.click=function(e){
		if(e==undefined) e=event;
		var x=(e.clientX-(document.documentElement.clientWidth-this.width)/2);
		var y=(e.clientY-(document.documentElement.clientHeight-this.height)/2);
		if(x>708 && x<806 && y>15 && y<45) { this.close(); }
		if( y>this.y && y<this.y+this.itemHeight ) {
			this.showDiv(Math.floor(x/this.itemWidth)-1);
		}
	}

	this.mouseMove=function(e){
		if(e==undefined) e=event;
		var fullWidth=0;
		var ydist=Math.abs(-this.itemHeight/2-this.y+e.clientY-(document.documentElement.clientHeight-this.height)/2)*2;
		var ratioY=Math.min((this.itemHeight/(ydist+1)),1);
		for(var i=0;i<this.count;i++) {
			var dist=Math.abs(((this.itemWidth*i)+(this.itemWidth*1.5)) - (e.clientX-(document.documentElement.clientWidth-this.width)/2));
			fullWidth+=Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth );
		}
		var left=(this.width-fullWidth)/2;
		document.getElementById(this.name+'titleDiv').style.display='none';
		for(var i=0;i<this.count;i++) {			
			var dist=Math.abs(((this.itemWidth*i)+(this.itemWidth*1.5)) - (e.clientX-(document.documentElement.clientWidth-this.width)/2));
			document.getElementById(this.name+'itemImg'+i).style.width=Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth )+'px';
			document.getElementById(this.name+'itemImg'+i).style.height=Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth )/this.itemRatio+'px';
			document.getElementById(this.name+'itemImg'+i).style.left=left+'px';
			document.getElementById(this.name+'itemImg'+i).style.top=this.y+ ( this.itemHeight - Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth )/this.itemRatio )/2 +'px';
			left+=Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth );
			if( (dist<this.itemWidth/2) && (ratioY>0.7)){
				document.getElementById(this.name+'titleDiv').style.display='block';
				var pos=Array('left:0px;top:0px;','left:2px;top:0px;','left:0px;top:2px;','left:2px;top:2px;','left:1px;top:0px;','left:0px;top:1px;','left:2px;top:1px;','left:1px;top:2px;');
				var title='';
				for(var j=0;j<pos.length;j++) {
					title+='<div style="width:200px;position:absolute;color:#000000;'+pos[j]+'">'+this.titles[i]+'</div>';
				}
				document.getElementById(this.name+'titleDiv').innerHTML=title+'<div style="position:absolute;color:#ffffff;left:1px;top:1px;width:200px;">'+this.titles[i]+'</div>';
				document.getElementById(this.name+'titleDiv').style.left=left-(100+Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth )/2)+'px';
				document.getElementById(this.name+'titleDiv').style.top=this.y+this.itemHeight/2+(Math.max( (this.itemWidth*1.5)*ratioY-(dist/2),this.itemWidth )/this.itemRatio)/2-30+'px';
			}
		}
	}

	this.show=function(){
		drawBGDiv(this.name);

		var contentDiv=document.createElement("div");
		contentDiv.id=contentDiv.name=this.name+'ContentDiv';
		contentDiv.style.zIndex='101';
		contentDiv.style.position='absolute';
		contentDiv.style.top=(Math.max(document.documentElement.scrollTop,document.body.scrollTop)) + ((document.documentElement.clientHeight-this.height)/2) +'px';
		contentDiv.style.left=((document.documentElement.clientWidth-this.width)/2)+'px';
		contentDiv.style.width=this.width+'px';
		contentDiv.style.height=this.height+'px';
		document.getElementsByTagName('body')[0].appendChild(contentDiv);
		var self=this;
		if (document.addEventListener) contentDiv.addEventListener("mousemove", function(e) { self.mouseMove(e); }, true);
		else contentDiv.attachEvent("onmousemove", function(e) { self.mouseMove(e); }, true);
		if (document.addEventListener) contentDiv.addEventListener("click", function(e) { self.click(e); }, true);
		else contentDiv.attachEvent("onclick", function(e) { self.click(e); }, true);

		var bgImg=document.createElement("img");
		bgImg.id=bgImg.name=this.name+'bgImg';
		bgImg.src='pic/coaches.png';
		bgImg.style.zIndex='100';
		bgImg.style.position='absolute';
		bgImg.style.top='0px';
		bgImg.style.left='0px';
		bgImg.style.width=this.width+'px';
		bgImg.style.height=this.height+'px';
		contentDiv.appendChild(bgImg);


		for(var i=0;i<this.count;i++) {
			var newImg=document.createElement("img");
			newImg.id=newImg.name=this.name+'itemImg'+i;
			newImg.src='pic/'+this.files[i];
			newImg.style.zIndex='101';
			newImg.style.position='absolute';
			newImg.style.cursor='pointer';
			newImg.style.top=this.y+'px';
			newImg.style.left=(this.itemWidth*i)+(this.itemWidth)+'px';
			newImg.style.width=this.itemWidth+'px';
			newImg.style.height=this.itemHeight+'px';
			contentDiv.appendChild(newImg);
		}
		for(var i=0;i<this.count;i++) {
			this.alpha[i]=0;
			var newDiv=document.createElement("div");
			newDiv.style.filter = "alpha(opacity:"+this.alpha[i]+")";
			newDiv.style.KHTMLOpacity = newDiv.style.MozOpacity = newDiv.style.opacity = this.alpha[i]/100;
			newDiv.id=newDiv.name=this.name+'itemDiv'+i;
			newDiv.style.zIndex='101';
			newDiv.style.background='#ffffff';
			newDiv.style.position='absolute';
			newDiv.style.top=this.y+(this.itemHeight*1.4)+'px';
			newDiv.style.width=this.width-80+'px';
			newDiv.style.marginLeft=40+'px';
			newDiv.style.marginRight=40+'px';
			newDiv.innerHTML=this.texts[i];
			contentDiv.appendChild(newDiv);
		}

		var titleDiv=document.createElement("div");
		titleDiv.id=titleDiv.name=this.name+'titleDiv';
		titleDiv.style.zIndex='102';
		titleDiv.style.position='absolute';
		titleDiv.style.top='0px';
		titleDiv.style.left='0px';
		titleDiv.style.width='200px';
		titleDiv.style.textAlign='center';
		titleDiv.style.filter = "";
		titleDiv.style.cursor = "pointer";
		titleDiv.style.display = "none";
		titleDiv.style.KHTMLOpacity = titleDiv.style.MozOpacity = titleDiv.style.opacity = 0.75;
		contentDiv.appendChild(titleDiv);
		this.showDiv(this.start);
	}

}


var cpBusShowcaseItem=Array();

function addcpBusShowcase(id,files,titles,texts,start){
	if(cpBusShowcaseItem[id]==null) {
		cpBusShowcaseItem[id]=new cpBusShowcase(id,files,titles,texts,start);
		cpBusShowcaseItem[id].show();
	}
}
