/*==== shared functions =====*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
function addDomLoadedEvent(func) {
	if (document.all) {
		func();
	} else {
		window.document.addEventListener("DOMContentLoaded", func, true);
	}
}

/*==== Mouseover and Back to Home for H1 ====*/
/* Function to capture mouseover and mouseout events on the H1 */
function mouseOverH1() {
	if(!document.getElementById && !document.getElementsByTagName) return false;
	var el = document.getElementsByTagName('h1');
	el[0].onmouseover = function() {
		// When the mouse is over, change the background and cursor
		this.style.cursor = "pointer";
	}
	el[0].onmouseout = function() {
		// When the mouse is out, change cursor back
		this.style.cursor = "default";
	}
}
/* Function to return to Main Page when clicking H1 */
function clickH1() {
	if(!document.getElementById && !document.getElementsByTagName) return false;
	var el = document.getElementsByTagName('h1');
	el[0].onclick = function() {
		window.location.href = "/default.aspx"   
	}
}
addLoadEvent(clickH1);
addLoadEvent(mouseOverH1);
/*=== end Back to Home scripts ===*/

/*== Safe Email scripts ==*/
// open the client email with the specified address
function sendEmail(encodedEmail)
{
  // do the mailto: link
  location.href = "mailto:" + decodeEmail(encodedEmail);
}

// return the decoded email address
function decodeEmail(encodedEmail)
{
  // holds the decoded email address
  var email = "";

  // go through and decode the email address
  for (i=0; i < encodedEmail.length;)
  {
    // holds each letter (2 digits)
    var letter = "";
    letter = encodedEmail.charAt(i) + encodedEmail.charAt(i+1)

    // build the real email address
    email += String.fromCharCode(parseInt(letter,16));
    i += 2;
  }
  
  return email;
}
/*== end Safe Email scripts ==*/

/*== People page scripts --*/
function ShowTip(sender)
{
    var tipBox = document.getElementById("toolTip").style.visibility = "visible";
    var tipText = sender.title;
    document.getElementById("toolTip").innerText = tipText;
}

