<!-- 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://cip.loc.gov/";
var nextfield;
var parent;
var child;
var subject;
var undefined;
var iCapsCheck = null;

// 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]; 
   }
}

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 = /^c[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "cipadmin") && (args[2] != "cipmgt"))                                                                            
   {                                                                            
	  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 = /^c[a-z]{2}\d{5}$/;
   if (!(acctexp.test(args[2])) && (args[2] != "cipadmin") && (args[2] != "cipmgt"))
   {
          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

// create a random number for URL
// to add to the childWindow URL
// to prevent caching of pages
var sessionID = Math.floor(Math.random()*99999999);

function new_childwin(htmlfile, width_height)
{
	close_childwin();
	childWindow = window.open(htmlfile + "?sid=" + sessionID, 'ChildWindow', width_height);
	if (childWindow.opener == null) {
		childWindow.opener = self;
	}
	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 + "?sid=" + sessionID, windowname, 'scrollbars=yes,width=520,height=450');
	if (childWindow.opener == null) {
		childWindow.opener = self;
	}
	if (childWindow_closed == true) {
        childWindow_closed = false;
	}
	window.onerror = error_handler;
	childWindow.moveTo(20,20);
}//return_new_childwin(htmlfile, windowname)

function nW(subj, team)
{
    // for cached subject pages problem:
	if (team.length != 4) {
		self.location.reload();
		alert("This is an outdated, cached version of the " + document.title + " page." + '\n' +
			  "Click \"OK\" to refresh the page, then select the appropriate subject.");
	   	return false;
	}
	else {
		self.close();
		self.opener.return_func(subj, team);
	} 
}//nW(subj, team)

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()
{
	form = document.forms[0];
	form.reset();                              
	set_userid();     
	form.account.value = args[2];
	form.elements[0].focus();
    if (form.account.value.length == 0)
    {
	   alert("You are not properly signed on!");
	   window.location.replace(basehref);
    }	
}//setcursor()

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 return_func(subj, team)
{
	form = document.forms[0];
	form.bisac.value = subj;
	subject = subj;
	form.team.value = team;
	if (form.bisac.value == "") {
		form.bisac.focus();
	}
	else { form.summary.focus(); }
}//return_func(subj, team)

function changeSubj()
{
	form = document.forms[0];
	if (subject == undefined) {
		form.bisac.value = "";
	}
	else {
		form.bisac.value = subject;
	}
}//changeSubj()

function noentry(field) {
	//document.forms[0].textval.blur();
}//noentry(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);

// **************************************************************
// CIP Data Applications -- Validation script

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

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("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 (!(field.match('bisac')) && (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
		}//if
	}//if text fields check  
	
// Required title information fields checks

	if (field.match('title')) {
		formobj.value = formobj.value.replace(/\"/g,"");
		if ((field.match(/^title\d?$/)) && (isEmpty(field))) {
			alert("Title is a required field.");
            formobj.focus();
            formobj.select();
            return false;
		}
	}//if title checks
	
	if ((field == "edition") && !(isEmpty(field))) {	
		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('copyright')) {
            alert("Copyright statements are not considered edition statements.");
            formobj.focus();
            formobj.select();
            return false;
		}
	}
		
    if (field == "pubname") {
		formobj.value = formobj.value.replace(/[\"\'\(\)\[\]]/g,"");
		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 == "pubplace") || (field == "pub_city")) {
		if (isEmpty(field)) {
			alert("U.S. City is a required field.");
            formobj.focus();
            formobj.select();
            return false;
		}	
    }//if publisher city check
	
//***************************************************************
// Special checks for radio buttons

   if (field == "large") {
		if (!(form.large[0].checked || form.large[1].checked)) {
			alert("Large-print format? is a required field.");
			form.large[1].focus();
			return false;
		}
   }//if large print check

   if (field == "ref") {		   
		if (!(form.ref[0].checked || form.ref[1].checked)) {
			alert("Reference work is a required field.");
			form.ref[1].focus();
			return false;
		}
   }//if reference check

   if (field == "child") {		   
		if (!(form.child[0].checked || form.child[1].checked)) {
   			alert("Children or young adults? is a required field.");
  			form.child[1].focus();
  			return false;
		}
		if (form.child[1].checked && ((form.age.value != "") || (form.grade.selectedIndex != 0))) {
			alert("Is this title for children or young adults?" + '\n' + "Data for age and/or grade is indicated.");
			form.child[0].focus();
			return false;
		}
   }//if children check

   if (field == "text") {   		   
		if (!(form.text[0].checked || form.text[1].checked)) {
   			alert("Text format is a required field.");
   			form.text[0].focus();
   			return false;
		}
   }//if text type check
   
   if ((form.name != "cipaplrp") && (field == "series")) {   
   		if (isEmpty(field) && (form.series_author[0].checked ||
			form.series_author[2].checked)) {
			alert("Does this title belong to a formal series?" + '\n' + "First-named author is selected.");
            formobj.focus();
            formobj.select();
			return false;
		}
   }//if series check
   
   if (field == "sameseries") {   
   		if (form.origseries[0].checked && !(form.sameseries[0].checked ||
			form.sameseries[1].checked)) {
			alert("Will original series be retained in reprint edition?");
			form.origseries[0].focus();
			form.sameseries[0].select();
			return false;
		}
		else if (!(form.origseries[0].checked) && (form.sameseries[0].checked)) {
			alert("Was original edition in a series?");
			form.origseries[0].focus();
			form.origseries[0].select();
			return false;
		}
   }//if reprint series check
   
//***************************************************************
// Checks for multivolume works

  var volexp = /^[1-9]((,|, |\-)?[1-9]+\d*)*$/;
  var volsexp = /^[1-9]\d*$/;
	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.");
    		form.vols.focus();
    		form.vols.select();
    		return false;
		}
		if ((isEmpty(field)) && (volexp.test(form.vol.value))) {
   			alert("Total number of volumes is a required" + '\n' + "field for multivolume works.");
   			form.vols.focus();
   			form.vols.select();
   			return false;
		}
	}//if number of volumes checks

	if (field == "vol") {
	  	if (!(isEmpty(field)) && !(volexp.test(form.vol.value))) {
			alert("This volume number(s) is an invalid number(s).");
    		form.vol.focus();
    		form.vol.select();
    		return false;
		}
		if ((isEmpty(field)) && (volsexp.test(form.vols.value))) {
   			alert("Volume number is a required" + '\n' + "field for multivolume works.");
   			form.vol.focus();
   			form.vol.select();
   			return false;
		}
	}//if volume number checks
	
//********************************************************************
//	LCCN Checks
//	1. LCCN must begin with "20", "990", or "998"
//	2. An LCCN beginning with "20" must be 10 chars long
//	   and contain "0" or "1" as the fifth digit
//	3. An LCCN beginning with "999" or "998" must be 8 chars long
//  4. The last 6 digits of the LCCN must be within the ECIP LCCN ranges:
//     000000 - 074999 or 080000 - 199999

  var lccn20exp = /^20[01][1-9][01]\d{5}$/;
  var lccn00exp = /^000\d{5}$/;
  var lccn9Xexp = /^9[89]0\d{5}$/;
  var lccnnum
  	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 (!(lccn20exp.test(formobj.value)) && !(lccn00exp.test(formobj.value)) &&
			!(lccn9Xexp.test(formobj.value))) {
			alert("This LCCN is not valid for the ECIP program.");
			formobj.focus();
			formobj.select();
			return false;
		}
    	lccnnum = parseInt(parseFloat(formobj.value.substring(formobj.value.length - 6)));
		if (lccnnum >= 75000 && lccnnum < 80000) {
			alert("This LCCN has been assigned to a conventional (paper) CIP application." + '\n' + 
			      "Changes to conventional CIP applications must be submitted by mail.");
			formobj.focus();
			formobj.select();
			return false;
		}
		if (lccnnum >= 80000) { // lccnnum >= 200000) {
			alert("This LCCN is not valid for the ECIP program.");
			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 added: (\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)))
	{
		// Alert 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 == "cipchg") {
		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 chars;
  var textmin = 10;
  var textmax = 1800;
  var words;
  var wordmin = 5;
  var wordmax = 60;
  var sumexp = /^.*provided by publisher.*$/gi;
  var sum2exp = /^\".*\"-{2}Provided by publisher\..*$/;
	if (formobj.type == "textarea")
	{
		chars = formobj.value.length;		
		if (!(isEmpty(field)) && (chars < textmin)) {
			alert("The data in this field contains only " + chars + " characters." + '\n' +
				  "Please provide more information.");
			formobj.focus();
			formobj.select();
			return false;
		}
		
      	if (chars > textmax) {
			alert("The data in this field contains " + chars + " characters." + '\n' +
				  "The field is limited to 1800 characters or less.");
      		formobj.focus();
      		formobj.select();
      		return false;
	  	}
		
		// Check for ALL CAPS
	  var 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;
		}
		
		// Check for HTML codes
		if (formobj.value.match(/<\//)) {
			alert("Please do not insert HTML or other codes (e.g., <p> ).");
			formobj.focus();
			formobj.select();
			return false;
		}
		
		// Special checks for Summary field
      	if (field == "summary") {
			words = formobj.value.split(" ").length;
			if (!(isEmpty(field)) && (words < wordmin)) {
				alert("This summary contains only " + words + " words." + '\n' + 
					  "Please provide more summary information.");
    			formobj.focus();
    			formobj.select();
    			return false;
			}
			
			// Publisher summary checks
			if (!(isEmpty(field)) && (sumexp.test(formobj.value))) {
				if (words > wordmax) {
					alert("Publisher's summary contains " + words + " words." + '\n' + 
						  "Summaries are limited to sixty words or less.");
					formobj.focus();
					formobj.select();
					return false;
				}
				if (!(sum2exp.test(formobj.value))) {
					alert("Please format the publisher-supplied summary" + '\n' +
						  "as per the instructions: \" \"--Provided by publisher.");
            		formobj.focus();
            		formobj.select();
            		return false;
				}
			}//if publisher summary
		
			if ((form.name == "cipapl") && form.text[1].checked && (isEmpty(field))) {
    			alert("Summary is a required" + '\n' + "field for core materials.");
    			form.summary.focus();
    			form.summary.select();
    			return false;
			}
/*			
			if ((form.name == "cipapl") && form.child[0].checked && (isEmpty(field))) {
    			alert("Summary is a required" + '\n' + "field for juvenile titles.");
    			form.summary.focus();
    			form.summary.select();
    			return false;
			}
*/
      	}//if summary
	}//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
	
	if ((field.match(/^author\d$/)) && (isEmpty(field))) {
		alert("Author is a required field.");
		formobj.focus();
		formobj.select();
		return false;
	}//if author checks

//*******************************************************
// Subject, Team, Publication date, and File field checks

	if ((field == "bisac") && ((isEmpty(field)) || 
	   (formobj.value == undefined))) {
      	alert("Subject is a required field.");
      	formobj.focus();
      	formobj.select();
      	return false;
	}//if for subject check
	
	// for missing team / Safari auto-fill problem:
	if ((field == "team") && (isEmpty(field))) {
		alert("The subject is missing a hidden attribute that is generated from the popup subject selection window." + '\n' +
			  "This may occur when using \"form filler\" software \(e.g., Apple Safari\'s \"Autofill\" feature\)." + '\n' +
			  "Please re-select the \"principal subject\" for this title using the \"Select\" button above.");
		form.bisac.focus();
      	form.bisac.select();
	   	return false;
	}//if for missing team check

	if ((field.match('ppd')) && (formobj.selectedIndex == 0)) {
    	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 == "cipchg") { 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 CIP data.");
      		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 CIP data.");
      		formobj.focus();
			return false;
		}// current month/year, but after 15th of month
*/
	}//if for PPD date check
	
	if ((form.name != "cipchg") && (field == "upload") && (isEmpty(field))) {
	  	alert("File name for the text file is a required field.");
	  	formobj.focus();
      	return false;
	}//if for text file name

}//for loop

// special routing for children's non-fiction and CIP partnership teams
if ((form.name == "cipapl") || (form.name == "cipaplrp")) {
	// Reset Children's radio button to "NO" for Non-Fiction subjects
    // Send any juvenile medical titles to Medical Sciences, not NLM
	if ((form.child[0].checked == true) && !(form.bisac.value.match("CHILDREN"))) {
		form.child[0].checked = false;
		form.child[1].checked = true;
		if (form.team.value == "tnlm") { form.team.value = "t104"; } 
	}
	// Change cataloging team account code for CIP coop libraries
	if (form.account.value == "cdf13304") { form.team.value = "tbyu"; } // Brigham Young University
	if (form.account.value == "cdf13737") { form.team.value = "tbyu"; } // Brigham Young University (Cedar Fort)
	if (form.account.value == "cdf14021") { form.team.value = "tbyu"; } // Brigham Young University (Deseret Book)
	if (form.account.value == "cdf14984") { form.team.value = "tbyu"; } // Brigham Young University (Signature Books)
	if (form.account.value == "cdf13582") { form.team.value = "tnic"; } // Cornell University
	if (form.account.value == "cdf13444") { form.team.value = "tncd"; } // Duke University
	if (form.account.value == "cdf13427") { form.team.value = "tien"; } // Northwestern University
	if (form.account.value == "cdf13472") { form.team.value = "tosu"; } // Ohio State University
	if (form.account.value == "cdf14562") { form.team.value = "tcst"; } // Stanford University
	if (form.account.value == "cdf13727") { form.team.value = "ttxa"; } // Texas A&M University
	if (form.account.value == "cnh54718") { form.team.value = "ttxa"; } // Texas A&M University (Southern Methodist University Press)
	if (form.account.value == "cdf15833") { form.team.value = "ttxa"; } // Texas A&M University (TCU Press)
	if (form.account.value == "cdf14326") { form.team.value = "ttxa"; } // Texas A&M University (Texas Review Press)
	if (form.account.value == "cdf15294") { form.team.value = "ttxa"; } // Texas A&M University (Texas State Historical Association)
	if (form.account.value == "cdf13408") { form.team.value = "ttxa"; } // Texas A&M University (University of North Texas Press)
	if (form.account.value == "cdf13452") { form.team.value = "ticu"; } // University of Chicago
	if (form.account.value == "cdf14542") { form.team.value = "tsha"; } // University of Hawaii
	if (form.account.value == "cdf14548") { form.team.value = "tsha"; } // University of Hawaii 
	if (form.account.value == "cdf15167") { form.team.value = "tsha"; } // University of Hawaii
	if (form.account.value == "cdf14975") { form.team.value = "tsha"; } // University of Hawaii
	if (form.account.value == "cdf14976") { form.team.value = "tsha"; } // University of Hawaii
	if (form.account.value == "cdf15042") { form.team.value = "tsha"; } // University of Hawaii
	if (form.account.value == "cep59749") { form.team.value = "tsha"; } // University of Hawaii
//	if (form.account.value == "cab54355") { form.team.value = "tpus"; } // University of Pennsylvania
//	if (form.account.value == "cdf13433") { form.team.value = "twau"; } // University of Washington
	if (form.account.value == "cxp13328") { form.team.value = "twum"; } // University of Wisconsin
    if (form.account.value == "cdf15394") { form.team.value = "tonx"; } // ONIX Pilot Project (Cambridge)
	if (form.account.value == "cnr41691") { form.team.value = "tonx"; } // ONIX Pilot Project (Cambridge)
//  if (form.account.value == "cdf13425") { form.team.value = "tonx"; } // ONIX Pilot Project (Wiley)
//	if (form.account.value == "cdf14480") { form.team.value = "tonx"; } // ONIX Pilot Project (Wiley)
//  if (form.account.value == "cak49112") { form.team.value = "tonx"; } // ONIX Pilot Project (Wiley)
//	if (form.account.value == "cdf15819") { form.team.value = "tonx"; } // ONIX Pilot Project (Wiley)
//  if (form.account.value == "cdf14022") { form.team.value = "tonx"; } // ONIX Pilot Project (Wiley)
	if (form.account.value == "cdf14732") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "cdf15620") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "ccs54420") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "cep54380") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "cab55748") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "cnb65337") { form.team.value = "tonx"; } // ONIX Pilot Project (HarperCollins)
	if (form.account.value == "cdf14294") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf14373") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf14692") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf15036") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf15435") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf15576") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdx41667") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cbb45550") { form.team.value = "tonx"; } // ONIX Pilot Project (Oxford University Press)
	if (form.account.value == "cdf13868") { form.team.value = "tonx"; } // ONIX Pilot Project (Berg Publishers)
	if (form.account.value == "cer47653") { form.team.value = "tonx"; } // ONIX Pilot Project (Palgrave Macmillan)
	if (form.account.value == "cxp13322") { form.team.value = "tonx"; } // ONIX Pilot Project (Pluto Press Publishers)
	if (form.account.value == "cdr52643") { form.team.value = "tonx"; } // ONIX Pilot Project (Zed Books)
//	if (form.account.value == "cdf13309") { form.team.value = "tonx"; } // ONIX Pilot Project (Sage)
		
	// check account id for authorization to submit apps
	if (form.account.value == "cnr45205") { // this cannot submit apps (CIP test acct: ceb43635)
		alert("Users of account number " + form.account.value + " are not authorized to submit applications.");
		return false;
	}
}//if for special routing for children's non-fiction and CIP partnership teams

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()) {
//	if (validateForm()) {
		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];
	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 check 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 ALL CAPS
			}//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 added: (\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 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

//************************************************
// Replace functions

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;
}

// Unhide -->
