function getPageScroll(){

	var yScroll;
	var xScroll;

	if (self.pageXOffset) {
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft){	 // Explorer 6 Strict
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		xScroll = document.body.scrollLeft;
	}

	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(xScroll,yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	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;
}


function getPageSize2(){
	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;
	}

	
	var arrPageScroll = getPageScroll();

//	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	arrayPageSize = arrPageScroll[0] + ',' + arrPageScroll[1] + ',' + windowWidth + ',' + windowHeight;
	return arrayPageSize;
}



//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function showFlash(objLink,no){
	var file = objLink.href;
	var ver = objLink.ver;
	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	}else{
		var br = "other";
	}
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objBody = document.body;
	var objOverlay = document.createElement("div");
	var myTag= ""

	myTag += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	myTag += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+'" width="100%" height="100%" id="overlayFlash" align="middle">';
	myTag += '<param name="allowScriptAccess" value="sameDomain" />';
	myTag += '<param name="movie" value="'+file+'" />';
	myTag += '<param name="quality" value="high" />';
	myTag += '<param name="salign" value="lt" />';
	myTag += '<param name="wmode" value="transparent" />';
	myTag += '<param name="bgcolor" value="#ffffff" />';
	myTag += '<param name="FlashVars" value="br='+br+'" />';
	myTag += '<embed src="'+file+'" FlashVars="no='+no+'" quality="high" salign="lt" swLiveConnect=true wmode="transparent" bgcolor="#ffffff" FlashVars="br='+br+'" 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.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.zIndex = '200';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = arrayPageSize[1]+'px';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	objOverlay.style.display = 'block';
	var now = new Date();
	var exitTime = now.getTime() + 500;

	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
		{
			objOverlay.innerHTML = myTag;
			break;
		}
	}
}

function hideFlash(){
	var objBody = document.body;
	objBody.removeChild(objBody.firstChild);
}

function wheel(event){
        if (event.preventDefault) {
                event.preventDefault();
        }
        event.returnValue = false;
}

function initoverLayFlash(){
	if (!document.getElementsByTagName){ return; }
	
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "overLayFlash")){
			anchor.onclick = function () {
				showFlash(this,anchor.getAttribute("no")); 
				return false;
			}
		}
	}
	
}


//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//

function addLoadEvent(func)
{	
//	var oldonload = window.onload;
//	alert(typeof window.onload);

//	if (typeof window.onload != 'function'){
//		window.onload = func;
//	} else {
//		window.onload = function(){
//		oldonload();
//		func();
//		}
//	}

  if (window.addEventListener) {
    window.addEventListener("load", func, false);
  } else if (window.attachEvent) {
    window.attachEvent("onload", func);
  }


}

addLoadEvent(initoverLayFlash);	
