/*
 * VideoHover
 *
 * Utility designed to correct the issue of multiple instances being 
 * played back in IE
 *
 *
 *
 * January 2009
 */

VideoHover = function (elementId) {
	
	this.currentPlayer = -1;
	this.element = document.getElementById(elementId);
	this.init();
};

VideoHover.prototype = {

	init : function () {
		
		var self = this;
		
		this.element.onmouseover = function (e) {
			var position =  self.getPosition(e);
			if(self.currentPlayer == -1) {
				self.currentPlayer = position;
				$f("*").each(function(){if(this.isPlaying()==1){/*console.log(this.id());*/this.unload();}});
				$f(position).play();
				/*console.log(position);*/

				var videoCaptionPlugin = $f(position).getPlugin("videoCaption");
//				console.log(videoCaptionPlugin);
/*
				var description = "videoDesc"+position;
//				console.log(description);

				var caption = '<span class="description">'+document.getElementById(description).innerHTML+'</span>';
//				console.log(caption);
*/			}
		}	

		this.element.onmouseout = function (e) {
			var position =  self.getPosition(e);
			if(self.currentPlayer == position) {
				self.currentPlayer = -1;
				$f(position).unload();
			}
		}

		this.element.onclick = function (e) {
alert("hi");
}

	},
	
	getPosition : function (e) {
		e = e || window.event;
		target  = e.srcElement || e.target;
		return Number(target.id.replace(/\D+/g,""));
	}
};
