
function player(id)
{
	
	this.count = 0;
    this.timer = new Timer(this);
	this.i=1;
	this.minimized=false;
	this.percent_array;
	this.pix_coord_array;
	this.coord_array;
	this.ele_array;
	this.time_array;
	this.speed_array;
	this.incline_array;
	this.id=id;
	this.minimized;
	this.html='<div id="fb-root"></div><div id="panelwidget"><div class="hd" id="trkNameIdPlayer"></div><div class="bd" id="toposhare" style="width:520px;padding:0px;background-color:white"><table border="0" cellpadding="0"><tr><td><table border="0"><tr><td><div id="titellink'+this.id+'"></div><table border="0"><tr><td><div style="position:relative"><div style="border: 2px solid grey;" id="mapimage'+this.id+'"></div><div style="position:absolute;margin-top:-6px;margin-left:-6px;border: solid 0px #789;padding: 0px;width:15px;height:15px;filter:alpha(opacity=100);-moz-opacity:1;opacity:1;background:white;display:none;" id="marker'+this.id+'"><div style="position:relative;top:1px;left:1px; background-image: url(images/redcrosshair.png);">&nbsp;</div></div></div></td><td valign="top"><div id="controlButtons'+this.id+'" style="display:inline;position:relative;"><table border="0"><tr><td><img id="playbutton'+this.id+'" style="cursor:hand" src="'+baseUrl+'/images/silk/icons/control_play_blue.png" onclick=\'playerObj'+this.id+'.play()\' /><img style="display:none;cursor:hand" id="pausebutton'+this.id+'" style="cursor:hand" src="'+baseUrl+'/images/silk/icons/control_pause_blue.png" onclick=\'playerObj'+this.id+'.pause()\' /></td><td><img style="cursor:hand;display:inline" id="stepbackbutton'+this.id+'" src="'+baseUrl+'/images/silk/icons/control_start_blue.png" onclick=\'playerObj'+this.id+'.stepBack()\' /></td><td><img style="display:inline" id="stepforbutton'+this.id+'" style="cursor:hand" src="'+baseUrl+'/images/silk/icons/control_end_blue.png" onclick=\'playerObj'+this.id+'.stepFor()\' /></td><td><img style="display:inline" style="cursor:hand" id="resetbutton'+this.id+'" src="'+baseUrl+'/images/silk/icons/control_rewind_blue.png" onclick=\'playerObj'+this.id+'.reset()\' /></td></tr></table></div><br><br><p><div id="stats'+this.id+'"></div></p></td><td valign="top"><div id="weather'+this.id+'"></div></td></tr></table></td></tr><tr><td><table border="0" cellspacing="2"><tr><td><a target="blank" href="pdfprint?search=trk&trkGid='+this.id+'"><img style="border:0px" src="'+baseUrl+'/images/silk/icons/page_white_acrobat.png" /></a></td><td><div class="small">PDF</div></td><td><a href="tokml?gid='+this.id+'"><img  style="border:0px" src="'+baseUrl+'/images/silk/icons/world.png" /></a></td><td><div class="small">Google Earth</div></td><td><a href="togpx?gid='+this.id+'"><img  style="border:0px" src="'+baseUrl+'/images/silk/icons/phone.png" /></a></td><td><div class="small">GPX</div></td></tr></table></td></tr><tr><td align="left" valign="middle"><div style="position:relative"><div id="profileimage'+this.id+'"></div><div style="position:absolute;left:50px"><div style="position:absolute;border:solid 1px #003399;padding:0px;width:1px;height:150px;background:white;display:none;left:0;bottom:0px;" id="stick'+this.id+'"></div></div><fb:like href="www.toposhare.org/sharedroutes?permalink=' + this.id  + '" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></td></tr></table></td></tr></table></div></div>';
	
    this.interval;
	this.move = function() {
		pix=this.pix_coord_array[this.i].split(",");
		text="<table border='0'><tr><td>T</td><td>:</td><td>"+this.time_array[this.i]+"</td></tr><tr><td>E</td><td>:</td><td> "+this.ele_array[this.i]+"</td></tr><tr><td>S</td><td>:</td><td>"+this.speed_array[this.i]+"</td></tr><tr><td>I</td><td>:</td><td>"+this.incline_array[this.i]+"%</td></tr></table>";
		if (!this.minimized) document.getElementById("marker"+this.id).style.display = "inline";
		document.getElementById("stats"+this.id).innerHTML = text;
		document.getElementById("marker"+this.id).style.left = pix[0]+"px";
		document.getElementById("marker"+this.id).style.top = pix[1]+"px";
		//stickPos=document.getElementById("stick"+this.id).style.left;
		newStickpos=this.percent_array[this.i];
		document.getElementById("stick"+this.id).style.left = newStickpos+"px";
	}
	this.gmapPan = function() { 
		coord=this.coord_array[this.i].split(" ");
		try {
			map.panTo(new GLatLng(coord[1],coord[0]));
		} catch (e) {}
	}
	this.play = function() {
		document.getElementById("playbutton"+this.id).style.display = "none";
		document.getElementById("pausebutton"+this.id).style.display = "inline";
		this.interval=500;
		this.animate();
	}
	this.animate = function() {
		if (!this.minimized) document.getElementById("stick"+this.id).style.display = "inline";
		if (this.pix_coord_array.length==this.i) return;
		this.move(this.i);
		this.gmapPan(this.i);
		this.i++;
		this.timer.setTimeout("animate", this.interval)
		
	}
	
	this.pause = function() {
		document.getElementById("playbutton"+this.id).style.display = "inline";
		document.getElementById("pausebutton"+this.id).style.display = "none";
		this.interval=10000000;
	}
	this.stepFor = function() {
		this.i++;
		this.move(this.i);
		this.gmapPan(this.i);
	}
	this.stepBack = function() {
		this.i--;
		this.move(this.i);
		this.gmapPan(this.i);
	}
	this.reset = function(){
		this.i=0;
		document.getElementById("marker"+this.id).style.display = "none";
		document.getElementById("stick"+this.id).style.display = "none";
	}
	this.changeSize = function(){
		if (this.minimized) {
			this.minimized=false;
			value="inline"
		}
		else
		{
			this.minimized=true;
			value="none"
		}
		document.getElementById("mapimage"+this.id).style.display=value;
		document.getElementById("profileimage"+this.id).style.display=value;
		document.getElementById("stick"+this.id).style.display=value;
		document.getElementById("marker"+this.id).style.display=value;
	}
	
	this.addHTML = function() {
		document.getElementById("toposhare"+this.id).innerHTML=this.html;
	}
	this.addTitel = function(str) {
			document.getElementById("titellink"+this.id).innerHTML=str;
	}
	this.addWeather = function() {
		document.getElementById("weather"+this.id).innerHTML=this.weatherHTML;
	}
	this.addMapImage = function(url) {
		document.getElementById("mapimage"+this.id).innerHTML='<img src="'+url+'">';
	}
	this.addProfileImage = function(url) {
		document.getElementById("profileimage"+this.id).innerHTML='<img src="'+url+'">';
	}
	this.renderWindow = function() {
		YAHOO.example.container.panelwidget = new YAHOO.widget.Panel("panelwidget", {visible:true, draggable:false, close:false } );
		YAHOO.example.container.panelwidget.render();
		YAHOO.example.container.panelwidget.show();
	}
										
}
