
// Detect the browser
//    browserName = { konqueror | safari | omniweb | opera | webtv | icab | msie | mozilla | netscape }
function isBrowser(browserName) {
	if (browserName == 'netscape' || browserName == 'mozilla')
		browserName = 'compatible';
	var detect = navigator.userAgent.toLowerCase();
	return (detect.indexOf(browserName) + 1);
}

// Create a popup window with a URL and (optionally) width and height
function popUp(URL, width, height) {
	day = new Date();
	id = day.getTime();
	width = (width ? width : 400);
	height = (height ? height : 300);
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left=20,top=15');");
}

function popUpStrict(URL, width, height) {
	day = new Date();
	id = day.getTime();
	width = (width ? width : 400);
	height = (height ? height : 300);
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left=20,top=15');");
}

// Create a popup window with the Flash presentation
function viewPresentation() {
	day = new Date();
	id = day.getTime();
	URL = "/flash.html";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=818,height=391,left=20,top=15');");
}

// Navigate to a URL in the window that opened this one, and optionally close this window
function openerLink(URL, closeThisWindow) {
	if (window.opener && !window.opener.closed) {
		window.opener.location.href = URL;
	} else {
		window.open(URL);
	}
	if (closeThisWindow) {
		window.close();
	} else {
		location.href = location.href;
	}
}

if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode) {
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling)
				this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}

	HTMLElement.prototype.insertAdjacentText = function(where,txtStr) {
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}

