function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


navHover = function() {
	var lis = document.getElementById("globalnav").getElementsByTagName("li");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);



/*function preparePopup() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].getAttribute("class") == "popup") {
      lnks[i].onclick = function() {
        popUp(this.getAttribute("href"));
        return false;
      }
    }
  }
}

function popUp(winURL) {
  window.open(winURL,"popup","width=320,height=480");
}*/


function emailObfuscate() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("contact_gen")) return false;
  var job = document.getElementById("contact_gen");
  var ems = job.getElementsByTagName( 'em' );
  for( var i=0; i<ems.length; i++ ){
    if( ems[i].firstChild &&
        ems[i].firstChild.nodeValue.match( /\s+?\[at]\s+?/g ) ){
      var str = ems[i].firstChild.nodeValue;
          str = str.replace( /\s+?\[(?:dot|period)]\s+?/g, '.' );  // replaces all .
          str = str.replace( /\s+?\[(?:at)]\s+?/g, '@' );          // replaces the @
          str = str.replace( /\s+?\[(?:dash|hyphen)]\s+?/g, '-' ); // replaces all -
      var a = document.createElement( 'a' );
          a.setAttribute( 'href', 'mailto:'+str );
          a.appendChild( document.createTextNode( str ) );
      ems[i].parentNode.replaceChild( a, ems[i] );
    }
  }
}

/*function emailObfuscate1() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("job_financial")) return false;
  var job = document.getElementById("job_financial");
  var ems = job.getElementsByTagName( 'em' );
  for( var i=0; i<ems.length; i++ ){
    if( ems[i].firstChild &&
        ems[i].firstChild.nodeValue.match( /\s+?\[at]\s+?/g ) ){
      var str = ems[i].firstChild.nodeValue;
          str = str.replace( /\s+?\[(?:dot|period)]\s+?/g, '.' );  // replaces all .
          str = str.replace( /\s+?\[(?:at)]\s+?/g, '@' );          // replaces the @
          str = str.replace( /\s+?\[(?:dash|hyphen)]\s+?/g, '-' ); // replaces all -
      var a = document.createElement( 'a' );
          a.setAttribute( 'href', 'mailto:'+str+'?subject=Attn Raleigh Knowles - Re:Financial Applications Conversion/Trainer Position');
          a.appendChild( document.createTextNode( "Send your resume" ) );
      ems[i].parentNode.replaceChild( a, ems[i] );
    }
  }
}

function prepareInternalnav() {
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("hiddensections")) return false;
	var nav = document.getElementById("hiddensections");
	var links = nav.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		var sectionId = links[i].getAttribute("href").split("#")[1];
		if (!document.getElementById(sectionId)) continue;
		document.getElementById(sectionId).style.display = "none";
		links[i].destination = sectionId;
		links[i].onclick = function() {
			showSection(this.destination);
			return false;
		}
	}
}*/

addLoadEvent(emailObfuscate);