function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function highlightRows() {
	if (!document.getElementById('mainMenuList')) return false;
		var rows = document.getElementById('mainMenuList').getElementsByTagName('li');
		for (var i=0; i<rows.length; i++) {
			if (rows[i].parentNode.id == 'mainMenuList') {
				rows[i].getElementsByTagName('div')[0].className += ' sampleComplaintsJS';
				rows[i].onmouseover = function() {
					this.parentNode.style.borderRight = '1px solid #D9D1B9';
					this.style.backgroundColor = '#D9D1B9';
					var divs = this.getElementsByTagName('div');
					for (var i=0; i<divs.length; i++) {
						divs[i].style.cursor = 'default';
						divs[i].style.height = 'auto';
						if(document.getElementById('mainMenuList').offsetHeight < divs[i].offsetHeight) {
							document.getElementById('mainMenuList').style.height = divs[i].offsetHeight + 'px';
						} else {
							divs[i].style.height = document.getElementById('mainMenuList').offsetHeight + 'px';
						}
					}
				}
				rows[i].onmouseout = function() {
					var ulDivs = this.parentNode.getElementsByTagName('div');
					for (var i=0; i<ulDivs.length; i++) {
						ulDivs[i].style.height = '0';
					}
					this.parentNode.style.borderRight = '0';
					this.style.backgroundColor = 'transparent';
				}
				rows[i].onclick = function() {
					var inputs = this.getElementsByTagName('input');
					for (var i=0; i<inputs.length; i++) {
						inputs[i].checked = true;
					}
				}
			}
		}
}

function prepareLabels() {
		if(!document.getElementById("labelContainer")) return false;
		document.getElementById('labelContainer').style.visibility = 'hidden';
		var elements = document.getElementById("mainMenuList").getElementsByTagName("div");
		for (var i=0; i<elements.length; i++) {
			elements[i].style.height = "0";
			elements[i].style.overflow = "hidden";			
		}
}

function printBackbutton() {
	document.write('<input type="button" value="&#8249;&#8249; Previous" onclick="history.go(-1)" class="buttonBtn"> ');
}

function openWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function doPopups() {
	if (!document.getElementsByTagName) return false;
	var links=document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popup")) {
			links[i].onclick=function() {
				window.open(this.href, "", "top=10,left=10,width=820,height=650,scrollbars=yes");
				return false;
			}
		}
		if (links[i].className.match("popup1")) {
			links[i].onclick=function() {
				window.open(this.href, "", "top=10,left=10,width=820,height=460,scrollbars=no");
				return false;
			}
		}
	}
}
