function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}

sfHover = function() {
	var sfEls = document.getElementById("disciplines").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function insertTop(obj) {
	d=document.createElement("div");
	d.className="bt";
    d2=document.createElement("div");
    d.appendChild(d2);
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj) {
	d=document.createElement("div");
	d.className="bb";
    d2=document.createElement("div");
    d.appendChild(d2);
	obj.appendChild(d);
}

function initCB()
{
	var divs = document.getElementsByTagName('div');
	var cbDivs = [];
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == 'rounded') cbDivs[cbDivs.length] = divs[i];
	}
	var thediv, outer, i1, i2;
	for (var i = 0; i < cbDivs.length; i++) {
		thediv = cbDivs[i];
		outer = document.createElement('div');
		outer.className = thediv.className;
		outer.className = thediv.className.replace('cbb', 'cb');
		thediv.className = 'i3';
		thediv.parentNode.replaceChild(outer, thediv);
		i1 = document.createElement('div');
		i1.className = 'i1';
		outer.appendChild(i1);
		i2 = document.createElement('div');
		i2.className = 'i2';
		i1.appendChild(i2);
		i2.appendChild(thediv);
		insertTop(outer);
		insertBottom(outer);
	}
}

function init() {
	if (!document.getElementById || !document.createElement) return; // One check for compatibility
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    if (_timer) clearInterval(_timer);
	document.getElementsByTagName('body')[0].className += ' js';
	if (window.attachEvent) sfHover();
	initCB();
	initPopups();
};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}


function initPopups() {
	// check to see that the browser supports the getElementsByTagName method
	// if not, exit the loop 
	if (!document.getElementsByTagName) {
		return false; 
	} 
	// create an array of objects of each link in the document 
	var popuplinks = document.getElementsByTagName("a");
	// loop through each of these links (anchor tags) 	
	for (var i=0; i < popuplinks.length; i++) {	
		// if the link has a class of "popup"...	
		if (popuplinks[i].getAttribute("class") == "popup") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUp(this.getAttribute("href"));	
			return false; 	
			} 	
		}
	} 
} 

function openPopUp(linkURL) {
window.open(linkURL,'helpfulpopup','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=400');
}


/* for other browsers */
window.onload = init;
document.execCommand('BackgroundImageCache', false, true);