﻿// JScript File

	var oMask = new objNode("mask",0,0,0,0);
	var oFlash = null;
	
	var oScreen = {
		oW:0, oH:0, cW:0, cH:0, sW:0,
		setup:function() {
			this.oW = document.body.offsetWidth;
			this.oH = document.body.offsetHeight;
			this.cW = document.body.clientWidth;
			this.cH = (document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight;
			this.sT = (document.documentElement.scrollTop)?document.documentElement.scrollTop:document.body.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 objNode(name, item, x, y, w, h, fw, fh) {
		this.name = name;
		this.show = false;
		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.item = item;
		this.flash = { w:fw, h:fh };
		this.filename = function() {
			return "loader_" + this.flash.w + "x" + this.flash.h + ".swf?passVar=" + this.item;
		}
	}

	function toggleMask(item,description,format) {
		//alert(document.location.href);
    switch(format) {
			case "280x224":
				oFlash = new objNode("flashObj",item,0,0,290,295,280,224);
			break;
			default :
				oFlash = new objNode("flashObj",item,0,0,330,255,320,180);
			break;
		}
		var obj = document.getElementById("loadDiv");
		if (!oMask.show) {
			oScreen.setup();
			obj.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+oFlash.flash.w+'" height="'+oFlash.flash.h+'" id="loader" align="middle">'
											+  '<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />'
											+  '<param name="movie" value="'+oFlash.filename()+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
											+  '<embed src="'+oFlash.filename()+'" quality="high" bgcolor="#ffffff" width="'+oFlash.flash.w+'" height="'+oFlash.flash.h+'" name="loader" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
											+'</object>';
			var videoTitle = document.getElementById("videoTitle");
			videoTitle.style.width = (oFlash.w - 10)+"px";
			videoTitle.innerHTML = description;
	    document.getElementById("flashContainer").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().focus();
		} else {
			oMask.show = false;
			oMask.obj().style.display = "none";
			oFlash.obj().style.display = "none";
			obj.innerHTML = "";
		}
	}

	window.onresize = 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,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);
			}
		}
	}


