
	

// SELECT ALL CHECKBOXES
function selectAll(cbList1,cbList2,bSelect) {
  for (var i=0; i<cbList1.length; i++) 
    cbList1[i].selected = cbList1[i].checked = bSelect;
	
  for (var i=0; i<cbList2.length; i++) 
    cbList2[i].selected = cbList2[i].checked = bSelect
}



// SEARCH FUNCTION

//Clear the Query text box when the user clicks for the first time
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
	thefield.value = "";
} 

//trap the Key pressed by the user - Prevent the entry of angle brackets
function checkKey(){
	var kCode = window.event.keyCode;
	if ((kCode==60) || (kCode==62)) {
		alert ("Please do not use angle brackets in your queries.");
		return false;
	}
}

//Code to run when the document loads
function loadComplete() {

	var x=simplesearchForm.QueryText.select();

}

//form validation
function checkrequired(which) {
	var pass=true;
	if (document.images) {
	for (i=0;i<which.length;i++) {
	var tempobj=which.elements[i];
	if (tempobj.name.substring(0,8)=="required") {
	if (((tempobj.type=="text"||tempobj.type=="textarea")&&
	tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
	tempobj.selectedIndex==0)) {
	pass=false;
	break;
	  }
	}
	}
	}
	if (!pass) {
	shortFieldName=tempobj.name.substring(8,30).toUpperCase();
	alert("Please make sure the "+shortFieldName+" field was properly completed.");
	return false;
	}
	else
	return true;
}



function checkForm(which) {
	var pass=true;
	if (document.images) {
	for (i=0;i<which.length;i++) {
	var tempobj=which.elements[i];
	if (tempobj.name.substring(0,8)=="required") {
	if (((tempobj.type=="text"||tempobj.type=="textarea")&&
	tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
	tempobj.selectedIndex==0)) {
	pass=false;
	break;
	  }
	}
	}
	}
	if (!pass) {
	shortFieldName=tempobj.name.substring(8,30).toUpperCase();
	alert("Please make sure the "+shortFieldName+" field was properly completed.");
	return false;
	}
	else
	return checkEmail(which);
	//return true;
		if (!checkEmail) {
			return true;
		}
		else
		return false;
	}
			


function checkEmail(myForm) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
	return (true)
	}
	alert("Invalid E-mail Address! Please re-enter.")
	return (false)
	}
	


// IMAGE ROLL OVERS
if (document.images) {
  homeOn = new Image();
  homeOn.src = "imgs/icon_home_on.gif";
  emailOn = new Image();
  emailOn.src = "imgs/icon_email_on.gif";
  
  homeOff = new Image();
  homeOff.src = "imgs/icon_home_off.gif";
  emailOff = new Image();
  emailOff.src = "imgs/icon_email_off.gif";
}

function imgAct(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + "On.src");
  }
}

function imgInact(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + "Off.src");
  }
}

	
// MENU MOUSE OVER 
function menuOver(itemName) {
 clearTimeout(timeOn)
 menuActive = 1
}// MENU MOUSE OUT 
function menuOut(itemName) {
 if(document.layers) {
 	menuActive = 0 
 	timeOn = setTimeout("hideAllMenus()", 400)
  }
}
 // SET BACKGROUND COLOR 
function getImage(name) {
  if (document.layers) {
    return findImage(name, document);
  }
  return null;
}

function findImage(name, doc) {
  var i, img;
  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageLeft(img) {
  var x, obj;
  if (document.layers) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  return -1;
}

function getImagePageTop(img) {
  var y, obj;
  if (document.layers) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  return -1;
}

//document.write('<style> .menu{position: absolute;}</style>');
var timeOn = null
numMenus = 7;
document.onmouseover = hideAllMenus;
document.onclick = hideAllMenus;
window.onerror = null;

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	//we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility


function showMenu(menuNumber, eventObj, labelID) {
    hideAllMenus();
	if(document.layers) {
	img = getImage("img" + menuNumber);
 	x = getImagePageLeft(img);
 	y = getImagePageTop(img);
 	menuTop = y + 10; // LAYER TOP POSITION
	eval('document.layers["menu'+menuNumber+'"].top="'+menuTop+'"');
 	eval('document.layers["menu'+menuNumber+'"].left="'+x+'"');
	}
	eventObj.cancelBubble = true;
    var menuId = 'menu' + menuNumber;
    if(changeObjectVisibility(menuId, 'visible')) {
	return true;
    } else {
	return false;
    }
}

function hideAllMenus() {
    for(counter = 1; counter <= numMenus; counter++) {
	changeObjectVisibility('menu' + counter, 'hidden');
    }
}

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

function popup(myURL, myName, myWidth, myHeight) {
  flashPopUp = window.open(myURL,myName,'width=' + myWidth + ',height=' + myHeight + ',toolbar=no,menubar=no,scrollbars=no,status=no,location=no,resizable=no');
  flashPopUp.focus();
}
function glossary(term) {
  flashPopUp = window.open('/glossary.html#'+term,'glossary','width=350,height=150,toolbar=no,menubar=no,scrollbars=yes,status=no,location=no,resizable=no');
  flashPopUp.focus();
}

function emailPopup(myURL) {
  emailPopup = window.open(myURL,'VisionEmail','width=' + 100 + ',height=' + 100 + ',toolbar=no,menubar=no,scrollbars=no,status=no,location=no,resizable=no');
  setTimeout('emaildelayer()', 100);
  //emailPopup.top.close();
  return false;
}

function emaildelayer(){
	emailPopup.top.close();
}


function formpopup(myURL, myName, myWidth, myHeight) {
  flashPopUp = window.open(myURL,myName,'width=' + myWidth + ',height=' + myHeight + ',toolbar=no,menubar=no,scrollbars=yes,status=no,location=no,resizable=no');
  flashPopUp.focus();
}


function playVid(myURL) {
  flashPopUp = window.open(myURL,'VisionGallery','width=' + 430 + ',height=' + 325 + ',toolbar=no,menubar=no,scrollbars=no,status=no,location=no,resizable=no');
  flashPopUp.focus();
}

// function to load the calendar window.
function ShowCalendar(FormName, FieldName) {
  window.open("admin/datepopup/window_datepopup.cfm?FormName=" + FormName + "&FieldName=" + FieldName, "CalendarWindow", "width=246,height=215");
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
function checkEmail (strng) {
var error="";
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}




