
/* Initialize Functions on window.onload Event
---------------------------------------------------------- */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/* Set Cookie
   Need to set a cookie for language, so visitors who have
   set French as their main lang, see it when they just hit
   www.genuitytraits.ca url. This targets the <a>'s on the
   English | French toggle in the header.
---------------------------------------------------------- */
function setCookie() {
	var frA = document.getElementById("fr");
	var enA = document.getElementById("en");
	// only one <a> exists depending on which language is active
	if (frA) {
		frA.onclick = new Function('document.cookie = "genuitycaLang=fr; expires=Thu, 2 Aug 2037 20:47:11 UTC; path=/"');
	}
	if (enA) {
		enA.onclick = new Function('document.cookie = "genuitycaLang=en; expires=Thu, 2 Aug 2037 20:47:11 UTC; path=/"');	
	}
}
addLoadEvent(setCookie);