//<![CDATA[

/* function to have multiple events within the 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();
    }
  }
}

function clearText(input) {
	if (input.defaultValue == input.value) {
		input.value = "";
	}
}

// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
 
//Modified by Justin
function decodeEmail(coded, key, alternateText, linkClass) {
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++) {
		if (key.indexOf(coded.charAt(i))==-1) {
			ltr = coded.charAt(i);
			link += (ltr);
		} else {
			ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length;;
			link += (key.charAt(ltr));
		}
	}
	if (alternateText) {
		if (linkClass) {
			document.write("<a href='mailto:"+link+"' class='" + linkClass + "'>" + alternateText + "</a>")
		} else {
			document.write("<a href='mailto:"+link+"'>" + alternateText + "</a>")
		}
	} else {
		if (linkClass) {
			document.write("<a href='mailto:"+link+"' class='" + linkClass + "'>" + link + "</a>")
		} else {
			document.write("<a href='mailto:"+link+"'>" + link + "</a>")
		}
	}
}

/* random image loader script */
var rand1 = 0;
var heroImage = 0;
var limit = 4;

function swapPic() {
	do {
		var randnum = Math.random();
		rand1 = Math.round((limit) * randnum);
	} while (rand1 == heroImage);
	heroImage = rand1;
	setTimeout("run()",500);
}

function run() {
	document.images['heroImage'].src = 'i/content/modtec_hero-' + heroImage + '.jpg';
}

// ]]>