// JavaScript Document
  <!--
  
  function changeTab (tab) {
	ctab = document.getElementById(tab);
	
	PersonalTab = document.getElementById('PersonalTab');
	OrganizationTab = document.getElementById('OrganizationTab');
	NeedsTab = document.getElementById('SpecialNeedsTab');
	AssignmentsTab = document.getElementById('AssignmentsTab');
	PersonalTab.src = 'Images/V3/regTab-Personal02.png';
	OrganizationTab.src = 'Images/V3/regTab-Org02.png';
	NeedsTab.src = 'Images/V3/regTab-Needs02.png';
	//AssignmentsTab.src = 'Images/V3/regTab-Assignments02.png';
	
	personal = document.getElementById('Personal');
	organization = document.getElementById('Organization');
	specialNeeds = document.getElementById('SpecialNeeds');
	assignments = document.getElementById('Assignments');
	submitdiv = document.getElementById('pageOptions');
	personal.style.display = 'none';
	organization.style.display = 'none';
	specialNeeds.style.display = 'none';
	//assignments.style.display = 'none';
	submitdiv.style.display = 'none';
	
	switch (tab) {
		case 'Personal':
			personal.style.display = 'block';
			PersonalTab.src = 'Images/V3/regTab-Personal01.png';
			break;
		case 'Organization':
			organization.style.display = 'block';
			OrganizationTab.src = 'Images/V3/regTab-Org01.png';
			break;
		case 'SpecialNeeds':
			specialNeeds.style.display = 'block';
			NeedsTab.src = 'Images/V3/regTab-Needs01.png';
			submitdiv.style.display = 'block';
			break;
		//case 'Assignments':
			//assignments.style.display = 'block';
			//AssignmentsTab.src = 'Images/V3/regTab-Assignments01.png';
			//submitdiv.style.display = 'block';
			//break;
		default:
			personal.style.display = 'block';
			PersonalTab.src = 'Images/V3/regTab-Personal01.png';
			break;
	}
	
	
}

  // -------------->  OnSubmit Validation  <----------- //
  //addLoadListener(init);

function init()
{
  document.forms["form3"].onsubmit = validateFields();

  return true;
}

function fadeIn(id, opacity) {
	opacitydiv = document.getElementById(id);
	opacitydiv.style.display = 'block';
	opacity += .05;
	opacitydiv.style.opacity = opacity;
	opacitydiv.style.MozOpacity = opacity;
	opacitydiv.KhtmlOpacity = opacity;
	opacitydiv.style.filter = "alpha(opacity=" + (opacity * 50) + ")";
	if (opacity < 1) {
		setTimeout("fadeIn('" + id + "', " + opacity + ")", 1);
	}
}

function lockSubmit()
{

  //clearText(UserCart);
  //usrStatus.style.backgroundColor = '#FF0000';
  //UserCart.style.backgroundColor = '990000';
  //replaceText(usrStatus, "Updating Cart");
	//MM_swapImage('submit', '', 'Images/Processing.png', 1);
	//MM_swapImage('submit2', '', 'Images/Processing.png', 1);
  if (validateFields()) {
	try
	{
	var button = document.getElementById("submit");
	button.src = 'Images/Processing.png';
	button.disabled=true;
	}
	catch(err)
	{
	}
	try
	{
	var button2 = document.getElementById("submit2");
	button2.src = 'Images/Processing.png';
	button2.disabled=true;
	}
	catch(err)
	{
	}
  	var regStatus = document.getElementById("RegStatus");
  	var overlay = document.getElementById("overlay");
	if (window.innerWidth) {
	var winScrollHeight = window.pageYOffset;
  	var winScrollWidth = window.pageXOffset;
  	var winWidth = window.innerWidth;
  	var winHeight = window.innerHeight;
  }
  if (document.documentElement.clientWidth) {
  	var winScrollHeight = document.documentElement.scrollTop;
  	var winScrollWidth = document.documentElement.scrollWidth;
  	var winWidth = document.documentElement.clientWidth;
  	var winHeight = document.documentElement.clientHeight;
  }
  overlay.style.top = winScrollHeight+"px";
  overlay.style.left = 0+"px";
  regStatus.style.top = ((winHeight / 2) + winScrollHeight)+"px";
  regStatus.style.left = ((winWidth / 2) - 126)+"px";
    var regBody = document.getElementById("RegStatusBody");
	var regFinish = document.getElementById("RegStatusFinished");
	overlay.style.display = 'block';
	fadeIn("overlay", 0);
	regBody.style.display = 'block';
	regFinish.style.display = 'none';
  regStatus.style.display = 'block';
  var regError = document.getElementById('Registrant-Errors');
  regError.style.display = 'none';
  return true;
  } else {
	var button = document.getElementById("submit");
	var button2 = document.getElementById("submit2");
	var regBody = document.getElementById("RegStatusBody");
	var regFinish = document.getElementById("RegStatusFinished");
	var regStatus = document.getElementById("RegStatus");
	var overlay = document.getElementById("overlay");
	var regError = document.getElementById('Registrant-Errors');
	button.src = 'Images/Continue.png';
	button.disabled = false;
	regStatus.style.display = 'none';
	overlay.style.display = 'none';
	regError.style.display = 'block';
	return false;
  }

	//document.forms["form3"].submit();
}


function validateFields()
{
		
	//-------------------------------------------->  First Name Field  <--------------------------------------------
  var firstName = document.getElementById("firstname");
  if (firstName.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("firstname", "Please fill in your first name.");
    /* Abort submission */
    return false;
  }
	//-------------------------------------------->  Last Name Field  <--------------------------------------------
    var el = document.getElementById("lastname");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("lastname", "Please fill in your last name.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Address Field  <--------------------------------------------
    var el = document.getElementById("address");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("address", "Please fill in your home address.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Home City Field  <--------------------------------------------
    var el = document.getElementById("city");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("city", "Please fill in your city.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Home State Field  <--------------------------------------------
    var el = document.getElementById("state");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("state", "Please select your state.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Home Zip Field  <--------------------------------------------
    var el = document.getElementById("zipcode");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("zipcode", "Please fill in your zip code.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Home Phone Field  <--------------------------------------------
    var el = document.getElementById("phone");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("phone", "Please fill in your phone number.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Email Field  <--------------------------------------------
    var el = document.getElementById("email");
	var el2 = document.getElementById("conemail");
  if (el.value != "", el2.value != "")
  {
  	if(VerifyEmail(el.value)){
    /* Continue with submission */
   // return true;
	} else {
		appendErrorMessage("email", "Please fill in a valid email address in both boxes.");
	}
  }
  else
  {
	appendErrorMessage("email", "Please fill in a valid email address in both boxes.");
    /* Abort submission */
    return false;
  }
    	//-------------------------------------------->  Password Field  <--------------------------------------------
    var el = document.getElementById("password");
	var el2 = document.getElementById("conpassword");
  if (el.value != "", el2.value = el.value)
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("password", "Please fill in a matching password in both fields.");
    /* Abort submission */
    return false;
  }
  	//-------------------------------------------->  Position Classification Field  <--------------------------------------------
    var el = document.getElementById("positionclass");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("positionclass", "Please choose a position classification.");
    /* Abort submission */
    return false;
  }
    	//-------------------------------------------->  Title Field  <--------------------------------------------
    var el = document.getElementById("title");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("tile", "Please choose a Title/Position.");
    /* Abort submission */
    return false;
  }
    	//-------------------------------------------->  Organization Field  <--------------------------------------------
    var el = document.getElementById("organization");
  if (el.value != "")
  {
    /* Continue with submission */
    //return true;
  }
  else
  {
	appendErrorMessage("organization", "Please select your organization or chose other to fill in the information below.");
    /* Abort submission */
    return false;
  }
  return true;
}
function appendErrorMessage(elementName, Message) {
	var el = document.getElementById(elementName);
	var errorSpan  = document.createElement("span");
	var errorMessage = document.createTextNode(Message);
	
	errorSpan.appendChild(errorMessage);
	errorSpan.className = "errorMsg";
	
	var fieldLabel = el.parentNode;
	while (fieldLabel.nodeName.toLowerCase() != "label")
	{
		fieldLabel = fieldLabel.previousSibling;
	}
	fieldLabel.appendChild(errorSpan);
}
function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
};
  
  // -------- Interactive Form Validation ---------- //
  	function VerifyEmail(string) {
  				if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
				return true;
				} else {
				return false;
				}
	}
  
  	function notBlank(formname, strLength, action) {
		var el = document.getElementById(formname);
		switch(action) {
			case 'zip':
				if (isNaN(el.value)) {
					MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
				} else {
					if (el.value.length == strLength) {
						MM_swapImage(formname+'Valid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
					}
				}
				break;
			case 'length':
				break;
			case 'title':
				var titlediv = document.getElementById('titleLabel');
				if (el.value == "Other") {
					titlediv.style.display = 'block';
				} else {
					titlediv.style.display = 'none';
				}
				if (el.value != "") {
					MM_swapImage(formname+'Valid','','Images/Form-Checkmark.png',1);
				} else {
					MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
				}
				break;
			case 'password':
				var pass1 = document.getElementById("password");
				var pass2 = document.getElementById("conpassword");
				if (pass1.value.length >= strLength, pass2.value.length >= strLength) {
					if (pass1.value == pass2.value) {
						MM_swapImage('passwordValid','','Images/Form-Checkmark.png',1);
						MM_swapImage('conpasswordValid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage('passwordValid','','Images/Form-Error.png',1);
						MM_swapImage('conpasswordValid','','Images/Form-Error.png',1);
					}
				} else {
					MM_swapImage('passwordValid','','Images/Form-Error.png',1);
					MM_swapImage('conpasswordValid','','Images/Form-Error.png',1);
				}
				break;
			case 'email':
				var email1 = document.getElementById('email');
				var email2 = document.getElementById('conemail');
				if(VerifyEmail(email1.value), VerifyEmail(email2.value)) {
					if (email1.value == email2.value) {
						MM_swapImage('emailValid','','Images/Form-Checkmark.png',1);
						MM_swapImage('conemailValid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage('emailValid','','Images/Form-Error.png',1);
						MM_swapImage('conemailValid','','Images/Form-Error.png',1);	
					}
				} else {
					MM_swapImage('emailValid','','Images/Form-Error.png',1);
					MM_swapImage('conemailValid','','Images/Form-Error.png',1);
				}
				break;
			case 'phone':
				var valid = 1;
				var GoodChars = "0123456789()-+ ";
				var i = 0;
				if (el.value=="") {
					// Return false if number is empty
					valid = 0;
				}
				for (i =0; i <= el.value.length -1; i++) {
					if (GoodChars.indexOf(el.value.charAt(i)) == -1) {
						// Note: Remove the comments from the following line to see this
						// for loop in action.
						// alert(TheNumber.charAt(i) + " is no good.")
						valid = 0;
					} // End if statement
				} // End for loop
				if (valid == 1) {
					if (el.value.length >= strLength) {
						MM_swapImage(formname+'Valid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
					}
				} else {
					MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
				}
				break;
				
			case 'organization':
				var alternate = document.getElementById("Alternate");
				if (el.value == "Other") {
					alternate.style.display = 'block';
				} else {
					alternate.style.display = 'none';
				}
			default:
				if (strLength == 0) {
					//Check for a blank string
					if (el.value != ""){
						MM_swapImage(formname+'Valid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage(formname+'Valid','','Images/Form-Astrick.png',1);
					}
				//Evaluate for required string length
				} else {
					if (el.value.length >= strLength) {
						MM_swapImage(formname+'Valid','','Images/Form-Checkmark.png',1);
					} else {
						MM_swapImage(formname+'Valid','','Images/Form-Error.png',1);
					}
				}
				break;
		}
	}
-->

