var win = window
var doc= document
if (doc.getElementsByTagName ){addEv(win, 'load', init)}
function init(){
	var cl = null;var showbnr = false;var showpr = false;var showstudy = false;var p = '<p></p>';var showbord = false;
	var cms = doc.getElementById("edit");
	if (cms){showbnr = true;showpr = true;showstudy = true};
	//apply box class to style side paneldivs only if they have content
	 if( !doc.divs )
	{doc.divs = doc.getElementsByTagName("div");}
	for (var ti=0;ti<doc.divs.length;ti++) {
		var div = doc.divs[ti];
			if (div.getAttribute("class") != null ) {cl = div.getAttribute("class")}
			if (div.getAttribute("className") != null ) {cl = div.getAttribute("className")}
			if (cl != null ) {
				if (cl == 'study'){
				if (div.firstChild.firstChild.innerHTML){
					var pnl = div.firstChild.firstChild.innerHTML.toLowerCase();
					pnl = replace(pnl ,'\n','');
					pnl = replace(pnl ,'\r','');
					if (pnl != p && pnl.length != 0){showstudy = true;}
					 }
				if (showstudy){ div.className = "panel";}
				}
				showstudy = false;
			if (cl == 'pr'){
				//apply promo class to promo box only if it has content;
				if (div.innerHTML){
					var pr = div.innerHTML.toLowerCase();
				//strip out line breaks
				pr = replace(pr ,'\n','');
				pr = replace(pr ,'\r','');
				if (pr != p && pr.length!= 0){showpr = true;}
				}
				if (showpr){ div.className= 'promo';}
			}
			}
		cl = 'null'}
	//apply banner class to page banner div only if it has content
	
	var bnr = doc.getElementById("banner");
	
	if (bnr.firstChild.firstChild.firstChild.innerHTML){
		var bnrc = bnr.firstChild.firstChild.firstChild.innerHTML.toLowerCase();
		bnrc = replace(bnrc ,'\n','');
		bnrc = replace(bnrc ,'\r','');
		if (bnrc != p && bnrc.length != 0){showbnr = true;}
	}
	if (showbnr){ bnr.className = "banner" ;
	if (!window.opera) doc.getElementById("leftColumn").style.top = -111;
	}
	//apply top border to  sectionlist items in main-section pages only if they have content
	doc.h = doc.getElementsByTagName("h3");
	for (var i=0;i<doc.h.length;i++) {
	if (doc.h[i].getAttribute("class")!= null ) {cl = doc.h[i].getAttribute("class")}
	if (doc.h[i].getAttribute("className")!= null ) {cl = doc.h[i].getAttribute("className")}
	if ( cl=="section"){
		if (doc.h[i].innerHTML){
		hc = doc.h[i].innerHTML;
		hc = replace(hc ,'\n','');
		hc = replace(hc ,'\r','');
		if (hc.length !=0){
				if(!doc.h[i].parentNode.getAttribute("class")) {showbord = true;}
				if (document.all && !window.opera){showbord=false;
					if(doc.h[i].parentNode.getAttribute("className") != "first" ) {showbord = true;}
				}}
				if (showbord) doc.h[i].parentNode.className = "border";
			}
		}
	cl = null;showbord=false}
	
}
function addEv(obj, evType, fn){
if(win.addEventListener){obj.addEventListener(evType, fn, false)
}else{obj.attachEvent("on"+evType, fn)}}
function replace(string,text,by) {
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}
