// ============================================================================================
// ============================================================================================

	var flash1 = "<embed id=\"video\" src=\"/_scripts/VideoPlayer.swf\" flashVars=\"";
	var flash2 = "\" width=\"100%\" height=\"100%\" duration=\"0\" wmode=\"transparent\" swLiveConnect=\"true\" />";
	var VideoDiv = "VideoDiv";
	var Container = "ContentTable";

//	preload();

	function preload()
	{
		var v;
		
		v = document.getElementById(VideoDiv);

		v.style.left = 0;
		v.style.top = 0;
		v.style.width = 0;
		v.style.height = 0;
		v.style.visibility = "hidden";
		v.innerHTML = flash1 + "width=0&height=0&maxheight=0" + flash2;
	}

	function startVideo(video, container, srcelem)
	{
		var o;
		var v;
		
		o = document.getElementById(Container);
		v = document.getElementById(VideoDiv);

		var left = o.offsetLeft;
		var top = o.offsetTop;
		var width = o.offsetWidth;
		var height = width * 480 / 640; // o.offsetHeight;
		var maxheight = o.offsetHeight;
		
		while (o.offsetParent != null) {
			o = o.offsetParent;
			left += o.offsetLeft;
			top += o.offsetTop;
		}

        var x = event.x - left - event.offsetX; // + event.srcElement.width/2;
        var y = event.y - top - event.offsetY; // + event.srcElement.height/2;
        
		v.style.position = "absolute";
		v.style.left = left;
		v.style.top = top;
		v.style.width = width;
		v.style.height = maxheight;
		v.style.visibility = "visible";
		v.innerHTML = flash1 + "video="+video+"&end=video_end()&x=" + x + "&y=" + y + "&height=480&duration=1000" + flash2;
	}

	function disableVideo()
	{
		var v = document.getElementById(VideoDiv);
		v.style.visibility = "hidden";
		// v.innerHTML = "";
	}
	
	function video_end()
	{
		disableVideo();
	}

	theObjects = document.getElementsByTagName("embed");
	for (var i = 0; i < theObjects.length; i++) {
	theObjects[i].outerHTML = theObjects[i].outerHTML;
	}

	function do_click(elem) {
	    var a = elem.attributes["xlink:href"];
	    if (a != null) 
	        {
	            var v = a.value;
	            if (v.indexOf(".flv") > 0) {
	                startVideo(v, null, null);
	        }
	        else 
	        {
                window.location = v;
	        }
	    }
	}
	
	function initScripts() {
	    var el = document.getElementsByTagName("table");
	    var l = el.length;
	    for (i = 0; i < l; ++i) {
	        var a = el[i].attributes["xlink:href"];
	        if (a != null) {
	            el[i].onclick = function() { do_click(this); }
	            el[i].style.cursor = "hand";
	        }
	    }
	}

	initScripts();