/**
 * GenericUtilities v1.0
 * @author
 * (c) 2008 Adam Schwartz - http://polymath.mit.edu
 *
 * @license
 * Licensed under the MIT Licencse
 * http://www.opensource.org/licenses/mit-license.php
 * This is distributed WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

function $(string) {
	return document.getElementById(string);
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
function isString(s) {
	return typeof s == 'string';
}
function isArray(a) {
	if (a.constructor.toString().indexOf("Array") == -1) {
		return false;
	} else {
		return true;
	}
}
function isInArray(string, array) {
	if (isString(string) && isArray(array)) {
		for (is=0; is<array.length; is++) {
			if (array[is]==string) {
				return true;
			}
		}
	}
}
function newWindow(url,name) {
	popUpWindow = window.open(url, name, "width=820, height=1000, left=200, top=10, scrollbars=yes, resizable=yes");
}
function getPosition(objID) {
	xPos = $(objID).offsetLeft;
	yPos = $(objID).offsetTop;
	tempEl = $(objID).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return [xPos,yPos];
}
function setOpacity(objID, value) {
	$(objID).style.opacity = value/100;
	$(objID).style.filter = 'alpha(opacity=' + value + ')';
}
function loadCSS(cssHref) {
	var headID = document.getElementsByTagName("head")[0];         
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = cssHref;
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}
function loadScript(scriptHref) {
	var headID = document.getElementsByTagName("head")[0];         
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = scriptHref;
	headID.appendChild(newScript);
}