
/*  DROP DOWN MENUS  */

startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("navigation");
		for (i = 0; i < navRoot.childNodes.length; i++) {
			if (navRoot.childNodes[i].nodeName == "UL") {
				navRoot = navRoot.childNodes[i];
			}
		}
		for (i = 0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className += " over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

/*  / DROP DOWN MENUS  */






/*  FORMS  */

function inputSetValue(input, newText, textToMatch) {
	if (input.value.trim() == textToMatch) {
		input.value = newText;
	}
}

function radioValue(radioGroup) {
	var val = 0;
	for (i = 0; i < radioGroup.length; i++) {
		if (radioGroup[i].checked) {
 			val = radioGroup[i].value; 
		}
	}
	return val;
}


/*  / FORMS  */






//-- mas lib

function checkEmail(emailStr){
	var checkTLD=0; // boolean to check TLD
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;  // This the list of known TLDs that an e-mail address must end with.
	var emailPat=/^(.+)@(.+)$/; // user@domain regexp
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";  // forbidden characters
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; // joe@[123.124.233.4] is a legale-mail address. NOTE: The square brackets are required.
	var atom=validChars + '+'; // The following string represents an atom (basically a series of non-special characters.)
	var word="(" + atom + "|" + quotedUser + ")"; // The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are words. Basically, a word is either an atom or quoted string.
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); // The following pattern describes the structure of the user
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); // The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above.

	var matchArray=emailStr.match(emailPat); // Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze.
	if (matchArray==null){ // Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address.
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++) { // Start by checking that only basic ASCII characters are in the strings (0-127).
		if (user.charCodeAt(i)>127) {
			return false;
 		  }
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			return false;
	   }
	}
	if (user.match(userPat)==null) { // See if "user" is valid 
		return false;
	}
	var IPArray=domain.match(ipDomainPat); // See if ip address is valid 
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false;
		   }
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
	   }
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		return false;
	}
	if (len<2) {
		return false;
	}
	return true;
}
	
Number.prototype.padNumber = function(minStringLength, val) {
	str = this.toString();
	val = val.toString();
	for (var i = str.length; i < minStringLength; i++) {
		str = val + str;
	}
	return str;
}

//-- / lib





