
// Navigation layer swap function

if (navigator.userAgent.indexOf("Opera")!=-1
    && document.getElementById) type="OP";
if (document.all) type="IE";
if (document.layers) type="NN";
if (!document.all && document.getElementById) type="MO";

function ShowNav(layervalue) {

var id = layervalue;

  if (type=="IE") {
	eval("document.all." + id + ".style.display='" + "block" + "'");
  	}
  if (type=="NN") {
  	eval("document." + id + ".display='" + "block" + "'");
  	}
  if (type=="MO" || type=="OP") {
  	eval("document.getElementById('" + id + "').style.display='" + "block" + "'");
  	}
}



// Send to Friend validation and layer swap functions

function swapLayers(layer,vis1) {
	var obj1;
	if (document.getElementById) {
		//NS6+MSIE5
		obj1 = document.getElementById(layer).style;
	}
	else if (document.all) {
		//MSIE4
		obj1 = document.all[layer].style;
	}
	else if (document.layers) {
		//NS4.x
		obj1 = document.layers[layer];
	}
	obj1.visibility = vis1;
}



function CheckFriend() {
	if (document.all) {
		Check_IE();
	}
	else {
		Check_NS();
	}
}

function Check_NS() {
	var yn = document.EmailFriend.YourName.value;
	var fr = document.EmailFriend.FriendName.value;
	var fe = document.EmailFriend.FriendEmail.value;
	var string1 = document.EmailFriend.FriendEmail.value;

	if (string1.indexOf("@")==-1) {
		fe = "";
		}
	if (string1.indexOf(".")==-1) {
		fe = "";
		}
    for (var i=0; i<string1.length; i++) {
        ch = string1.charAt(i)
        if (! ((ch >= "A" && ch <= "Z")
        		|| (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) ) {
             fe = "";
             }
    }

	var loopthru = new Array(yn, fr, fe);
	var trigger = "20";
	var require = new Array("Your Name", "Friend's Name", "Friend's Email");
	var result = "";
	for (loop=0; loop < 3; loop++) {
		if (loopthru[loop] == "" || loopthru[loop] == " ") {
			trigger = loop;
			result = result + require[loop] + "\n";
		}
		else {
		}
	}
	if (trigger == "20") {
		EmailFriendPost(yn, fr, fe);
	}
	else {
		window.alert("Please complete the following fields \nbefore submitting this form: \n\n" + result);
	}
}

function Check_IE() {
	var yn = document.EmailFriend.YourName.value;
	var fr = document.EmailFriend.FriendName.value;
	var fe = document.EmailFriend.FriendEmail.value;
	var string1 = document.EmailFriend.FriendEmail.value;

	if (string1.indexOf("@")==-1) {
		fe = "";
		}
	if (string1.indexOf(".")==-1) {
		fe = "";
		}
    for (var i=0; i<string1.length; i++) {
        ch = string1.charAt(i)
        if (! ((ch >= "A" && ch <= "Z")
        		|| (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) ) {
             fe = "";
             }
    }

	var loopthru = new Array(yn, fr, fe);
	var trigger = "20";
	var require = new Array("layerA", "layerB", "layerC");
	for (loop=0; loop < 3; loop++) {
		if (loopthru[loop] == "" || loopthru[loop] == " ") {
			trigger = loop;
			swapLayers(require[loop],'visible');
			var showit = "document.all." + require[loop] + ".style.display = ''";
			eval (showit);
		}
		else {
			swapLayers(require[loop],'hidden');
			var showit = "document.all." + require[loop] + ".style.display = 'none'";
			eval (showit);
		}
	}
	if (trigger == "20") {
	EmailFriendPost(yn, fr, fe);
	}
	else {
	}
}


function EmailFriendPost(yn, fr, fe) {
	this.document.EmailFriend.submit();
}

function RedirectTestOnly() {
	window.location.href = "Thanks.htm";
}
