// AddLoadEvents
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


// Cloack e-mail addresses
function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
			if (alltags[i].className == "emailCloak") {
				var oldText = alltags[i].firstChild;
				var emailAddress = alltags[i].firstChild.nodeValue;
				var user = emailAddress.substring(0, emailAddress.indexOf("("));
				var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
				var newText = user+"@"+website;
				var a = document.createElement("a");
				a.href = "mailto:"+newText;
				var address = document.createTextNode(newText);
				a.appendChild(address);
				alltags[i].replaceChild(a,oldText);
			}
		}
	}
}
addLoadEvent(emailCloak);


// Open external links in a new window
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}
addLoadEvent(externalLinks);


// Show/Hide Divs
function fShowDiv(id) {
  document.getElementById(id).style.display="block";
}
function fHideDiv(id) {
  document.getElementById(id).style.display="none";
}

function fCheckOpt() {
	var intEmail = document.getElementById('fByEmail').checked;
	var intSMS = document.getElementById('fBySMS').checked;

	if (intEmail == true || intSMS == true)
	{
		document.getElementById('duration').className="show";
	}
	else
	{
		document.getElementById('duration').className="hide";
	}
}