
function popSWF(uri, width, height) {
	var newswf = document.createElement('OBJECT');
	newswf.type = "application/x-shockwave-flash";
	newswf.width = width;
	newswf.height = height;
	newswf.data = uri;
	var newpropmovie = document.createElement('PARAM');
	newpropmovie.name = "movie";
	newpropmovie.value = uri;
	var newproptran = document.createElement('PARAM');
	newproptran.name = "wmode";
	newproptran.value = "transparent";
	newswf.appendChild(newpropmovie);
	newswf.appendChild(newproptran);
	_popElem(newswf, width, height);
}

function _popElem(element, width, height) {
	popin = document.getElementById('_POPIN');
	ps = getPageSize();
	var lefter = (ps[2] - width) / 2;
	var topper = (ps[3] - height) / 2;
	popin.style.left = lefter + 'px';
	popin.style.top = topper + 'px';
	popin.style.width = width+'px';
	popin.style.height = height+'px';
	document.getElementById('_POP').style.display = 'block';
	popin.appendChild(element);
}

function popget_event(e) {
	if(!e) {
		var e = window.event;
	}
	if (e.srcElement) {
		e.target = e.srcElement;
	}
	if(e.target) {
		if (e.target.nodeType == 3) {
			e.target = e.target.parentNode;
		}
	}
	if(e.clientX || e.clientY) {
		if(document.documentElement) {
			try {
				e.pageX = e.clientX + document.documentElement.scrollLeft;
				e.pageY = e.clientY + document.documentElement.scrollTop;
			} catch (error) {
				
			}
		} else {
			e.pageX = e.clientX + document.body.scrollLeft;
			e.pageY = e.clientY + document.body.scrollTop;
		}
	}
	return e;
}

function popadd_event(event_name, function_name, event_target) {
/*	add_event("mousedown", myFunction, document.getElementById('elementId'));
	add_event("mouseover", myFunction, false); //defaults to document/document.body
	add_event("load", init, window);
	*/
	if(!event_target) {
		if(document.documentElement) {
			event_target = document;
		} else {
			event_target = document.body;
		}
	}
	if (event_target.attachEvent) {
		popremove_event(event_name, function_name, event_target);
		event_target.attachEvent("on" + event_name, function_name);
	} else if(event_target.addEventListener) {
		event_target.addEventListener(event_name, function_name, true);
	} else {
		alert('Your browser does not appear to support attachEvent OR addEventListner; Please either update your current browser or use an alternative.');	
	}
}

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 popremove_event(event_name, function_name, event_target) {
	if(!event_target) {
		if(document.documentElement) {
			event_target = document;
		} else {
			event_target = document.body;
		}
	}
	if (event_target.detachEvent) {
		event_target.detachEvent("on" + event_name, function_name);
	} else if(event_target.removeEventListener){
		event_target.removeEventListener(event_name, function_name, true);
	} else {
		alert('Your browser does not appear to support detachEvent OR removeEventListener; Please either update your current browser or use an alternative.');	
	}
}

function popstop_event(e) {
	if (e.stopPropagation) {
		e.stopPropagation();
		if(e.preventDefault) {
			e.preventDefault();	
		}
	} else {
		e.cancelBubble = true;
		e.returnValue = false;
	}
}

var popin = false;

function _pophide() {
	document.getElementById('_POP').style.display = 'none';
	document.getElementById('_POPIN').innerHTML = '';
}

function _popinit() {
	var ph = document.createElement('DIV');
	ph.id = '_POP';
	var pho = document.createElement('DIV');
	pho.id = '_POPOUT';
	popadd_event('click', _pophide, pho);
	var phi = document.createElement('DIV');
	phi.id = '_POPIN';
	ph.appendChild(pho);
	ph.appendChild(phi);
	document.body.appendChild(ph);
}

popadd_event('load', _popinit, window);