
var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 



function ereg(objText, spCh)
{
  if(spCh == null || spCh == "") spCh = "@._-";

  var rx=/[^A-Za-z\d @._-]/;

  if(rx.test(objText.value) == true)
  {
    objText.value = "";
    alert("You may enter only spaces, alphanumeric and/or these special characters: " + spCh);
    objText.focus();
    return (false);
  } 
  return (true);
}



function autoTab( input,len, e ) { 
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 
	var filter	= ( isNN ) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if( input.value.length >= len && !containsElement( filter, keyCode )) { 
	input.value = input.value.slice( 0, len ); 
	input.form[( getIndex( input ) + 1 ) % input.form.length].focus(); 
	} 
	return true; 
} 
 

function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}






function ValidateThis(theForm)
{

  if (theForm.FirstName != null && theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName != null && theForm.FirstName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName != null && theForm.FirstName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }


 if (theForm.Email != null && theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email != null)
  {
    if (!/^([\w]+)(\.[\w]+)*@([\w\-]+)(\.[\w]{2,7})(\.[a-z]{2})?$/i.test(theForm.Email.value))
    {
      alert("'" + theForm.Email.value + "' is not a valid email address.  Please enter a valid Email Address.");
      theForm.Email.value = "";
      theForm.Email.focus();
      return (false);
    }
  }

 if (theForm.WarrantyCode != null && theForm.WarrantyCode.value == "")
  {
    alert("Please enter a value for the \"Warranty Code\" field.");
    theForm.WarrantyCode.focus();
    return (false);
  }
  

  return (true);
}


