/** No Spam **/
function noSpam(user,domain){
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

/** Highlight **/

function lightOn(allCubes, toLight){
	for(var j=1;j<allCubes+1;j++){
		var n=document.getElementById('cube'+j);
		  if(n){
		      var rep=n.className.match(' '+"highlight")?' '+"highlight":"highlight";
		      n.className=n.className.replace(rep,'');
		  }
	}
	for(var i=0;i<toLight.length;i++){
		var n=document.getElementById('cube'+toLight[i]);
		  if(n){
		    n.className+=n.className?' highlight':'highlight';
		  }
	}
}
/** SlideShow **/

var numSlides = 0;
var currentSlide = 0;

function selectSlide(slideItem) {
	for (var i=0;i<numSlides;i++) {
		if (document.getElementById("image"+i).style.visibility = "visible") {
			document.getElementById("image"+i).style.visibility = "hidden"
		}
	}
	if (document.getElementById("copy"+slideItem) == null || document.getElementById("copy"+slideItem).firstChild == null ) {
		theCaption = "This Slide does not have a caption."
	}else{
		theCaption = document.getElementById("copy"+slideItem).firstChild.nodeValue;
	}
	document.getElementById("copy").innerHTML = theCaption;
	document.getElementById("image"+slideItem).style.visibility = "visible";
	currentSlide = slideItem;
}

function switchSlide(sDir) {
	var theCaption;
	var newSlide;	
	if (sDir == null) {
		newSlide = currentSlide;
	} else {
		newSlide = currentSlide + sDir;
	}
	if (newSlide == numSlides) {
		newSlide = 0;
	} else if (newSlide == -1) {
		newSlide = numSlides - 1;
	}
	document.getElementById("image"+currentSlide).style.visibility = "hidden";
	if (document.getElementById("copy"+newSlide) == null || document.getElementById("copy"+newSlide).firstChild == null ) {
		theCaption = "This Slide does not have a caption."
	}else{
		theCaption = document.getElementById("copy"+newSlide).firstChild.nodeValue;
	}
	document.getElementById("copy").innerHTML = theCaption;
	document.getElementById("image"+newSlide).style.visibility = "visible";
	currentSlide = newSlide;
}
function switchDisplay(swapMe){
	if(document.getElementById("slideCaption").style.visibility=="visible"){
		swapMe.firstChild.nodeValue="Show Caption";
		document.getElementById("slideCaption").style.visibility="hidden";
	}else{
		swapMe.firstChild.nodeValue="Hide Caption";
		document.getElementById("slideCaption").style.visibility="visible";
	}
}
function init(){
	var allSlides = document.getElementById("theShow").getElementsByTagName("div");
	numSlides = 0; 
	for (i= 0; i<allSlides.length; i++) { 
		if (allSlides[i].className == "slides") {
			numSlides++;
		}
	}
	switchSlide();
}

/* Clear/Populate Input Fields */

window.onload = function () {

	if (!document.getElementsByTagName) return true;

	ourForms = document.getElementsByTagName('form');
	var numForms = ourForms.length;
	for (var i=0;i<numForms;i++) {
		var numFormElements = ourForms[i].elements.length;
		for (var j=0;j<numFormElements;j++) {

			var el = ourForms[i].elements[j];
			if (el.type == "submit") continue;
			if (el.type == "text") {
				var ourClassName = el.className;
				if (ourClassName.match('auto-clear') || ourClassName.match('populate')) {
					if (el.value == '') el.value = el.title;
				}
				if (el.className.match('auto-clear')) {
					el.onfocus = function () {
						if (this.value == this.title) this.value = '';
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);
					el.onblur = function () {
						if (this.value == '') this.value = this.title;
					}
					if (el.captureEvents) el.captureEvents(Event.BLUR);
				}
			}

			if (el.type == "textarea") {
				var ourClassName = el.className;
				if (ourClassName.match('auto-clear') || ourClassName.match('populate')) {
					if (el.value == '') el.value = el.title;
				}
				if (el.className.match('auto-clear')) {
					el.onfocus = function () {
						if (this.value == this.title) this.value = '';
					}
					if (el.captureEvents) el.captureEvents(Event.FOCUS);
					el.onblur = function () {
						if (this.value == '') this.value = this.title;
					}
					if (el.captureEvents) el.captureEvents(Event.BLUR);
				}
			}

		}

	}

}
