// JavaScript Document


var ZoomVideo	= {
	Videos	: {}
	,Current : {
		Open : false
		,Scroll : null
	}
	,Add	: function (strID,objVars) {
		this.Videos[strID] = objVars
	}
	,Open	: function (strID) {
		if (this.Videos[strID]) {
			hex.BlackOut.Show()
			this.MoveToCentre()
			hex.$Show("videozoom")
			this.Current.Open = true
			
			var strCode = this.Videos[strID].Code
			var intHeight = 350
			var intWidth = parseInt(intHeight * this.Videos[strID].Ratio,10)
				
			strCode = strCode.replace(/width=\"[0-9]*\"/gi,"width='" + intWidth + "'")
			strCode = strCode.replace(/height=\"[0-9]*\"/gi,"height='" + intHeight + "'")
			
			hex.$Text("videozoomtitle",this.Videos[strID].Title)
			hex.$Text("videozoomimageframe",strCode)
			hex.$Text("videozoomdetails",this.Videos[strID].Description)
			hex.$("videozoomdetails").style.height = (480 - 10 - intHeight - 50) + "px"
			return false
		}
		
	}
	,Close	: function () {
		hex.BlackOut.Hide()
		hex.$Hide("videozoom")
		this.Current.Open = false
		return false
	}
	,MoveToCentre	: function () {
		window.clearTimeout(this.Current.Scroll);
		this.Current.Scroll = null
		var blnIE = (window.innerHeight > 0) ? false : true;
		var intWinHeight = (blnIE) ? document.documentElement.clientHeight : window.innerHeight;
		var intWinWidth	= (blnIE) ? document.documentElement.clientWidth : window.innerWidth;
		var intFrameWidth	=  640;
		var intFrameHeight	=  480;

	
		var intLeft = (intWinWidth/2) - (intFrameWidth/2);
		var intTop = (intWinHeight/2) - (intFrameHeight/2);
				
		var objSrollPos = ZoomImage.GetScrollPos();
				
		hex.$("videozoom").style.left	= ((intLeft) + objSrollPos.Left) + "px";
		hex.$("videozoom").style.top	= ((intTop) + objSrollPos.Top) + "px";
	}
	,OnScroll		: function () {
		if (this.Current.Open) {
			if (this.Current.Scroll != null) {
				window.clearTimeout(this.Current.Scroll);
				this.Current.Scroll = null
			}
			this.Current.Scroll = window.setTimeout(function () {ZoomVideo.MoveToCentre()},500);
		}
	}
}
