// JavaScript Document

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 element = document.getElementById("mainMenuList");
	var rows = element.getElementsByTagName("li");
  for (var i=0; i<rows.length; i++) {
 	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++) {
			var id = divs[i].getAttribute('id');
			if(id.match('sample')) {
			var text = document.getElementById(id).innerHTML;
			document.getElementById('labelContainer').innerHTML=text;
			document.getElementById('labelContainer').style.visibility = 'visible';
			}
		}
	}
    rows[i].onmouseout = function() {
    this.parentNode.style.borderRight = "0";
    this.style.backgroundColor = "transparent";
	var divs = this.getElementsByTagName("div");
	  for (var i=0; i<divs.length; i++) {
		document.getElementById('labelContainer').style.visibility = 'hidden';
		}
    }
	rows[i].onclick = function() {
		var divs = this.getElementsByTagName("input");
		for (var i=0; i<divs.length; i++) {
			var id = divs[i].getAttribute('id');
			document.getElementById(id).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() {
      // Next two lines should be on one line
        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() {
      // Next two lines should be on one line
        window.open(this.href, "", "top=10,left=10,width=820,height=460,scrollbars=no");
        return false;
      }
    }
  }
}