if (document.getElementById && document.createTextNode){canDOM=true}

//OPEN FOLD i.e. Expand Collapse
function openFold(id){
	if (canDOM && document.getElementById(id)){
		elm = document.getElementById(id);
		elm.style.display = elm.style.display=='block'||elm.style.display==''?'none':'block';
		expColImage(id);
	}
}

//TEXT SIZE CHANGE
function setTextSize(size) {
	switch(size) {
		case "small":
			document.body.style.fontSize = "80%"; break;
		case "medium":
			document.body.style.fontSize = "90%"; break;
		case "large":
			document.body.style.fontSize = "110%"; break;
		default:
			document.body.style.fontSize = "90%";					
	}
}

//SWAP IMAGE
function expColImage(id){
	var i, imgs, tmp;
	if (document.images){
		imgs=document.getElementsByTagName('img');
		for(i=0;i<imgs.length;i++){
			if(imgs[i].id == id+"_img") {
				imgs[i].src=imgs[i].src.replace(/(plus|minus)/, (document.getElementById(id).style.display == "none"?"plus":"minus"));
			}		
			if(/exp(Up|Down)/.test(imgs[i].src)) {
				imgs[i].src=imgs[i].src.replace(/(Up|Down)/, (document.getElementById(id).style.display == "none"?"Down":"Up"));
			}
		}
	}
}

//////////////////////////////////////// WINDOW ONLOAD ////////////////////////////////////

// USE newOnLoad or addOnLoad - more efficient one is....?
function newOnload(myfunc)
{
	if(window.addEventListener)
		window.addEventListener('load', myfunc, false);
	else if(window.attachEvent)
		window.attachEvent('onload', myfunc);
}

//http://www.webreference.com/programming/javascript/onloads/
//http://blog.outofhanwell.com/2006/06/08/the-windowonload-problem-revisited/
//http://simonwillison.net/2004/May/26/addLoadEvent/
function addOnLoad(func) { 
	var oldonload = window.onload;  
	if (typeof window.onload != 'function'){   
		window.onload = func;
	} else {   
		window.onload = function() {   
			if (oldonload) {   
				oldonload();   
			} 
			func();   
		};   
	}   
}
