// JavaScript Document

window.onload = initForms;

function initForms() {
	for (var i=0; i< document.forms.length; i++) {
		document.forms[i].onsubmit = function() {return validForm();}
	}
}

function validForm() {
	var allGood = true;
	var allTags = document.getElementsByTagName("*");

	for (var i=0; i<allTags.length; i++) {
		if (!validTag(allTags[i])) {
			allGood = false;
		}
	}
	return allGood;

	function validTag(thisTag) {
		var outClass = "";
		var allClasses = thisTag.className.split(" ");
	
		for (var j=0; j<allClasses.length; j++) {
			outClass += validBasedOnClass(allClasses[j]) + " ";
		}
	
		thisTag.className = outClass;
	
		if (outClass.indexOf("invalid") > -1) {
			thisTag.focus();
			if (thisTag.nodeName == "INPUT") {
				thisTag.select();
			}
			return false;
		}
		return true;
		
		function validBasedOnClass(thisClass) {
			var classBack = "";
		
			switch(thisClass) {
				case "":
				case "invalid":
					break;
				case "reqd":
					if (allGood && thisTag.value == "") classBack = "invalid ";
					classBack += thisClass;
					break;
				default:
					classBack += thisClass;
			}
			return classBack;
		}
	}
}



function Mail(box) {
   domain="finsvcs.com";
   document.write("<a href=\"mailto:"+box+"@"+domain+"\">"+box+"@"+domain+"</a>"); }
function Mail2(box) {
   domain="virginiabarristersalliance.com";
   document.write("<a href=\"mailto:"+box+"@"+domain+"\">"+box+"@"+domain+"</a>"); }
   
function confirmLink(linkUrl) {
  if (confirm("Important Notice: You have selected a link that will direct you to a website which is outside of this website.  Products or services from other entities outside of this website are not endorsed, nor is this site or its administrators responsible for information contained in any website outside of this one."))
  {    window.open(linkUrl);  }
}
