function trim(mystring) {
return mystring.replace(/(^\s*)|(\s*$)/g,'');
} 

function isValidDate (dateStr, fldName) {
// Checks for the following valid date formats: DD/MM/YY   DD/MM/YYYY   DD-MM-YY   DD-MM-YYYY
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2*(\d{2}|\d{4})*$/;
var matchArray = dateStr.match(datePat); 
if (matchArray == null) { alert(fldName+ ': Date is not in a valid format. Use dd/mm/yyyy'); return false; }
month = matchArray[3]; day = matchArray[1]; year = matchArray[4];
if (month < 1 || month > 12) { alert(fldName+ ': Month must be between 1 and 12'); return false; }
if (day < 1 || day > 31) { alert(fldName+ ': Day must be between 1 and 31'); return false; }
if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert(fldName+ ': Month '+month+' doesn\'t have 31 days!'); return false; }
if (month == 2) { 
  var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
  if (day>29 || (day==29 && !isleap)) { alert(fldName+ ': February ' + year + ' doesn\'t have ' + day + ' days!'); return false; }
}
return true; 
}

function ContactFormFindUs () {
/* non utilise */
  if (document.forms[0].findus[0].checked == true) { 
  document.forms[0].whichsearch.style.visibility = "visible"; }
  else { document.forms[0].whichsearch.style.visibility = "hidden"; }
  if (document.forms[0].findus[1].checked == true) { 
  document.forms[0].whichadvert.style.visibility = "visible"; }
  else { document.forms[0].whichadvert.style.visibility = "hidden"; }
  if (document.forms[0].findus[2].checked == true) { 
  document.forms[0].whichshow.style.visibility = "visible"; }
  else { document.forms[0].whichshow.style.visibility = "hidden"; }
  if (document.forms[0].findus[3].checked == true) { 
  document.forms[0].othertext.style.visibility = "visible"; }
  else { document.forms[0].othertext.style.visibility = "hidden"; }
  return true;
}	

function ContactFormFldValid() {
if (trim(document.forms["contact"].last_name.value) == '') { alert ("Fill-in Last Name!"); return false; }
if (trim(document.forms["contact"].first_name.value) == '') { alert ("Fill-in First Name!"); return false; }
if (trim(document.forms["contact"].company.value) == '') { alert ("Fill-in Organization!"); return false; }
if (trim(document.forms["contact"].email.value) == '') { alert ("Fill-in Email Address!"); return false; }
if (document.forms["contact"].elements[8].value == '') { alert ("Select a Region!"); return false; }
if (trim(document.forms["contact"].elements[9].value) == '') { alert ("Missing Request!"); return false; }
return true;
}
