//adds js_hide.css if javascript is supported
function addCSS(path) {
	if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
		document.write('<link rel="stylesheet" type="text/css" title="KU Style" href="'+path+'" />');
	}
}

//setup initialisation function
function addonLoad(func) {
	//.. gecko, safari, konqueror and generic
	if(typeof window.addEventListener != 'undefined') {
		window.addEventListener('load', func, false);
	}
	//.. opera 7
	else if(typeof document.addEventListener != 'undefined') {
		document.addEventListener('load', func, false);
	}
	//.. win/ie
	else if(typeof window.attachEvent != 'undefined') {
		window.attachEvent('onload', func);
	}
}

/* cssjs, written by Christian Heilmann (http://icant.co.uk)
 * eases the dynamic application of CSS classes via DOM
 * parameters: action a, object o and class names c1 and c2 (c2 optional)
 * actions: swap exchanges c1 and c2 in object o
 *			add adds class c1 to object o
 *			remove removes class c1 from object o
 *			check tests if class c1 is applied to object o
 * example:	cssjs('swap',document.getElementById('foo'),'bar','baz');
 *  modified by BF to avoid replacing substrings of classes, i.e. cssjs('replace',link,'on')
 *	turning className='hw_concert on' into 'hw_ccert on' */

function cssjs(a,o,c1,c2) {
	switch (a){
		case 'swap':
			o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			//var rep=o.className.match(' '+c1)?' '+c1:c1;	o.className=o.className.replace(rep,'');
			o.className=o.className.replace(new RegExp('\\b'+c1+'\\b'),'');
		break;
		case 'check':
			return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}
