cpMarker = function(name,dest,start,top,img){
	this.top=top;
	this.name=name;
	this.dest=document.getElementById(dest);
	this.destImg=document.getElementById(img);
	if(start>-1) this.start=start;
	else this.start=document.documentElement.clientWidth+100;
	this.div=null;
	this.left=this.start;
	this.interval=null;
	this.timeout=null;
	this.status='null';

	this.init=function(){
		if(this.start<document.documentElement.clientWidth+99){
			var areas=this.dest.getElementsByTagName('area');
			var area=areas[this.start-1];
			var coords=area.coords.split(",");
			this.left=this.start=(parseInt(coords[2])+parseInt(coords[0]))/2+this.destImg.offsetLeft-15;			
		}
		this.div=document.createElement("div");
		this.div.style.position='absolute';
		this.div.style.display='block';
		this.div.style.top=this.top+'px';
		this.div.style.width='29px';
		this.div.style.left=this.left+'px';
		this.div.style.height='10px';
		this.div.style.background='url(\'pic/menu_marker.png\')';
		this.dest.appendChild(this.div);
		var areas=this.dest.getElementsByTagName('area');
		var self=this;
		for(var i=0;i<areas.length;i++){
			if (document.addEventListener) {
				areas[i].addEventListener("mouseover", function(e) { self.move(e); }, true);
				areas[i].addEventListener("mouseout", function(e) { self.status='remove'; self.timeout=setTimeout("cpMarkerItem['"+self.name+"'].remove();",1000); }, true);
			}
			else {
				areas[i].attachEvent("onmouseover", function(e) { self.move(e); }, true);
				areas[i].attachEvent("onmouseout", function(e) { self.status='remove'; self.timeout=setTimeout("cpMarkerItem['"+self.name+"'].remove();",1000); }, true);
			}
		}
	}

	this.remove=function(e){
		if(this.status=='remove') {
			clearInterval(this.interval);
			this.interval=setInterval("cpMarkerItem['"+this.name+"'].moveTo("+this.start+");",20);
		}
	}

	this.move=function(e){
		if(e==undefined) e=event;
		if(e.target) obj=e.target; else obj=e.srcElement;
		var coords=obj.coords.split(",");
		this.status='move';
		clearTimeout(this.timeout);
		clearInterval(this.interval);
		this.interval=setInterval("cpMarkerItem['"+this.name+"'].moveTo("+( (parseInt(coords[2])+parseInt(coords[0]))/2+this.destImg.offsetLeft-15 )+");",30);
	}

	this.moveTo=function(left){
		this.left=(this.left*0.8 + left*0.2);
		if( Math.abs(this.left-left)<3 ) {
			this.left=left;
			clearInterval(this.interval);
		}
		this.div.style.left=this.left+'px';
	}

	this.init();
}


var cpMarkerItem=Array();

function addcpMarker(id,dest,start,top,img){
	if(cpMarkerItem[id]==null) {
		cpMarkerItem[id]=new cpMarker(id,dest,start,top,img);
	}
}
