
function checkForm ()
{

  // Uppercase only

  document.CMSFORM.EIDnumber.value = document.CMSFORM.EIDnumber.value.toUpperCase();

  // Terms of Use

  if (!document.CMSFORM.SEARCH_Terms.checked) {
    alert( "You must agree to the terms of use for this website in order to proceed." );
    return false;
  }

  // Test case TRUE for EuroPet

  //if (document.CMSFORM.EIDnumber.value == "276097200816590") {
  //	return true;
  //}

  if (document.CMSFORM.EIDnumber.value == "TESTALL") {
  	return true;
  }

  // Trovan or ISO only

  var re;
  re = new RegExp("^[0-9]{9}$|^[0-9A-F]{10}$|^[0-9]{15}"); 

  if (!re.test(document.CMSFORM.EIDnumber.value)) {
	alert( "Invalid RFID entry. All entries must be either\n\n10-digit A through F, 0 through 9\n\nor\n\n15-digit numeric-only.\n" );
	return false;
  }

  re = new RegExp("^[0-9]{9}$|^[0O]A[0-9A-FO]{8}$|^[0O]D[0-9A-FO]{8}$|^1[0-9A-FO]{8}A$|^[1-9][0-9A-FO]{9}$"); 

  if (re.test(document.CMSFORM.EIDnumber.value)) {
	alert( "This is not a TROVAN microchip number. This may be another manufacturer’s microchip.\n" );
	return false;
  }

  re = new RegExp("^956[0-9]{12}$|^968[0-9]{12}$|^804[0-9]{12}$|^276[0-9]{12}$"); 

  if (document.CMSFORM.EIDnumber.value.length == 15 && !re.test(document.CMSFORM.EIDnumber.value)) {
	alert( "This is not a TROVAN microchip number. This may be another manufacturer’s microchip.\n" );
	return false;
  }

  //alert('OK');  return false;

  return true;
}

function doStyles() {

	document.CMSFORM.SUBMIT.disabled = true;
	document.CMSFORM.action = 'search.asp';

	var elem1 = document.getElementById('progressRow');
	elem1.style.visibility = 'visible';
	elem1.style.display = 'inline';

	var elem2 = document.getElementById('search-results');
	elem2.style.visibility = 'hidden';
}

function processForm(f) {

	if (!checkForm()) {
		return false;
	}

	doStyles();

	document.CMSFORM.submit();

	setTimeout('animate()',1);
	
	return true;

}

function animate() {

	// reset the image so it starts moving again
	document.images['progress'].src='images/progress-roller.gif';

	window.status = 'Searching, please wait ...';

}

function openTerms() {
	window.open ("/terms_of_use.asp","mywindow1","menubar=1,resizable=1,width=625,height=300"); 
}

function openInfo() {
	window.open ("/distributor_info.asp","mywindow2","menubar=1,resizable=1,width=625,height=500,scrollbars=1"); 
}


