//<!--
// This function will validate a form
function validateForm(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";


  //validate the email address
  if (!(isEmail(theform.email.value)))
  {
    msg = msg + "- Please enter a valid email address\n";
    pass = 0;
  }
  //make sure required fields are not empty
  if (isEmpty(theform.typename.value))
  {
    msg = msg + "- Vehicle Type/Name cannot be empty\n";
    pass = 0;
  }

if (isEmpty(theform.model.value))
  {
    msg = msg + "- Vehicle Model cannot be empty\n";
    pass = 0;
  }

if (isEmpty(theform.bodycolour.value))
  {
    msg = msg + "- Vehicle Body Colour cannot be empty\n";
    pass = 0;
  }

if (isEmpty(theform.numberdoors.value))
  {
    msg = msg + "- Vehicle Number of Doors cannot be empty\n";
    pass = 0;
  }
  
    if (isEmpty(theform.fueltype.value))
  {
    msg = msg + "- Vehicle Fuel Type cannot be empty\n";
    pass = 0;
  }
  
      if (isEmpty(theform.cylinders.value))
  {
    msg = msg + "- Vehicle Cylinders cannot be empty\n";
    pass = 0;
  }
  
      if (isEmpty(theform.gears.value))
  {
    msg = msg + "- Vehicle Gears cannot be empty\n";
    pass = 0;
  }  
  
        if (isEmpty(theform.gearbox.value))
  {
    msg = msg + "- Vehicle Gear Box cannot be empty\n";
    pass = 0;
  }  
        if (isEmpty(theform.odometer.value))
  {
    msg = msg + "- Vehicle Odometer cannot be empty\n";
    pass = 0;
  }    
          if (isEmpty(theform.rego.value))
  {
    msg = msg + "- Vehicle Rego cannot be empty\n";
    pass = 0;
  }
  
            if (isEmpty(theform.vin.value))
  {
    msg = msg + "- Vehicle Vin cannot be empty\n";
    pass = 0;
  }

  
  
  
  
  if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
    return false;
  }
}

// validators ------------------------------------------------------------------
	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isAlphaNum(string) {
    if (string.search(/^[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return false;
    else
        return true;
}

function isExecutable (s) {
	var p = /\.(bat|com|dll|exe|vbs)$/i;
	return p.test(s);
}


function isUrl (s) {
	var p = /^(http|https|ftp):\/\/\S+\.[^\.\s]{2,4}(\/\S*)?$/i;
	return p.test(s);
}

//-->