function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			fuct;
		}
	}
}

function insertAfter(newElement,targetElement) {
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement,targetElement.nextSibling);
	}
}

function addClass(element,value) {
	if (!element.className) {
		element.className = value;
	} else {
		newClassName = element.className
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}
	
function findSubsection() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("header")) return false;
	var currenturl = window.location.href;
	var aboutusurl = "/aboutus/";
	var communityurl = "/community/";
	var howtohelpurl = "/howtohelp/";
	var partnersurl = "/partners/";
	var resourcesurl = "/resources/";
	if (currenturl.indexOf(aboutusurl)) {
		header.style.backgroundImage = "url(/css/images/lilgirl.jpg)";
		//alert(window.location.href);
		}
	else if (currenturl.indexOf(communityurl)) {
		header.style.backgroundImage = "url(/css/images/momandchild.jpg)";
		}
	else if (currenturl.indexOf(howtohelpurl)) {
		header.style.backgroundImage = "url(/css/images/grandma.jpg)";
		}
	else if (currenturl.indexOf(partnersurl)) {
		header.style.backgroundImage = "url(/css/images/elderlyman.jpg)";
		}
	else if (currenturl.indexOf(resourcesurl)) {
		header.style.backgroundImage = "url(/css/images/coach.jpg)";
		}
	else {
		header.style.backgroundImage = "url(/css/images/coach.jpg)";
		}
}

addLoadEvent(findSubsection);

