<!--
gMandatoryFields = 0x001007FF; 

/*---------------------------------------------------------------------------------------------------------------------*/

function onSearchFocus()
{
	if (document.form_search.search.value == "Search...")
		 document.form_search.search.value = ""
}

/*---------------------------------------------------------------------------------------------------------------------*/

function DoSearch()
{
	var sStr = ""

	sStr += IsValidString(document.form_search.search.value, "---");
	if (sStr == "")
		if (document.form_search.search.value == "Search...")
			sStr = "---"
			
	if (sStr != "")
		alert("You must enter at least one keyword")
	else
	{
		document.form_search.action = "/search.asp#results"
		document.form_search.submit()
	}
}

/*---------------------------------------------------------------------------------------------------------------------*/


function SubmitForm()
{
  var sStr = ""
	
	if ( (document.formular["First name"]) && (gMandatoryFields & 1) )
		sStr += IsValidString(document.formular["First name"].value, "First Name");
	
	if ( (document.formular["Last name"]) && (gMandatoryFields & 2) )
		sStr += IsValidString(document.formular["Last name"].value, "Last Name");
	
	if ( (document.formular["Title"]) && (gMandatoryFields & 4) )
	  sStr += IsValidString(document.formular["Title"].value, "Job Title");
	
	if ( (document.formular["Company"]) && (gMandatoryFields & 8) )
	  sStr += IsValidString(document.formular["Company"].value, "Organization");
	
	if ( (document.formular["Email"]) && (gMandatoryFields & 16) )
	  sStr += IsValidEmail(document.formular["Email"].value, "Email");
	
	if ( (document.formular["Street"]) && (gMandatoryFields & 32) )
	  sStr += IsValidString(document.formular["Street"].value, "Address");
	
	if ( (document.formular["City"]) && (gMandatoryFields & 64) )
	  sStr += IsValidString(document.formular["City"].value, "City");
	
	if ( (document.formular["State"]) && (gMandatoryFields & 128) )
	  sStr += IsValidString(document.formular["State"].value, "State");
	
	if ( (document.formular["Zip"]) && (gMandatoryFields & 256) )
	  sStr += IsValidString(document.formular["Zip"].value, "Zip");
	
	if ( (document.formular["Country"]) && (gMandatoryFields & 512) )
	  sStr += IsValidString(document.formular["Country"].value, "Country");
	
	if ( (document.formular["Phone"]) && (gMandatoryFields & 1024) )
	  sStr += IsValidString(document.formular["Phone"].value, "Phone");

	if ( (document.formular["Fax"]) && (gMandatoryFields & 2048) )
	  sStr += IsValidString(document.formular["Phone"].value, "Fax");


	
	if ( (document.formular["Comments"]) && (gMandatoryFields & 65536) )
	  sStr += IsValidString(document.formular["Comments"].value, "Comments");

	if ( (document.formular["Industry"]) && (gMandatoryFields & 131072) )
	  sStr += IsValidString(document.formular["Industry"].value, "Industry");

	if ( (document.formular["Annual revenue"]) && (gMandatoryFields & 262144) )
	  sStr += IsValidString(document.formular["Annual revenue"].value, "Annual revenue");

	if ( (document.formular["Employees"]) && (gMandatoryFields & 524288) )
	  sStr += IsValidString(document.formular["Employees"].value, "Employees");

	if ( (document.formular["ERP"]) && (gMandatoryFields & 1048576) )
	  sStr += IsValidString(document.formular["ERP"].value, "Primary business application");


	if (window.AdditionnalCheck)
		sStr = AdditionnalCheck(sStr)


  if (sStr != "")
    alert(sStr)
  else
    document.formular.submit()
}


/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidNumber(sValue, sName)
{
  if ( (sValue == null) || (sValue == "") )
    return "[" + sName + "] must not be empty\n";
  
  if (isNaN(sValue))
    return "[" + sName + "] must be a number\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidString(sValue, sName)
{
  if ( (sValue == null) || (sValue == "") )
    return "[" + sName + "] must not be empty\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidEmail(sValue, sName)
{
  if (sValue == null)
      return "[" + sName + "] must be a valid email address\n";

  var pos = sValue.indexOf('@');

  if (pos < 1 || pos == (sValue.length-1))
     return "[" + sName + "] must be a valid email address\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsValidHTTPURL(sValue, sName)
{
  if (sValue == null)
      return "[" + sName + "] must not be empty\n";

  var pos1 = sValue.indexOf('http://');
  var pos2 = sValue.lastIndexOf('.');

  if (pos1 != 0 || pos2 < 8 || pos2 > (sValue.length-3))
     return "[" + sName + "] must be a valid HTTP URL address\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsInRange(sValue, min, max, sName)
{
  if ((sValue == null) || isNaN(sValue) || (sValue < min || max < sValue))
      return "[" + sName + "] must be a number between " + min + " and " + max + "\n";

  return "";
}

/*---------------------------------------------------------------------------------------------------------------------*/

function IsMatchingRegEx(sValue, sPattern, sFlag,  sName)
{
  if (sValue == null)
      return "[" + sName + "] is not a valid entry\n";

  var rRegEx = new RegExp(sPattern, sFlag);

  if (! rRegEx.test(sValue))
      return "[" + sName + "] is not a valid entry\n";

  return "";
}

//-->

