var item_qt = new Class({
	initialize: function(element) 
	{
		this.element=element;
		this.video=$E('embed',$(this.element));
		this.timeline=$E('div.timeline',$(this.element));
		this.timeline2=$E('div.timeline2',this.timeline);
		this.timeline3=$E('div.timeline3',this.timeline);
		this.control=$E('div.control',$(this.element));
		
		this.timeline2.setStyle('opacity',0);
		this.fx=new Fx.Styles(this.timeline2, {duration: 300});
		this.play=false;
		this.setupVideo();
	},
	
	
	setupVideo : function()
	{
		this.video.oncontextmenu=(function(){return false;});
		this.video.onselectstart=(function(){return false;});
		this.video.ondragstart=(function(){return false;});
		
		this.control.addEvents({
			'mouseover' : (function(){
				var s=(this.play==true ? ' right' : ' left');
				this.control.setStyle('backgroundPosition','bottom'+s);
			}).bind(this),
			'mouseout' : (function(){
				var s=(this.play==true ? ' right' : ' left');
				this.control.setStyle('backgroundPosition','top'+s);
			}).bind(this),
			'click' : (function(){
				this.play=(this.play==true ? false : true);
				if(this.play==true) {this.play=false;this.videoPlay();}
				else this.videoStop();
			}).bind(this)
		});
		
		this.timeline.addEvents({
				'mouseenter' : (function(e){
					this.fx.stop();	
					this.fx.start({'opacity':1});
				}).bind(this),
				'mouseleave' : (function(e){
					this.fx.stop();	
					this.fx.start({'opacity':0});
				}).bind(this),
				'mousemove' : (function(e){		
					if (window.ie) tempX = event.clientX + document.body.scrollLeft;
					else    tempX = e.pageX
					if (tempX < 0){tempX = 0;}
					x=this.timeline.getPosition().x;
				
					if(window.gecko)
					{
						var d1=($('page').getStyle('width').toInt()-800)/2;
						var d2=this.element.getCoordinates().left;
						var d=tempX - x - d1;
					}
					else
					{
						var d=tempX - x;
					}
					this.timeline2.setStyles({'width':d});
				}).bind(this),
				'click' : (function(){
					var t = this.video.GetEndTime();
					var w= this.timeline.getStyle('width').toInt();
					var w2= this.timeline2.getStyle('width').toInt();
					this.fx.start({'opacity':0});
					pc=Math.floor(t*w2/w);
					this.video.SetTime(pc);
					this.videoPlay();
				}).bind(this)
		});
			
			
	},
	
	trackTime : function(){
		var t = this.video.GetEndTime();
		var t2 = this.video.GetTime();
		var w= this.timeline.getStyle('width').toInt();
		var d = Math.floor(w*t2/t);
		this.timeline3.setStyles({'width':d});
		if(this.video.GetRate()==0) this.videoStop();
		if(t==t2){
			this.play=false;
			$clear(this.track);
			var s=(this.play==true ? ' right' : ' left');
				this.control.setStyle('backgroundPosition','top'+s);
		}
	},
	
	videoPlay : function()
	{
		this.video.Play();
		if(this.play==false){
			this.play=true;this.track=this.trackTime.periodical(100,this);
		}
		var s=(this.play==true ? ' right' : ' left');
		this.control.setStyle('backgroundPosition','top'+s);
	},
	
	videoStop : function()
	{
		this.video.Stop();
		this.play=false;
		$clear(this.track);
		var s=(this.play==true ? ' right' : ' left');
		this.control.setStyle('backgroundPosition','bottom'+s);
	}
	
		
});