/*        __//__ __ .____________________________________________
         /_///_//_///_                   /  v1.5  /  (c) 2009+  /
    _____________/                                           
  */
	/* onLoad / onResize / onScroll
	   ---- Use eg. ----
	   dlLoad.add(function() { alert("example"); });
	   -------------
	*/
	function dlVersion () {
		alert("Version 1.5");
	}
	dlLoad = {
		add:function(func) {
			var wLoad = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = function() { eval(func); }
			} else {
				window.onload = function() { wLoad(); eval(func); }
			}
		}
	};
	dlResize = {
		add:function(func) {
			var wResize = window.onresize;
			if (typeof window.onresize != 'function') {
				window.onresize = function() { func(); }
			} else {
				window.onresize = function() { wResize(); func(); }
			}
		}
	};
	dlScroll = {
		add:function(func) {
			var wScroll = window.onscroll;
			if (typeof window.onscroll != 'function') {
				window.onscroll = function() { func(); }
			} else {
				window.onscroll = function() { wScroll(); func(); }
			}
		}
	};
	var oScreen = { oW:0, oH:0, cW:0, cH:0, sW:0, setup:function() {
		this.oW = document.body.offsetWidth;
		this.oH = document.body.offsetHeight;
		if (document.documentElement && (document.documentElement.clientWidth != 0)) {
			this.cW = document.documentElement.clientWidth;
			this.cH = document.documentElement.clientHeight;
		} else {
			this.cW = document.body.clientWidth;
			this.cH = document.body.clientHeight;
		}
		if( typeof( window.pageYOffset ) == "number") {
			this.sT = window.pageYOffset;
		} else if (document.body.scrollTop) {
			this.sT = document.body.scrollTop;
		} else if (document.documentElement) {
			this.sT = document.documentElement.scrollTop;
		}
		if (document.body.scrollWidth) {
			this.oW = (document.body.scrollWidth>this.oW)?document.body.scrollWidth:this.oW;
		}
		if (document.body.scrollHeight) {
			this.oH = (document.body.scrollHeight>this.oH)?document.body.scrollHeight:this.oH;
		}
	}};
	
	function dlTabInitialise() {
		var obj = document.getElementById("tabContainer");
		var liNodes = obj.getElementsByTagName("LI");
		var aTags = [];
		for (var i=0; i<liNodes.length; i++) {
			if (liNodes[i].tagName == "LI") {
				var aNodes = liNodes[i].getElementsByTagName("A");
				for (var j=0; j<aNodes.length; j++) {
					if (aNodes[j].tagName == "A") {
						aTags[aTags.length] = aNodes[j];
						//aNodes[j].className = (aNodes[j].className == "")?"tabItem":"tabItem "+aNodes[j].className;
						aNodes[j].onclick = function() { return dlTabToggle(this); };
						aNodes[j].innerHTML = "<span>" + aNodes[j].innerHTML + "</span>";
						break;
					}
				}
			}
		}	
		var nodeItem = 0;
		for (var i=0; i<liNodes.length; i++) {
			if (liNodes[i].tagName == "LI") {
				var divNodes = liNodes[i].getElementsByTagName("DIV");
				for (var j=0; j<divNodes.length; j++) {
					if (divNodes[j].tagName == "DIV") {
						divNodes[j].id = getTabname(aTags[nodeItem].href);
						divNodes[j].className = (aTags[nodeItem].className.indexOf("selected") == -1)?divNodes[j].className:divNodes[j].className+" selected";
						//-- Resize --
						/*
						if (aTags[nodeItem].className.indexOf("selected") != -1) {
							document.getElementById("tabContainer").style.height = (divNodes[j].clientHeight+aTags[nodeItem].clientHeight)+"px";
						}
						*/
						nodeItem++;
						break;
					}
				}
			}
		}
	}
	function dlTabToggle(item) {
		clickedTab = getTabname(item.href);
		var obj = document.getElementById("tabContainer");
		var nodes = obj.getElementsByTagName("A");
		for (var i=0; i<nodes.length; i++) {
			if (nodes[i].tagName == "A") {
				itemTab = getTabname(nodes[i].href);
				oTab = document.getElementById(itemTab);
				if (itemTab != clickedTab) {
					if (nodes[i].className == "tabItem selected") {
						nodes[i].className = "tabItem";
						oTab.className = oTab.className.replace(" selected","");
					}
				} else {
						nodes[i].className = "tabItem selected";
						if (oTab.className.indexOf(" selected") == -1)
							oTab.className = oTab.className + " selected";
						//-- Resize --
						//document.getElementById("tabContainer").style.height = (oTab.clientHeight+nodes[i].clientHeight)+"px";
				}
			}
		}
		return false;
	}
	function getTabname(sHref) {
		return (sHref.substring(sHref.indexOf("#")+1,sHref.length));
	}
	/* SWF Mask */
	var oMask = new objNode("mask",'',0,0,0,0);
	var oFlash = null;
	
	function objNode(name, swf, flv, jpg, x, y, w, h, fw, fh) {
		this.name = name;
		this.show = false;
		this.filename = swf;
		this.flashvars = {
			swf:flv,
			jpg:jpg
		};
		this.obj = function() {
			return document.getElementById(this.name) 
		};
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;
		this.setup = function (x,y,w,h) {
			this.x = (x == null)?this.x:x;
			this.y = (y == null)?this.y:y;
			this.w = (w == null)?this.w:w;
			this.h = (h == null)?this.h:h;
			this.obj().style.left = this.x + "px";
			this.obj().style.top = this.y + "px";
			this.obj().style.width = this.w + "px";
			this.obj().style.height = this.h + "px";
		};
		this.flash = { w:fw, h:fh };
	}

	var storeW = 0;
	var storeH = 0;
	function toggleMask(description,format) {
		var loadObj = document.getElementById("loader");
		var obj = document.getElementById("loadDiv");
		var videoTitle = document.getElementById("videoTitle");
		var longDesc = document.getElementById("longDesc");
		oScreen.setup();
		if (typeof description != "object") {
			if (format != null) {
				oFlash = new objNode("flashObj",format.swf,format.flv,format.jpg,0,0,format.w+10,format.h+70,format.w,format.h);
				if (typeof format.longDesc != "undefined") {
					longDesc.longdesc = format.longDesc;
				}
			} else {
				oFlash = new objNode("flashObj");
			}
			if (!oMask.show) {
				storeW = format.w;
				storeH = format.h;
				swfobject.embedSWF(oFlash.filename, "loadDiv", format.w, format.h, "9.0.0", false, oFlash.flashvars, { wmode:"transparent" }, {});
				videoTitle.style.width = (oFlash.w - 10)+"px";
				videoTitle.innerHTML = description;
				document.getElementById("maskFlashContainer").style.width = oFlash.w+"px";
				oMask.show = true;
				oMask.setup(null,null,oScreen.oW,oScreen.oH);
				oFlash.setup((oScreen.cW-oFlash.w)/2,((oScreen.cH-oFlash.h)/2)+oScreen.sT,null,null);
				oMask.obj().style.display = "block";
				oFlash.obj().style.display = "block";
				oFlash.obj().style.backgroundColor = "#000000";
				oFlash.obj().style.color = "#FFFFFF";
				oFlash.obj().focus();
			} else {
				oMask.show = false;
				oMask.obj().style.display = "none";
				oFlash.obj().style.display = "none";
				storeW = (storeW == 0)?320:storeW;
				storeH = (storeH == 0)?240:storeH;
				swfobject.embedSWF("/Portals/0/content/swf/blank.swf", "loadDiv", storeW, storeH, "9.0.0", false, {}, { wmode:"transparent" }, {});
			}
		} else {
			if (!oMask.show) {	
				obj.style.display = "none";
				oFlash = new objNode("flashObj",format.swf,format.flv,format.jpg,0,0,format.w+10,format.h+70,format.w,format.h);
				if (typeof format.longDesc != "undefined") {
					longDesc.longdesc = format.longDesc;
				}
				videoTitle.style.width = (oFlash.w - 10)+"px";
				var formatDesc = "<span class='transcriptHeader'>"+description[0]+"</span><br/><br/>";
				for (i=1; i<description.length; i++) {
					formatDesc = formatDesc + description[i]+"<br/><br/>"
				}
				videoTitle.innerHTML = formatDesc;
				oMask.show = true;
				oMask.setup(null,null,oScreen.oW,oScreen.oH);
				oFlash.setup((oScreen.cW-oFlash.w)/2,((oScreen.cH-oFlash.h)/2)+oScreen.sT,null,null);
				oMask.obj().style.display = "block";
				oFlash.obj().style.display = "block";
				oFlash.obj().style.backgroundColor = "#FFFFFF";
				oFlash.obj().style.color = "#000000";
				oFlash.obj().focus();
			} else {
				oMask.show = false;
				oMask.obj().style.display = "none";
				obj.style.display = "none";
			}
		}
	}

	dlResize.add(
		function() {
			if (oMask.show) {
				oScreen.setup();
				if ((oFlash.x != ((oScreen.cW-oFlash.w)/2)) || (oFlash.y != ((oScreen.cH-oFlash.h)/2))) {
					oFlash.setup((oScreen.cW-oFlash.w)/2,((oScreen.cH-oFlash.h)/2)+oScreen.sT,null,null);
				}
				if (document.documentElement.scrollWidth) {
					oScreen.oW = document.documentElement.scrollWidth;
				}
				if ((oMask.w != oScreen.oW) || (oMask.h != oScreen.oH)) {
					oMask.setup(null,null,oScreen.oW,oScreen.oH);
				}
			}
		}
	);
	dlScroll.add(
		function() {
			if (oFlash != null && oMask.show) {
				oScreen.setup();
				oFlash.setup((oScreen.cW-oFlash.w)/2,((oScreen.cH-oFlash.h)/2)+oScreen.sT,null,null);
			}
		}
	);
