// JavaScript Document

function clearinputText() {
	if (document.frmSearchIndex.txtSrchString.value == "Search")
	{
  		document.frmSearchIndex.txtSrchString.value= "";
	}
}

function replaceText() {
	if (document.frmSearchIndex.txtSrchString.value == "")
	{
		document.frmSearchIndex.txtSrchString.value = "Search";
	}
}

function startList() {
	for (e=1; e<5; e++) {
		if (document.getElementById("nav" + e)) {
			if (document.all&&document.getElementById) {
				navRoot = document.getElementById("nav" + e);
				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", "");
						}
					}
				}
			}
		}
	}
}

function startList2() {
	if (document.getElementById("sideNav"))
	{
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("sideNav");
			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", "");
					}
				}
			}
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function writeFlash(id, width, height, title, path) {
    document.getElementById(id).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=" + width + " height=" + height + " title=" + title + " style='z-index:4'><param name='movie' value=" + path + "><param name='quality' value='high'><param name='wmode' value='transparent' /><embed src=" + path + " quality='high' wmode='transparent' bgcolor='#ffffff' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + width + " height=" + height + "></embed></object>";
}

function keepTextGold(id, text, gotoLink) {
	document.getElementById(id).innerHTML = "<span><a href='" + gotoLink + "'>" + text + "</a></span>";
}

function normalText(id, text, gotoLink) {
	document.getElementById(id).innerHTML = "<a href='" + gotoLink + "'>" + text + "</a>";
}

function sideNavCurrent(id, text, gotoLink) {
	document.getElementById(id).innerHTML = "<div><a href='" + gotoLink + "'>" + text + "</a></div>";
}

function showLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  vis.display = 'block';
}

function hideLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  vis.display = 'none';
}

function swapStyle(id, newStyle)
{
	var elem
	elem = document.getElementById(id);
	elem.className = newStyle;
}

function checkPhone( phone ) {
  phoneRegex = /^\D*\d{3}\D*\d{3}\D*\d{4}$/;
 if( !phone.match( phoneRegex ) ) {
  return false;
 }
 return true;
}

function removeWhiteSpace( email ) {
	var orgString = document.getElementById(email).value
	var newString = "";
	var counter = 0
	
	for (counter; counter < orgString.length; counter ++)
	{
		newString += orgString.substring(counter, counter+1).replace(" ", "");
	}
	document.getElementById(email).value = newString;
}

function checkZip( zip ) {
  zipRegex = /(^[0-9]{5}[0-9]{4}$)|(^\d{5}-\d{4}$)|(^\d{5}\s\d{4}$)|(^[a-zA-Z]\d[a-zA-Z]\s\d[a-zA-Z]\d$)|(^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$)|(^\d{5}$)|(^\d{5}\s$)/;
 if( !zip.match( zipRegex ) ) {
  return false;
 }
 return true;
}

function ValidateTextBox (strTextBoxID)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var fIsValid = true;

	if (cTextBox.value.replace(/\s/g, "") == "")
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		
		fIsValid = false;
	}

	return (fIsValid);
}

function caseMenuState (id1, id2, id3)
{
	showLayer(id1);
	showLayer(id2);
	hideLayer(id3);
}

