function url_selector(theValue) {
//{alert (theValue);}
	if (theValue != '0') {
	   	location.href = theValue;
	}
}

function submit_search(theSearch) {
{alert (theSearch) ;}
	if (theSearch.length != 0) {
	target = '#request.cfroot#search/?process_form=search_form&freetext=#urlencodedformat(theSearch)#';
	location.href = target;
	}
	return false;
	}

function EmailErrors(element) {
	var inputStr = element.value;
	var message = "";
	var badchars = "/:,;";
	var bad = "";
	re= /\w/gi;
	
	// alert(" EmailErrors.");

	if (inputStr.match(re)== null)  {
	    message += "Please enter your email address.\n";
	}
	
	if (inputStr.length > 0 && inputStr.length < 9){
	    message += "Email should be at least 9 characters\n";
	}

	for (i=0;i<badchars.length;i++){
	    bad = badchars.charAt(i);
		if (inputStr.indexOf(bad,0) > -1){
			message += "The email address contains the invalid character: '" + bad + "'\n";
		}
	}
	var charA = inputStr.indexOf("@");
	if (charA == -1){
		message += "An email address must contain an @ sign.\n";
	}

	else if (charA < 2) {
	   message += "There must be at least 2 characters before the @ sign.\n";
	}

	var charL = inputStr.lastIndexOf("@");
	if (charL != charA){
		message += "Only one @ sign is allowed in an email address.\n";
	}
	var charP = inputStr.lastIndexOf(".");
	var charD = inputStr.length - charP;
	
	if (charP == -1 || charP < charA){
	   message += "There must be at least one period in the email address after the @ sign.\n";
	}
	else if ((charD != 3) && (charD != 4)){
	   message += "The last period must be followed by either 2 or 3 characters\n";
	}
	
//	else if (inputStr.indexOf(".",charA) - charA < 3){
//		message += "There must be at least 2 characters between the @ sign and the following period.\n";
//	}

	var charB = inputStr.indexOf(" ");
	if (charB > -1){
		message += "An email address cannot contain any space(s)\n";
	}
	if (message.length > 1){
	alert(message);     
	element.select(); 
	element.focus();
	return false;
	}
}

function validateBrowse(thefield) {
	var uscore = thefield.indexOf("_");
	var slctname = thefield.replace(thefield.charAt(uscore), ' ');
	var slct = document.getElementById(thefield);
	if (slct.selectedIndex < 0)
	{
		alert("Please select a " + slctname + " for your \"browse by\" request.");
		slct.focus();
		valid = false;
		return (false);
	}
}
	
function validateSearch(theform, thefield) {
	    re= /\w/gi;
		if (theform.thefield.value.match(re)== null)   {
	    	alert("Please enter your search request.");
	   		theform.thefield.focus();
	   		theform.thefield.select();
	   		return false;}
	}
	
function fullpopopen(location){
	var windowwidth = screen.width - 100
	var windowheight = screen.height - 150
	window.open(location,"_blank","width="+windowwidth+",height="+windowheight+",left=5,top=5,screenx=5,screeny=5,toolbar=yes,resizable=yes,status=yes,scrollbars=yes,locationbar=yes,location=yes,menubar=yes")
}

function validateLogin(theform, action) {

	if (action != "submit"){
		if (theform.login.value.length <= 1){
		   alert("Please enter your login.");
		   theform.login.focus();
		   theform.login.select();
		   return false;}
	}
	   
	if (theform.passwd.value.length <= 1) {
	   alert("Please enter your password.");
	   theform.passwd.focus();
	   theform.passwd.select();
	   return false;
	}
	if (theform.passwd2.value.length <= 1) {
	   alert("Please re-enter your password.");
	   theform.passwd2.focus();
	   theform.passwd2.select();
	   return false;
	}
	if (theform.passwd.value != theform.passwd2.value) {
	   alert("The two passwords you entered do not match. Please verify them and re-submit.");
	   theform.passwd2.focus();
	   theform.passwd2.select();
	   return false;
	}
}

////////////////////////////////////////////////////////////////////////////////////////
	
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/////////////////////////////////////////////////////////////////////////////////////////


function validateDate(element, fieldlabel){
  str = element.value;
  len = str.length;
  monthdays = 0;
  
  {alert ("validateDate function has been called with these values: " + element)}
  
  if(len==0){
return false;}
  
  if (str == "none")
  {return false;}
  
  if(len != 10) {
	{alert ("Please make sure"+ " "  + str + ", the date entered in the" +  " " + fieldlabel +  " " + "field, is in the format mm/dd/yyyy.")} 
return false;
  } 
  
  strmonth = str.substring(0, 2);
  strday = str.substring(3, 5).toUpperCase();
  stryear = str.substring(6, 10);
  
  if( isNaN(strday) || (strday < 0) || isNaN(stryear) || (stryear < 0)) {
	{alert ("Please make sure"+ " "  + str + ", the date entered in the" +  " " + fieldlabel +  " " + "field, is a valid date in the format mm/dd/yyyy.")} 
return false;
  } 

  // Ensure valid month and set maximum days for that month...
  if( (strmonth == "01") || (strmonth == "03") || (strmonth == "05") || 
      (strmonth == "07") || (strmonth == "08") || (strmonth == "10") || 
      (strmonth == "12") ) { monthdays = 31 }
  else if( (strmonth == "04") || (strmonth == "06") || (strmonth == "09") ||
           (strmonth == "11") ) { monthdays = 30 }
  else if(strmonth == "02") { 
    monthdays = ((stryear % 4) == 0) ? 29 : 28; 
  }
  
  else {
	{alert ("Please make sure"+ " "  + str + ", the date entered in the" +  " " + fieldlabel +  " " + "field, is a valid date in the format mm/dd/yyyy.")} 
return false;
  }
  
  if(strday > monthdays) {
	{alert ("Please make sure"+ " "  + str + ", the date entered in the" +  " " + fieldlabel +  " " + "field, is a valid date in the format mm/dd/yyyy.")} 
return false;
  }
 }

