<!-- Hide

//***************************
// Declare global variables

var childWindow = null;
var childWindow_closed = false;
var args = new Array();
var userid_check
var form 
var formobj
var field
var basehref = "http://pcn.loc.gov/";
var nextfield
var parent  
var child
var iCapsCheck = null;
var iAuthor = 0;

//*****************************************************
// Start existing checks for Publisher Information Change form

// check email addresses
function validEmail() 
{
      var regexp = /\s/g;   // Match any white space - space,tab,form-feed,etc
      var newstr = formobj.value.replace(regexp, "");                         
      if (newstr.length == 0) { 
            alert("This email address is a required field.");       
            return false;                                                   
      }                                                               
      var emailexp = /^([a-zA-Z0-9'_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;                                                                        
      if (emailexp.test(formobj.value)) { return true; } 
      else
      {
            alert("This email address is invalid.");                
            return false;                                                   
      }                                                               
}// validEmail()

function initArray_upd()
{
this.length=initArray_upd.arguments.length
 
this[0]="10Publisher";
this[1]="10Address";
this[2]="10City";
this[3]="00State"; 
this[4]="01Zip Code"; 
this[5]="01Zip Code"; 
this[6]="01Area Code"; 
this[7]="00Phone"; 
this[8]="01Fax Area Code";
this[9]="00Fax Number";
this[10]="00EMAIL";
this[11]="00Homepage"; 
this[12]="00ISBN"; 
this[13]="10Senior Officer"; 
this[14]="10Senior Officer"; 
this[15]="00Senior Officer"; 
this[16]="00Job Title"; 
this[17]="01Area Code"; 
this[18]="00Phone"; 
this[19]="01Fax Area Code";
this[20]="00Fax Number";
this[21]="00EMAIL";
this[22]="10Principal Contact"; 
this[23]="10Principal Contact"; 
this[24]="00Principal Contact"; 
this[25]="00Job Title"; 
this[26]="11Principal Contact Area Code"; 
this[27]="10Principal Contact Phone"; 
this[28]="01Fax Area Code";
this[29]="00Fax Number";
this[30]="10Principal Contact EMAIL";
}

function edits_upd(form)
{
var editArray = new initArray_upd(document.forms[0].elements.length);

    // Publisher Name Field Only - Remove "The "
    newstr=document.forms[0].pubname.value.toLowerCase();
    if ((newstr.substring(0,4)) == "the ") {
	    document.forms[0].pubname.value = (document.forms[0].pubname.value.substring(4)); 
	}

for (var i=0; i<31; i++) {
    formobj = document.forms[0].elements[i];
       //Trim spaces
    if (formobj.value != null) {
       formobj.value = formobj.value.replace(/^\s*/,"").replace(/\s*$/,"");
    }//if

	// Required Field
    if (editArray[i].substring(0,1) == "1") {
       if (isEmpty()) {
          alert(editArray[i].substring(2) + " is a required field.");
          document.forms[0].elements[i].focus();
          document.forms[0].elements[i].select();
          return false;
       }//if empty
    }//if 

    // Email address check
    if (i==30)
    {
       if (!(validEmail()))
       {
            formobj.focus();                                                
            formobj.select();                                               
            return false;
       }
    }//if for email check

    // Numeric Values Only
    if (editArray[i].substring(1,2) == "1") {
       for (var j=0; j<document.forms[0].elements[i].value.length; j++) {
           var oneChar = document.forms[0].elements[i].value.charAt(j);
           if (oneChar < "0" || oneChar > "9") {
              alert(editArray[i].substring(2) + " is for numeric values only.");
              document.forms[0].elements[i].focus();
              document.forms[0].elements[i].select();
              return false;
           }//if
       }//for
    }//if 
}//for    

document.forms[0].submit();
return true;
}//edits_upd(form)

// End existing checks for Publisher Information Change form
//***********************************************************

// Creates new screen after adding "~userid" to URL, for cgi pgms
function new_window(linkhref)
{                            
   linkhref += "~" + args[2];
   window.location=linkhref; 
}

// Creates new screen with known args                                           
function new_window2(linkhref)                                                  
{                                                                               
   window.location=linkhref;                                                    
}                                                                               
                                                                                
// Creates new screen after adding "&userid=..." to URL, for plsql pgms
function new_window_ora(linkhref)
{                            
   linkhref += "&userid=" + args[2];
   window.location=linkhref; 
}
                                                                   
// Set new url with userid parameter                               
function next_window(linkhref)                                     
{                                                                  
   var result = linkhref.search(/userid=/);                        
   if (result != -1)                 // function called by plsql   
   {                                                               
     window.location = basehref + linkhref;                        
   }                                                               
   else                              // function called by html    
   {                                                               
     window.location = basehref + linkhref + "?userid=" + args[2]; 
   }
}

// Performs ORACLE signoff procedure
function signoff_window(linkhref)
{                            
   linkhref += "&userid=" + args[2];
   window.location=linkhref; 
}

function set_userid()
{
/*  2 types of links to extract account from
      1. Chuck's cgi-bin links
         "~account" is 3rd parameter in href substring
      2. ORACLE links
         "?userid=account" is href substring
*/                                                                               
   var query = location.search.substring(1);  // Get query string from href
   var result = query.search(/userid=/);
   if (result != -1)
   {
      args = query.split("=");		// Break query string into separate parameters
	  args = args[1].split("&");	// Break args[1] string into separate parameters
	  args[2] = args[0];			// Move account into args[2]
   }
   else
   {
      args = query.split("~");  // Break query string into separate parameters
                                // Account is 3rd parm - will be in args[2]
   }

   var acctexp = /^p[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "pcnadmin") && (args[2] != "pcnmgt"))
   {
	  alert("You are not properly signed on!");
	  window.location.replace(basehref);
   }
}

function update_links()
{
/*  2 types links
      1. Chuck's cgi-bin links
         Add "~account" as 3rd and last argument
      2. ORACLE links
         Add "?userid=account" as last argument
*/
   if (userid_check != "completed")
   {
      userid_check = "completed";
      set_userid();
      for(var i = 0; i < document.links.length; i++)
      { 
		var result = document.links[i].href.search(/\?/);
		if (result != -1)
		{
           	document.links[i].href += "~" + args[2];
       	}
       	else
       	{
			if (document.links[i].hash != "")
			{
				var hrefpath = document.links[i].href.split("#");
				document.links[i].href = hrefpath[0] + "?userid=" + args[2] + "#" + hrefpath[1];
			}
			else { document.links[i].href += "?userid=" + args[2]; }
       	}
      }
   }
}

function load_default()
{
  form = document.forms[0];     
  form.reset();
  form.elements[0].focus();
  var query = location.search.substring(1);
  var arrayQry = new Array();           //array of name and value pairs
  var query_pair = new Array();         //two elements of a pair
  var query_name = new Array();         //array of query names
  var query_value = new Array();        //array of query values

  arrayQry = query.split("&");         	 	  //array of name and value pairs
  for (var i=0; i < arrayQry.length; i++)     // build name and value arrays
  {
    query_pair = arrayQry[i].split("=");
    if (query_pair[0] == "userid")  {
        args[2] = query_pair[1];              // args[2] is used in other func
                                              // as value of userid
        // form.account.value = args[2];
    }

    query_name[i] = query_pair[0];
    query_value[i] = query_pair[1];
  }

   var acctexp = /^p[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "pcnadmin") && (args[2] != "pcnmgt"))
   {
          alert("You are not properly signed on!");
          window.location.replace(basehref);
   }

  for (var k=0; k < form.elements.length; k++)  //match field name w array
  {
    for (var i=0; i < arrayQry.length; i++)
    if (form.elements[k].name == query_name[i]) {
        form.elements[k].value = unescape(query_value[i]);
	break;
    }
  }
} //load_default()

// **************************************************************
// Window functions

function new_childwin(htmlfile, width_height, field)
{
	close_childwin();
	childWindow = window.open(htmlfile, 'ChildWindow', width_height);
	if (childWindow.opener == null) {
		childWindow.opener = self;
	}
	passedfield = field;
	if (childWindow_closed == true) {
        	childWindow_closed = false;
	}
	window.onerror = error_handler;
	childWindow.moveTo(20,20);
}//new_childwin(htmlfile, width_height, field)

function return_new(htmlfile, windowname)
{
	self.opener.return_new_childwin(htmlfile, windowname);
	self.close();
}//return_new(htmlfile, windowname)

function return_new_childwin(htmlfile, windowname)
{
	childWindow = window.open(htmlfile, windowname, 'scrollbars=yes,width=475,height=450');
	childWindow.opener = self;
	window.onerror = error_handler;
	childWindow.moveTo(20,20);
}//return_new_childwin(htmlfile, windowname)

function nW(parm)
{
	self.close();
	self.opener.return_func(parm); 
}//nW(parm)

function close_childwin()
{
    if (childWindow != null) {
        if (childWindow_closed == false) {
            childWindow_closed = true;
            childWindow.close();
        }
    }
}//close_childwin()

function error_handler()
{	
	return true;
}//error_handler	

// **************************************************************
// Field functions

function setcursor()                  
{                                     
   set_userid();
   document.forms[0].elements[0].focus();
   document.chuck.action += "~" + args[2];
   // document.forms[0].account += args[2];
}// setcursor()

function setcursor2() // pass value to hidden userid on form 
{
	form = document.forms[0];
	form.reset();                              
	set_userid();     
	form.userid.value = args[2];
	form.elements[0].focus();
    if (form.userid.value.length == 0)
    {
	   alert("You are not properly signed on!");
	   window.location.replace(basehref);
    }                                
}// setcursor2()

// Reset fields when reload                  
function resetpage()                        
{                                           
   document.forms[0].reset();               
// document.forms[0].elements[0].focus(); 
} // resetpage()

if (document.layers) {  // for Netscape Navigator 4.xx
	document.captureEvents(Event.KEYPRESS); 
}

function tabOnEnter(field, evt)
{
	var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode;
	var isNN = navigator.appName.indexOf("Netscape");
		if ((keyCode != 13) && (keyCode != 9) && (isNN == -1)) {
			return true;
		}
		else if ((keyCode != 13) && (isNN != -1)) {
			return true;
		}
		else {
			nextfield = getNextElement(field);
			nextfield.focus();
		if (nextfield.type != 'select-one') { nextfield.select(); }
			return false;
		}
}//tabOnEnter(field, evt)

function getNextElement(field)
{
	var fieldFound = false;
	form = document.forms[0];
	for (var j = 0; j < form.elements.length; j++) {
		if (fieldFound && form.elements[j].type != 'hidden') {
			break;
		}
		if (field == form.elements[j]) {
			fieldFound = true;
		}
	}
	return form.elements[j % form.elements.length];
}//getNextElement(field)

function isEmpty(field)
{
	var regexp = /\s/g;		 // Match any white space including space, tab, form-feed, etc. 
	RegExp.multiline = true; // Check multiple lines
	var newstr = formobj.value.replace(regexp, "");
	if (newstr.length == 0) { return true; }
	else { return false; }
}//isEmpty(field)

function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
	date.setTime(date.getTime() - skew);
}//fixDate(date)

// **************************************************************
// Netscape Navigator 4.xx resize fix

function MM_reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// **************************************************************
// PCN Data Applications -- Validation script

function validateForm(form)
{
if (this.submitted == true) { return false; }
form = document.forms[0];
var iChecked = 0;
var newstr;

for (var j=0; j<(form.elements.length); j++) 
	{
// Set default variables
	formobj = form.elements[j];
	field = formobj.name.substr(0,30);

	// Trim fields and check for special characters
	if ((formobj.value != null) && (formobj.type != "file")) {
		formobj.value = formobj.value.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");
		// Search and replace Unicode punctuation
		// Check for upper ASCII characters (i.e. < 31 & > 126).
		if (formobj.type.match('text')) {
			for (x=0; x<formobj.value.length; x++) {
				// search and replace Unicode punctuation
				if ((formobj.value.charCodeAt(x)>8200)) {
					formobj.value = convert(formobj.value);
				}//if
				// check for upper-ascii characters
				if ((formobj.value.charCodeAt(x)>126) || (formobj.value.charCodeAt(x)<31)) {
				 // alert(formobj.value.charCodeAt(x));
					alert("This field contains invalid characters."); /* + '\n' + 
						  "Please consult the \"Diacritics\" link" + '\n' +
						  "at the top of the application form."); */
					formobj.focus;
					if (formobj.type != 'select-one') { formobj.select(); }
					return false;
   				}//if
			}//for
		}//if
	}//if trim fields and special characters
	
// Special checks for text fields
  var textmax = 255;
	if (formobj.type == "text")
	{
      	if (formobj.value.length > textmax) {
			alert("This field is limited to 255 characters.");
      		formobj.focus();
      		formobj.select();
      		return false;
	  	}//if
		if (!(isEmpty(field))) {
	  var na = new Array(7);
			na[0] = "none";
			na[1] = "na";
			na[2] = "not applicable";
			na[3] = "does not apply";
			na[4] = "unknown";
			na[5] = "same as above";
			na[6] = "see above";
			
		  var naexp = /^[x\W]+$/gi;
			// Check for non-specific terminology (e.g., N/A)
			for (var x=0; x<7; x++) {
				newstr = formobj.value.replace(/[\_\.\"\'\(\)\[\]\/\\]/g,"");
				newstr = newstr.toLowerCase();
				if (!(field.match('midname')) && ((newstr == na[x]) || (naexp.test(newstr)))) {
					alert("Please do not use non-specific terminology." + '\n' + 
						  "Either provide specific data or leave the field blank.");
					formobj.focus();
					formobj.select();
					return false;
				}//if
			}//for
			
			// Check for ALL CAPS, reject all but acronyms
	  	  var textexp = /^[A-Z][A-Z]+$/g;
		    newstr = formobj.value.replace(/\W*\d*[X]*/g, "");	
			if ((textexp.test(newstr)) && ((j > iCapsCheck) || (iCapsCheck == null))) {
				iCapsCheck = j;
				alert("Please do not use all capital letters," + '\n' +
					  "except for acronyms or initialisms.");
				formobj.focus();
				formobj.select();
				return false;
			}//if ALL CAPS
			
			// Capitalize the first letter of all name and city fields
			if ((field.match('name')) || (field.match('city'))) {
				formobj.value = formobj.value.substring(0,1).toUpperCase() + formobj.value.substring(1);
			}//if initial capitals
		}//if
	}//if text fields check
	
// Required title information fields checks

	if ((field == "title") && (isEmpty(field))) {
		alert("Title is a required field.");
		formobj.focus();
		formobj.select();
		return false;
	}//if title checks
	
	if ((field == "edition") && !(isEmpty(field))) {
	  var words = new Array(31);
	  	words[0] = "edition~ed.";
		words[1] = "revised~rev.";
		words[2] = "enlarged~enl.";
		words[3] = "United States~U.S.";
		words[4] = "first~1st";
	  	words[5] = "second~2nd";
		words[6] = "third~3rd";
		words[7] = "fourth~4th";
		words[8] = "fifth~5th";
		words[9] = "sixth~6th";
	  	words[10] = "seventh~7th";
		words[11] = "eighth~8th";
		words[12] = "ninth~9th";
		words[13] = "tenth~10th";
		words[14] = "eleventh~11th";
		words[15] = "twelfth~12th";
		words[16] = " ed~ ed";
		words[17] = " rev~ rev"
		words[18] = " ed ~ ed. ";
		words[19] = " rev ~ rev. "
		words[20] = "st ~st ";
		words[21] = "1 st~1st";
		words[22] = "nd ~nd ";
		words[23] = "2 nd ~2nd ";
		words[24] = "rd ~rd ";
		words[25] = "3 rd ~3rd ";
		words[26] = "th ~th ";
		words[27] = " th ~th ";
		words[28] = "ed. rev. ~ed., rev. ";
		words[29] = " us ~ U.S. ";
		words[30] = "paperback~pbk.";
		
		// Remove some punctuation and add one space to the start and end of string
		formobj.value = " " + formobj.value.replace(/[\"\'\(\)\[\]\/\\]/g,"") + " ";
		newstr = formobj.value.toLowerCase();
		// Alerts for non-edition statements
		if (newstr.match('printing')) {
            alert("Printing statements are not considered edition statements.");
            formobj.focus();
            formobj.select();
            return false;
		}
		if ((newstr.match(/\s[c]\s?\d+/)) || (newstr.match('copyright'))) {
            alert("Copyright statements are not considered edition statements.");
            formobj.focus();
            formobj.select();
            return false;
		}
		// Check for 'e'-type edition statements
		formobj.value = formobj.value.replace(/(\D+\d{1,2}\s?)[e]\s/, "$1 ed. ");

		// Run the replace array for numbers and edition terms
		for (var x=0; x<31; x++) {
		  var word = words[x].split('~');
		  	// replace lower case terms
		  	formobj.value = formobj.value.replace(word[0], word[1]);
		  	// replace initial capital terms
			if (word[0].substring(0,1) == " ") {
				newstr = word[0].substring(0,2).toUpperCase() + word[0].substring(2);
			}
			else {
				newstr = word[0].substring(0,1).toUpperCase() + word[0].substring(1);
			}
			formobj.value = formobj.value.replace(newstr, word[1]);
		  	// replace upper case terms
			newstr = word[0].toUpperCase();	
			formobj.value = formobj.value.replace(newstr, word[1]);
		}
		// Convert arabic to ordinal numbers
		formobj.value = formobj.value.replace(/(\D+[1][1-3])\s$/, "$1th ed.");
		formobj.value = formobj.value.replace(/(\D+[1][1-3])\s/, "$1th ");
		formobj.value = formobj.value.replace(/(\D+\d?)[1]\s$/, "$11st ed.");
		formobj.value = formobj.value.replace(/(\D+\d?)[1]\s/, "$11st ");
		formobj.value = formobj.value.replace(/(\D+\d?)[2]\s$/, "$12nd ed.");
		formobj.value = formobj.value.replace(/(\D+\d?)[2]\s/, "$12nd ");
		formobj.value = formobj.value.replace(/(\D+\d?)[3]\s$/, "$13rd ed.");
		formobj.value = formobj.value.replace(/(\D+\d?)[3]\s/, "$13rd ");
		formobj.value = formobj.value.replace(/(\D+\d?[04-9])\s$/, "$1th ed.");
		formobj.value = formobj.value.replace(/(\D+\d?[04-9])\s/, "$1th ");
		
		// Add ed. at end of statement, if necessary
		if (formobj.value.substring(1,4) == "ed.") {
			formobj.value = formobj.value.replace("ed.", "");
		}
		if (!(formobj.value.match('ed.'))) { 
			formobj.value = formobj.value + " ed.";		
		}
		// Strip out extra spaces and capitalize first letter
		formobj.value = formobj.value.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");
		formobj.value = formobj.value.substring(0,1).toUpperCase() + formobj.value.substring(1).toLowerCase();
		formobj.value = formobj.value.replace("u.s.", "U.S.");
		formobj.value = formobj.value.replace("american", "American");
	}
		
    if (field == "pubname") {
		formobj.value = formobj.value.replace(/[\"\'\(\)\[\]]/g,"");
		formobj.value = formobj.value.replace(/publishing/gi,"Pub.");
		newstr=formobj.value.toLowerCase();
		if ((newstr.substring(0,4)) == "the ") {
			formobj.value = (formobj.value.substring(4));
		}
		if (isEmpty(field)) {
            alert("Publisher is a required field.");
            formobj.focus();
            formobj.select();
            return false;
		}
/*
	  var pubexp = /^\w.*$/;
		if (!(pubexp.test(formobj.value))) {
		    alert("First character of publisher name must be alphanumeric.");
            formobj.focus();
            formobj.select();
            return false;
		}
*/
    }//if publisher name checks

    if ((field == "city") || (field == "pub_city")) {
		if (isEmpty(field)) {
			alert("U.S. City is a required field.");
            formobj.focus();
            formobj.select();
            return false;
		}	
    }//if publisher city check
	
	if ((field == "state") && (formobj.selectedIndex == 0)) {
    	alert("State is a required field.");
      	formobj.focus();
		return false;
	}//if state check

//***************************************************************	
// Checks for author information fields

	if ((field == "firstname_1") && !(isEmpty(field))) {
		if (form.elements[j-1].value == "") {
			alert("Please provide the last name for the first author.");
       		form.elements[j-1].focus();
       		form.elements[j-1].select();
      		return false;			
		}
		if (form.elements[j+2].value == "") {
			alert("Please provide the name for the first author as instructed.");
       		form.elements[j+2].focus();
       		form.elements[j+2].select();
      		return false;
		}
	}//if firstname check
	
	if ((field == "lastname_1") && !(isEmpty(field))) {
		if (form.elements[j+1].value == "") {
			alert("Please provide the first name for the first author.");
       		form.elements[j+1].focus();
       		form.elements[j+1].select();
      		return false;			
		}
		if (form.elements[j+3].value == "") {
			alert("Please provide the name for the first author as instructed.");
       		form.elements[j+3].focus();
       		form.elements[j+3].select();
      		return false;
		}
	}//if lastname check
	
	if ((field == "author_1") && !(isEmpty(field))) {
		if ((form.elements[j-3].value == "") && (iAuthor == 0)) {
			iAuthor = 1;
			alert("If the first author is a personal author," + '\n' +
				  "please provide the first and last name." + '\n' +
				  "Otherwise, leave these fields blank.");
			form.elements[j-3].focus();
			form.elements[j-3].select();
			return false;
		}
		if ((form.elements[j-2].value == "") && (iAuthor == 0)) {
			iAuthor = 1;
			alert("If the first author is a personal author," + '\n' +
				  "please provide the first and last name." + '\n' +
				  "Otherwise, leave these fields blank.");
			form.elements[j-2].focus();
			form.elements[j-2].select();
			return false;			
		}
		if (!(formobj.value.match(form.elements[j-3].value))) {
			alert("The last name for the first author does not match the last name in the box above.");
       		formobj.focus();
       		formobj.select();
      		return false;
		}
	}//if first author check
  
  var authornum = field.substr(field.length - 1,1);
  var authorempty
 
	if ((field.match('author_')) || (field.match('editor_')))
	{	
		if (authornum == 1) { authorempty = null; }
		if ((isEmpty(field)) && (authorempty == null)) {
			authorempty = authornum;
		}
		if (!(isEmpty(field)) && (authorempty != null)) {
			alert("Please move " + field.substr(0, field.length - 2) + " #" + authornum + " to " + field.substr(0, field.length - 2) + " box #" + authorempty + ".");
       		form[field.substr(0, field.length - 1) + authorempty].focus();
       		form[field.substr(0, field.length - 1) + authorempty].select();
			authorempty = null;
       		return false;
		}	
	}//if author and editor field checks
	
	// Check for terms of address or affiliations
	if ((field.match('name_')) || (field.match('author_')) || 
		(field.match('editor_'))) {
	  var terms = new Array(13);
	  	terms[0] = /doctor\s/;
		terms[1] = /dr\./;
		terms[2] = /esq\./;
		terms[3] = /director/;
		terms[4] = /general\s/;
	  	terms[5] = /professor\s/;
		terms[6] = /prof\./;
		terms[7] = /ph\.d/;
		terms[8] = /jr\./;
		terms[9] = /sr\./;
		terms[10] = /\sii/;
		terms[11] = /\siii/;
		terms[12] = /\siv/;

		for (var x=0; x<13; x++) {
			newstr = formobj.value.toLowerCase();
			if ((newstr.match(terms[x])) && x<8) {
				alert("Please do not use terms of address or affiliations.");
    			formobj.focus();
    			formobj.select();
    			return false;
			}
			if ((newstr.match(terms[x])) && (field.match('lastname'))) {
				alert("Please do not use surname suffixes in this field.");
    			formobj.focus();
    			formobj.select();
    			return false;
			}
		}		
	}//if terms of address or affiliations

//***************************************************************
// Checks for # of pages, multivolume works, and series number

  var volexp = /^[1-9]\d*\-?[1-9]?\d*$/;
  var volsexp = /^[1-9]\d*$/;
  	if (field == "pages") {	
	  var volsnum = parseInt(formobj.value)
		if (!(isEmpty(field)) && (!(volsexp.test(volsnum)) ||
			!(volsnum > 0))) {
			alert("Total number of pages is an invalid number.");
    		formobj.focus();
    		formobj.select();
    		return false;
		}
		if (isEmpty(field)) {
   			alert("Total number of pages is a required field.");
   			formobj.focus();
   			formobj.select();
   			return false;
		}
		/*
		if ((volsnum < 50) && !(form.children[0].checked)) {
			alert("Non-juvenile titles must be at least 50 pages in length.");
   			formobj.focus();
   			formobj.select();
   			return false;
		}
		*/
	}//if number of pages checks
  
	if (field == "vols") {	
	  var volsnum = parseInt(form.vols.value)
		if (!(isEmpty(field)) && (!(volsexp.test(volsnum)) ||
			!(volsnum > 1))) {
			alert("Total number of volumes is an invalid number.");
    		formobj.focus();
    		formobj.select();
    		return false;
		}
		if ((isEmpty(field)) && (volexp.test(form.vol.value))) {
   			alert("Total number of volumes is a required" + '\n' + "field for multivolume works.");
   			formobj.focus();
   			formobj.select();
   			return false;
		}
	}//if number of volumes checks

	if (field == "vol") {
	  	if (!(isEmpty(field)) && !(volexp.test(form.vol.value))) {
			alert("This volume number is an invalid number.");
    		formobj.focus();
    		formobj.select();
    		return false;
		}
		if ((isEmpty(field)) && (volsexp.test(form.vols.value))) {
   			alert("Volume number is a required" + '\n' + "field for multivolume works.");
   			formobj.focus();
   			formobj.select();
   			return false;
		}
	}//if volume number checks
	
	if ((field == "series") && (isEmpty(field)) && (form.series_number.value != "")) {
		alert("Series title is required" + '\n' + "for a numbered series.");
		formobj.focus();
		return false;
	}//if series number check
	
//********************************************************************
//	LCCN Checks
//	1. LCCN must begin with "200", "990", or "998"
//	2. An LCCN beginning with "200" must be 10 chars long
//	3. An LCCN beginning with "999" or "998" must be 8 chars long

  var lccn200exp = /^200\d{7}$/;
  var lccn000exp = /^000\d{5}$/;
  var lccn9X0exp = /^9[89]0\d{5}$/;
	if (field == "lccn") {
		formobj.value = formobj.value.replace(/[-\s]/g,"");
		if (isEmpty(field))
		{
			alert("LCCN is a required field.");
			formobj.focus();
			formobj.select();
			return false;
		}
		if (!(lccn200exp.test(formobj.value)) && !(lccn000exp.test(formobj.value)) &&
			!(lccn9X0exp.test(formobj.value))) {
			alert("This LCCN is invalid.");
			formobj.focus();
			formobj.select();
			return false;
		}
	}//if LCCN checks
		
//*************************************************************************
// Special checks for ISBNs and Administrative Information
// Checks for checkboxes and textarea boxes

// Special checks for ISBN numbers
  var isbnfield = /^isbn_\d{1,2}$/;
  var isbnexp = /^\d{9}[0-9X](\d{3})?$/; // For 13-digit ISBNs: (\d{3})?$/;
  var isbnnum = field.substr(5,2);
  var isbnempty
  
  	if ((field.match(isbnfield)) || (field == "isbn"))
	{  
		formobj.value = formobj.value.toUpperCase();
		formobj.value = formobj.value.replace(/[-\s]/g,"");
     	if (!(isEmpty(field)) && !(isbnexp.test(formobj.value)))
		{ 
			alert("ISBN #" + isbnnum + " is invalid.");
            formobj.focus();
            formobj.select();
            return false;
      	}
		
		// 10 and 13 digit ISBN validation tests:
	  var mem = 0; 
		if (formobj.value.length == 10) {
			// Test for 10-digit ISBNs
			// Formulated number must be divisible by 11
			// 0234567899 is a valid number
			for (var x=0; x<9; x++) {
				mem = mem+(formobj.value.charAt(x)*(10-x));
			}
	
			if (formobj.value.charAt(9) == "X") { mem = mem+10; }
	
			else { mem = mem+(formobj.value.charAt(9)*1); }
	
			if ((mem % 11) != 0) {   // modulo function gives remainder
				alert("ISBN #" + isbnnum + " is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}// if 10-digit ISBN check

		if (formobj.value.length == 13) { 
			// Test for 13-digit ISBNs
			// 9780234567890 is a valid number
			for (var x=0; x<12; x++) {
				if ((x % 2) == 0) { y = 1; }
				else { y = 3; }
				mem = mem+(formobj.value.charAt(x)*y);
			}
			z = formobj.value.charAt(12);
			if (z == 0) { z = 10; }		
			if ((10 - (mem % 10)) != z) {   // modulo function gives remainder
				alert("ISBN #" + isbnnum + " is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}// if 13-digit ISBN check
			
		// Other ISBN checks		
		if ((formobj.type != "hidden") && (isEmpty(field)) &&
			(field.match(isbnfield)))
		{
			if (isbnempty == null) { isbnempty = isbnnum; }
			if ((form.elements[j+1].value != "") || (form.elements[j+2].checked == true)) {
				alert("ISBN #" + isbnnum + " is invalid.");
       			formobj.focus();
       			formobj.select();
       			return false;
			}
		}
		if ((isbnempty != null) && !(isEmpty(field)) &&
			(field.match(isbnfield)))
		{
			alert("Please move ISBN #" + isbnnum + " to ISBN box #" + isbnempty + ".");
       		form['isbn_' + isbnempty].focus();
       		form['isbn_' + isbnempty].select();
			isbnempty = null;
       		return false;
		}	
		if ((formobj.type != "hidden") && (isbnnum > 1) &&
			(formobj.value.length == 13))
		{
			if ((form['isbn_' + (isbnnum-1)].value.length == 10) && 
			    (form['isbn_' + (isbnnum-1)].value.substring(0,9) == formobj.value.substring(3,12)))
			{
				alert("The 13-digit ISBN \(#" + isbnnum + "\) should precede " + '\n' +
				      "the corresponding 10-digit ISBN \(#" + (isbnnum-1) + "\).");
       				formobj.focus();
       				formobj.select();
       				return false;
			}
		}	
	}//if ISBN checks
	
	// 10 and 13 digit ISBN qualifier check
  var formatfield = /^format_\d{1,2}$/;
	if ((field.match(formatfield)) && !(isEmpty(field)))
	{  
		// Alerts for ISBN length/type statements
		newstr = formobj.value.toLowerCase();
		if (newstr.match('digit') || newstr.match('isbn')) {
            alert("Please do not qualify ISBNs by length \(e.g., 13-digit, ISBN-10\).");
            formobj.focus();
            formobj.select();
            return false;
		}
      var isbnexp2 = /\d{9}[0-9X]/;
		// Alert for ISBNs in qualifier field
		newstr = formobj.value.toUpperCase();
		if (newstr.match(isbnexp2)) {
            alert("Please do not include ISBNs in the qualifier field.");
            formobj.focus();
            formobj.select();
            return false;			
		}
	}//if ISBN qualifier check
	
// Special checks for Change Application checkboxes
// Test if OLD & NEW information is required

	if (form.name == "pcnchg") {
		if ((field.match('_chng')) && (field != "other_chng") && (formobj.checked))
		{
			iChecked++;
		}
		if ((field == "old_info") && (isEmpty(field)) && (iChecked != 0)) {
       		alert("Old Information is a required field.");
			formobj.focus();
			return false;
		}
		if ((field == "new_info") && (isEmpty(field)) && (iChecked != 0)) { 
			alert("New Information is a required field.");
			formobj.focus();
			return false;
		}
		/*
		if ((field == "comment") && (isEmpty(field)) && form.other_chng.checked) {
			alert("Comments is a required field" + '\n' + "for change type Other.");
			formobj.focus();
			return false;
		}
		*/
	}//if change form checks
	
// Special checks for textarea boxes
  var textmin = 1;
  var textmax = 1800;
	if (formobj.type == "textarea")
	{
      	if (formobj.value.length > textmax) {
			alert("This field is limited to 1800 characters.");
      		formobj.focus();
      		formobj.select();
      		return false;
	  	}
		// Check for ALL CAPS
	  	textexp = /^[A-Z]+$/g;
	    newstr = formobj.value.replace(/\W*\d*/g, "");
		if ((textexp.test(newstr))) {
			alert("Please do not use all capital letters.");
			formobj.focus();
			formobj.select();
			return false;
		}
	}//if textarea check

// Special checks for Administrative Information

	if (formobj.type != "hidden")  // do not check hidden fields
  	{
	  // Check names
		if ((field.match('_name')) || (field.match('_firstname')) ||
			(field.match('_lastname'))) {
			if (isEmpty(field)) {
				alert("This contact name is a required field.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if name checks
	
	  // Check area codes
		if (field.match('_area'))
		{
			if ((isEmpty(field)) && !(field.match('fax'))) {
				alert("This area code is a required field.");
				formobj.focus();
				formobj.select();
				return false;
			}
		  var areaexp = /^[\s\+1-9]\d{1,2}$/;
			if (!(isEmpty(field)) && !(areaexp.test(formobj.value))) {
				alert("This area code is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if area code checks
	
	  // Check phone numbers
		if ((field.match('_phone')) && (isEmpty(field))) {
			alert("This phone number is a required field.");
			formobj.focus();
			formobj.select();
			return false;
		}
	  var phoneexp = /^[0-9x\(\)\-\s\.]{7,25}$/;
		if ((field.match('phone')) && !(isEmpty(field))) {
			formobj.value = formobj.value.toLowerCase(); 
			if (!(phoneexp.test(formobj.value))) {
				alert("This phone number is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if phone number checks
		
	  // Check fax numbers
		if ((field.match('_fax')) && !(field.match('area'))) { 
			if (!(isEmpty(field)) && !(phoneexp.test(formobj.value))) {
				alert("This fax number is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if fax number checks
	
	  // Check street addresses
		if ((field.match('_street')) && (isEmpty(field))) {
			alert("This street address is a required field.");
			formobj.focus();
			formobj.select();
			return false;
		}//if street address check
		
	  // Check zip code
		if (field.match('zip'))
		{
		var zipexp
			if (field.match('1')) { zipexp = /^\d{5}$/; }
			else { zipexp = /^\d{4}$/; }
	 
			if (!(isEmpty(field)) && !(zipexp.test(formobj.value))) {
				alert("This zip code is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if zip code checks	
	
	  // Check email addresses
		if ((field.match('_email')) && (isEmpty(field))) {
			alert("This email address is a required field.");
			formobj.focus();
			formobj.select();
			return false;
		}
	  var emailexp = /^([a-zA-Z0-9'_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if ((field.match('email')) && !(isEmpty(field)) &&
			!(emailexp.test(formobj.value))) {
			alert("This email address is invalid.");
			formobj.focus();
			formobj.select();
			return false;
		}//if email checks
	}//if not a "hidden" field
	
  // Check imprint name
  	if ((field == "imprint1") && (isEmpty(field))) {
		alert("This imprint name is a required field.");
      	formobj.focus();
      	formobj.select();
      	return false;
	}//if imprint name check

//*******************************************************
// Publication date checks

	if ((field.match('ppd')) && (formobj.selectedIndex == 0)) {
		if (form.name == "pcnapl") {
			alert("Publication date is a required field.");
			formobj.focus();
			return false;
		}
	}//if for ppd checks

	if ((field.match('ppd_2')) && (formobj.selectedIndex != 0)) { 
    // get current date and create integer
 	  var today = new Date();
	// fix Macintosh date bug
	    fixDate(today);
      var year = today.getYear();
  	  	if (year < 1000) { year += 1900; }
 	  var month = today.getMonth() + 1;
		if (month < 10) { month = '0' + month; }
		else { month = '' + month; }
	  var day = today.getDate();
      var curdate = parseInt(year + month);
 	// get PPD year + month and create integer
	  var ppd_y = formobj.value; 
	  var ppd_m = form.elements[j-1].selectedIndex;
	  	//	if (form.name == "pcnchg") { ppd_m = ppd_m - 1; }
		if (ppd_m < 10) { ppd_m = '0' + ppd_m; }
		else { ppd_m = '' + ppd_m; }
	  var ppd = parseInt(ppd_y + ppd_m);
	// compare curdate and PPD to see if PPD is valid
		if (ppd < curdate) {
			alert("Projected publication date has past." + '\n' + "This title is ineligible for a PCN.");
      		formobj.focus();
			return false;
		}// past month/year
/*
		else if ((ppd == curdate) && (day > 15)) {
			alert("Projected publication date has past." + '\n' + "This title is ineligible for a PCN.");
      		formobj.focus();
			return false;
		}// current month/year, but after 15th of month
*/
	}//if for PPD date check

}//for loop

// convert case and diacritic terms to Voyager diacritics
for (var j=0; j<(form.elements.length); j++) {
// Set default variables
	formobj = form.elements[j];
	field = formobj.name.substr(0,30);
	
	// convert case for titles
	if (((field.match('title')) || (field.match('series'))) && !(isEmpty(field))) {
		formobj.value = formobj.value.replace(/\"/g,"");
		if (!(field.match('number'))) {
			formobj.value = formobj.value.substring(0,1).toUpperCase() + formobj.value.substring(1).toLowerCase();
		}
		if (field == "subtitle") {
			formobj.value = formobj.value.toLowerCase();
		}
	}//if convert case
	
	// convert case and abbreviate ISBN qualifiers and series numbers 
	if (((field.match('format')) || (field == "series_number")) && !(isEmpty(field)))
	{
		if (field.match('format')) {
			formobj.value = formobj.value.toLowerCase();
		}
		formobj.value = formobj.value.replace(/[Pp]aperback/,"pbk.");
		formobj.value = formobj.value.replace(/[Vv]olume/,"v.");
		formobj.value = formobj.value.replace(/[Vv]ols\./,"v.");
		formobj.value = formobj.value.replace(/[Vv]ol\./,"v.");
		formobj.value = formobj.value.replace(/[Bb]ook/,"bk.");
		formobj.value = formobj.value.replace(/[Nn]umber/,"no.");
		formobj.value = formobj.value.replace(/[Nn]umero/,"no.");
		formobj.value = formobj.value.replace(/[Pp]art/,"pt.");
		formobj.value = formobj.value.replace(/[Ss]eries/,"ser.");
	}	

/*
// convert diacritics
  var termexp = /\{\w+\}/;
	if (!(isEmpty(field)) && (formobj.type.match('text'))
		&& (formobj.value.match(termexp)))
	{
		formobj.value = diacritics(formobj.value);
	}
*/
}//for loop

this.submitted = true;
form.submit();
return true;
}//validateForm(form) 

// *****************************************************
// Additional forms

function nW2() 		// Other additional forms 
{
parent = window.opener.document.forms[0];
child = self.document.forms[0];
	if (validateAddForm()) {
		for (var j=0; j<(child.elements.length); j++) 
		{
			formobj = child.elements[j];
			field = formobj.name;
		// copy text field values
			if (formobj.type.match('text'))
			{ 
				parent[field].value = formobj.value;
			}//if text fields
		// copy checkbox values
			if (formobj.type == "checkbox")
			{
				if (formobj.checked == true) {          		// get checkbox status
					parent[field].value=formobj.value;			// set value = "Yes"
				}
				if (formobj.checked == false) {         		// get checkbox status
					parent[field].value = "";					// return value = ""
				} 
			}//if checkbox fields
		// copy select option values
			if (formobj.type.match('select'))
			{
				parent[field].value = formobj.options[formobj.selectedIndex].value;
			}//if select fields
		}//for
		window.close();
	}//if
}//nW2()  

function reload_w2()
{
parent = window.opener.document.forms[0];
child = self.document.forms[0];
iCapsCheck = null;
	for (var j=0; j<(child.elements.length); j++) 
	{
		formobj = child.elements[j];
		field = formobj.name;
	// copy text field values
		if (formobj.type.match('text'))
		{ 
			formobj.value = parent[field].value;
		}//if text fields
	// copy checkbox values
		if ((formobj.type == "checkbox") && (parent[field].value == "Yes") &&
		     (formobj.checked == false))
		{ 
			formobj.checked = true;		// restore saved checkbox status
		}//if checkbox fields
	// copy select option values
		if (formobj.type.match('select'))
		{
			for (var k=0; k<(formobj.options.length); k++)
			{
    			if (formobj.options[k].value == parent[field].value)
				{
       				formobj.selectedIndex = k;
    			}//if
			}//for  
		}//if select fields
  	}//for
	child.elements[0].focus();
	child.elements[0].select();
}//reload_w2()

function validateAddForm()
{
	for (var j=0; j<(child.elements.length); j++) 
	{
// Set default variables
	formobj = child.elements[j];
  	field = formobj.name;
	
		// trim fields and check for special characters
		if ((formobj.value != null) && (formobj.type != "file")) {
			formobj.value = formobj.value.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");
			// Search and replace Unicode punctuation
			// Check for upper ASCII characters (i.e. < 31 & > 126).
			if (formobj.type.match('text')) {
				for (x=0; x<formobj.value.length; x++) {
					// search and replace Unicode punctuation
					if ((formobj.value.charCodeAt(x)>8200)) {
						formobj.value = convert(formobj.value);
					}//if
					// check for upper-ascii characters
					if ((formobj.value.charCodeAt(x)>126) || (formobj.value.charCodeAt(x)<31)) {
						alert("This field contains invalid characters."); /* + '\n' + 
							  "Please consult the \"Diacritics\" link" + '\n' +
							  "at the top of the application form."); */					formobj.focus;
						if (formobj.type != 'select-one') { formobj.select(); }
						return false;
					}//if
				}//for
			}//if
		}//if trim fields and special characters
		
		// Special checks for text fields
	  var textmax = 255;
		if (formobj.type == "text")
		{
			if (formobj.value.length > textmax) {
				alert("This field is limited to 255 characters.");
				formobj.focus();
				formobj.select();
				return false;
			}
			if (!(isEmpty(field))) {
		  var na = new Array(7);
				na[0] = "none";
				na[1] = "na";
				na[2] = "not applicable";
				na[3] = "does not apply";
				na[4] = "unknown";
				na[5] = "same as above";
				na[6] = "see above";
	
			  var naexp = /^[x\W]+$/gi;
				// Check for non-specific terminology (e.g., N/A)
				for (var x=0; x<7; x++) {
					newstr = formobj.value.replace(/[\_\.\"\'\(\)\[\]\/\\]/g,"");
					newstr = newstr.toLowerCase();
					if (!(field.match('midname')) && ((newstr == na[x]) || (naexp.test(newstr)))) {
						alert("Please do not use non-specific terminology." + '\n' + 
							  "Either provide specific data or leave the field blank.");
						formobj.focus();
						formobj.select();
						return false;
					}//if
				}//for
				
				// Check for ALL CAPS, reject all but acronyms
			  var textexp = /^[A-Z][A-Z]+$/g;
				newstr = formobj.value.replace(/\W*\d*[X]*/g, "");	
				if ((textexp.test(newstr)) && ((j > iCapsCheck) || (iCapsCheck == null))) {
					iCapsCheck = j;
					alert("Please do not use all capital letters," + '\n' +
						  "except for acronyms or initialisms.");
					formobj.focus();
					formobj.select();
					return false;
				}//if
				
				// Capitalize the first letter of all name and city fields
				if ((field.match('name')) || (field.match('city'))) {
					formobj.value = formobj.value.substring(0,1).toUpperCase() + formobj.value.substring(1);
				}//if initial capitals
			}//if
		}//if text fields check 
		
		// Special checks for ISBN numbers
	  var isbnfield = /^isbn_\d{1,2}$/;
	  var isbnexp = /^\d{9}[0-9X](\d{3})?$/; // For 13-digit ISBNs: (\d{3})?$/;
	  var isbnnum = field.substr(5,2);
	  var isbnempty
	  
		if ((field.match(isbnfield)) || (field == "isbn"))
		{  
			formobj.value = formobj.value.toUpperCase();
			formobj.value = formobj.value.replace(/[-\s]/g,"");
			if (!(isEmpty(field)) && !(isbnexp.test(formobj.value)))
			{ 
				alert("ISBN #" + isbnnum + " is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
			
			// 10 and 13 digit ISBN validation tests:
		  var mem = 0; 
			if (formobj.value.length == 10) {
				// Test for 10-digit ISBNs
				// Formulated number must be divisible by 11
				// 0234567899 is a valid number
				for (var x=0; x<9; x++) {
					mem = mem+(formobj.value.charAt(x)*(10-x));
				}
		
				if (formobj.value.charAt(9) == "X") { mem = mem+10; }
		
				else { mem = mem+(formobj.value.charAt(9)*1); }
		
				if ((mem % 11) != 0) {   // modulo function gives remainder
					alert("ISBN #" + isbnnum + " is invalid.");
					formobj.focus();
					formobj.select();
					return false;
				}
			}// if 10-digit ISBN check

			if (formobj.value.length == 13) { 
				// Test for 13-digit ISBNs
				// 9780234567890 is a valid number
				for (var x=0; x<12; x++) {
					if ((x % 2) == 0) { y = 1; }
					else { y = 3; }
					mem = mem+(formobj.value.charAt(x)*y);
				}
				z = formobj.value.charAt(12);
				if (z == 0) { z = 10; }		
				if ((10 - (mem % 10)) != z) {   // modulo function gives remainder
					alert("ISBN #" + isbnnum + " is invalid.");
					formobj.focus();
					formobj.select();
					return false;
				}
			}// if 13-digit ISBN check
				
			// Other ISBN checks		
			if (isEmpty(field))
			{
				if (isbnempty == null) { isbnempty = isbnnum; }
				if ((child.elements[j+1].value != "") || (child.elements[j+2].checked == true)) {
					alert("ISBN #" + isbnnum + " is invalid.");
       					formobj.focus();
       					formobj.select();
       					return false;
				}
			}
			if ((isbnempty != null) && !(isEmpty(field))) {
				alert("Please move ISBN #" + isbnnum + " to ISBN box #" + isbnempty + ".");
       				child['isbn_' + isbnempty].focus();
       				child['isbn_' + isbnempty].select();
				isbnempty = null;
       				return false;
			}	
			if ((isbnnum > 5) && (formobj.value.length == 13))
			{
				if ((child['isbn_' + (isbnnum-1)].value.length == 10) && 
				    (child['isbn_' + (isbnnum-1)].value.substring(0,9) == formobj.value.substring(3,12)))
				{
					alert("The 13-digit ISBN \(#" + isbnnum + "\) should precede " + '\n' +
					      "the corresponding 10-digit ISBN \(#" + (isbnnum-1) + "\).");
					formobj.focus();
					formobj.select();
					return false;
				}
			}	
		}//if ISBN checks
		
		// 10 and 13 digit ISBN qualifier check
	  var formatfield = /^format_\d{1,2}$/;
		if ((field.match(formatfield)) && !(isEmpty(field)))
		{  
			// Alerts for ISBN length/type statements
			newstr = formobj.value.toLowerCase();
			if (newstr.match('digit') || newstr.match('isbn')) {
				alert("Please do not qualify ISBNs by length \(e.g., 13-digit, ISBN-10\).");
				formobj.focus();
				formobj.select();
				return false;
			}
		  var isbnexp2 = /\d{9}[0-9X]/;
			// Alert for ISBNs in qualifier field
			newstr = formobj.value.toUpperCase();
			if (newstr.match(isbnexp2)) {
				alert("Please do not include ISBNs in the qualifier field.");
				formobj.focus();
				formobj.select();
				return false;			
			}
		}//if ISBN qualifier check
		
		// Check series number	
		if ((field.match(/^series_\d$/)) && (isEmpty(field)) && (child.elements[j+1].value != "")) {
			alert("Series title is required" + '\n' + "for a numbered series.");
			formobj.focus();
			return false;
		}//if series number check
			
	  // Check area codes
		if (field.match('_area'))
		{
		  var areaexp = /^[\s\+1-9]\d{1,2}$/;
			if (!(isEmpty(field)) && !(areaexp.test(formobj.value))) {
				alert("This area code is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if area code checks
	
	  // Check phone numbers
	  var phoneexp = /^[0-9x\(\)\-\s\.]{7,25}$/;
		if ((field.match('phone')) && !(isEmpty(field))) {
			formobj.value = formobj.value.toLowerCase(); 
			if (!(phoneexp.test(formobj.value))) {
				alert("This phone number is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if phone number checks
		
	  // Check fax numbers
		if ((field.match('_fax')) && !(field.match('area'))) { 
			if (!(isEmpty(field)) && !(phoneexp.test(formobj.value))) {
				alert("This fax number is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if fax number checks
		
	  // Check zip code
		if (field.match('zip'))
		{
		var zipexp
			if (field.match('1')) { zipexp = /^\d{5}$/; }
			else { zipexp = /^\d{4}$/; }
	 
			if (!(isEmpty(field)) && !(zipexp.test(formobj.value))) {
				alert("This zip code is invalid.");
				formobj.focus();
				formobj.select();
				return false;
			}
		}//if zip code checks
		
	  // Check email addresses
	  var emailexp = /^([a-zA-Z0-9'_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if ((field.match('email')) && !(isEmpty(field)) &&
			!(emailexp.test(formobj.value))) {
			alert("This email address is invalid.");
			formobj.focus();
			formobj.select();
			return false;
		}//if email checks
		
	}//for loop
return true;
}//validateAddForm

function replace(string,text,newtxt)
{
// Replaces text with newtxt in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + newtxt;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,newtxt);

    return newstr;
}

function convert(string)
{
	// convert Unicode punctuation to lower-ASCII equivalents

    string = replace(string,'\u2013','-');   // en dash = -
    string = replace(string,'\u2014','--');  // em dash = --
    string = replace(string,'\u2018','\'');  // left single quote = '
    string = replace(string,'\u2019','\'');  // right single quote = '
    string = replace(string,'\u201A',',');   // single low-9 quote = ,
    string = replace(string,'\u201C','\"');  // left double quote = "
    string = replace(string,'\u201D','\"');  // right double quote = "
	string = replace(string,'\u2022','-');   // bullet = -
	string = replace(string,'\u2026','...'); // horizonal ellipsis = ... 
	string = replace(string,'\u2122','TM');  // trademark sign = TM
    
	return string;
}

function diacritics(string)
{
	// convert diacritic terms in braces to Voyager diacritics

    string = replace(string,'{slash L}',unescape('%A1')); // Hex A0 = Asc 160
    string = replace(string,'{slash O}',unescape('%A2'));
    string = replace(string,'{slash D}',unescape('%A3'));
    string = replace(string,'{Thorn}',unescape('%A4'));
    string = replace(string,'{AE}',unescape('%A5'));
    string = replace(string,'{OE}',unescape('%A6'));     
    string = replace(string,'{miagkii znak}',unescape('%A7'));
    string = replace(string,'{dot center}',unescape('%A8'));
    string = replace(string,'{O hook}',unescape('%AC'));
    string = replace(string,'{U hook}',unescape('%AD'));
    string = replace(string,'{alif}',unescape('%AE'));
    string = replace(string,'{ayn}',unescape('%B0')); // Hex B0 = Asc 176
	string = replace(string,'{slash l}',unescape('%B1'));
    string = replace(string,'{slash o}',unescape('%B2'));
    string = replace(string,'{slash d}',unescape('%B3'));
    string = replace(string,'{thorn}',unescape('%B4'));
    string = replace(string,'{ae}',unescape('%B5'));
    string = replace(string,'{oe}',unescape('%B6'));
    string = replace(string,'{tvyerdi znak}',unescape('%B7'));
    string = replace(string,'{undotted i}',unescape('%B8'));
    string = replace(string,'{eth}',unescape('%BA'));
    string = replace(string,'{o hook}',unescape('%BC'));
    string = replace(string,'{u hook}',unescape('%BD'));
    string = replace(string,'{grave}',unescape('%E1')); // Hex E0 = Asc 224
    string = replace(string,'{acute}',unescape('%E2'));
    string = replace(string,'{agudo}',unescape('%E2'));
    string = replace(string,'{circumflex}',unescape('%E3'));
    string = replace(string,'{tilde}',unescape('%E4'));
    string = replace(string,'{macron}',unescape('%E5'));
    string = replace(string,'{breve}',unescape('%E6'));
    string = replace(string,'{dot above}',unescape('%E7'));
    string = replace(string,'{umlaut}',unescape('%E8'));
    string = replace(string,'{hacek}',unescape('%E9'));
    string = replace(string,'{left ligature}',unescape('%EB'));
    string = replace(string,'{right ligature}',unescape('%EC'));
    string = replace(string,'{comma off}',unescape('%ED'));
    string = replace(string,'{double acute}',unescape('%EE'));
    string = replace(string,'{cedilla}',unescape('%F0')); // Hex F0 = Asc 240
    string = replace(string,'{right hook}',unescape('%F1'));
    string = replace(string,'{dot below}',unescape('%F2'));
    string = replace(string,'{double dot below}',unescape('%F3'));
    string = replace(string,'{left hook}',unescape('%F7'));
    string = replace(string,'{right cedilla}',unescape('%F8'));
    string = replace(string,'{double tilde 1}',unescape('%FA'));
    string = replace(string,'{double tilde 2}',unescape('%FB'));
    
    return string;
}

// Unhide -->
