// 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 intWidth = parseInt(this.Videos[strID].Width,10)
			var intHeight = parseInt(this.Videos[strID].Height,10)
			//parseInt(intHeight * this.Videos[strID].Ratio,10)
			

			/*if (intWidth > 640) {
				intWidth = 640
			}
			intHeight = intWidth / this.Videos[strID].Ratio
			if (intHeight > 480) {
				intHeight = 480
				intWidth = this.Width / this.Videos[strID].Ratio
			}*/
			
			var strHtmlCode = '<object style="height: ' + intWidth + 'px; width: ' + intHeight + 'px">'
			strHtmlCode += '<param name="movie" value="http://www.youtube.com/v/' + strCode  + '?version=3">'
			strHtmlCode += '<param name="allowFullScreen" value="true">'
			strHtmlCode += '<param name="allowScriptAccess" value="always">'
			strHtmlCode += '<embed src="http://www.youtube.com/v/' + strCode  + '?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="' + intWidth + '" height="' + intHeight + '">'
			strHtmlCode += '</object>'
			
			hex.$Text("videozoomtitle",this.Videos[strID].Title)
			hex.$Text("videozoomimageframe",strHtmlCode)
			hex.$Text("videozoomdetails",this.Videos[strID].Description)
			if (hex && (hex.FX)) {
				hex.FX.Resize.Start("videozoom",{EndWidth: (intWidth+20), EndHeight : (intHeight+20), Centre : true, Border : {x : 2, y: 2}})
				hex.FX.Resize.Start("videozoomcontents",{EndWidth: (intWidth+10), EndHeight : (intHeight+10), Centre : true, Border : {x : 10, y: 10}})
				
			}else{
				hex.$("videozoom").style.width = intWidth+20 + "px";
				hex.$("videozoom").style.height = intHeight+50 + "px";
				hex.$("videozoomcontents").style.width = intWidth+10 + "px";
				hex.$("videozoomcontents").style.height = intHeight+40 + "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);
		}
	}
}
