/*
	overLayFlash JS: Fullsize FLash Overlays 
	by Ken Murayama - http://www.muraken.biz

*/
var OLF = {

	on_hide : null,

	//
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.org
	//
	getPageScroll : function()
	{
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	},

	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	//
	getPageSize : function()
	{
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	},

	show : function(file, ver, vars, on_hide)
	{
		this.on_hide = on_hide;

		var br = (navigator.appName.indexOf("Microsoft") != -1) ? "ie" : "other";

		var arrayPageSize = OLF.getPageSize();
		var arrayPageScroll = OLF.getPageScroll();	

		var objBody = document.body;
		var objOverlay = document.createElement("div");
	
		var vars_str = "";
		if(vars) for (i in vars) vars_str += "&" + i + "=" + vars[i];
	
		var myTag= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" width="100%" height="100%" id="overlayFlash" align="middle">' +
				'<param name="allowScriptAccess" value="sameDomain" />' +
				'<param name="movie" value="'+file+'" />' + 
				'<param name="quality" value="high" />' +
				'<param name="salign" value="lt" />' +
				'<param name="wmode" value="transparent" />' +
				'<param name="bgcolor" value="#ffffff" />' +
				'<param name="FlashVars" value="br='+br+vars_str+'" />' +
				'<embed src="'+file+'" quality="high" salign="lt" swLiveConnect=true wmode="transparent" bgcolor="#ffffff" FlashVars="br='+br+vars_str+'" width="100%" height="100%" name="overlayFlash" id="overlayFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
				'</object>';
		
		objOverlay.setAttribute('id','overlay');
//		objOverlay.onclick = function () {OLF.hide(); return false;}
		objOverlay.style.display = 'block';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = '200';
	 	objOverlay.style.width = '100%';
	 	objOverlay.style.height = '100%';
//		objOverlay.style.height = (arrayPageSize[1] + 'px');
		objOverlay.innerHTML = myTag;
		objBody.insertBefore(objOverlay, objBody.firstChild);
//		window.document.overlayFlash.onclick = function () {OLF.hide(); return false;}
	},

	hide : function()
	{
		document.body.removeChild(document.body.firstChild);
		if(this.on_hide) {this.on_hide(); this.on_hide = null;}
	}
};
