// To check if all the fields in the form are correctly filled.
// Validation - Reports if all the fields are filled out correctly

function checksearchcp(searchtype)
{
 if (testformsearchcp())
 {
  if (searchtype == 'exact') document.searchcp.searchtype.value = 'exact';
  if (searchtype == 'timeflexible') document.searchcp.searchtype.value = 'timeflexible';
  if (searchtype == 'locationflexible') document.searchcp.searchtype.value = 'locationflexible';
  document.searchcp.submit();
 }
 else return false;	
}		

function testformsearchcp()
{

 var oplace = document.searchcp.oplace.selectedIndex;
 if (document.searchcp.oplace.options[oplace].value == '')
 {
  alert('Please select the locality from where you start off');       				
  document.searchcp.oplace.focus();
  return false;
 }

 var dplace = document.searchcp.dplace.selectedIndex;
 if (document.searchcp.dplace.options[dplace].value == '')
 {
  alert('Please select the locality to which you travel to');       				
  document.searchcp.dplace.focus();
  return false;
 }

 if (document.searchcp.oplace.options[oplace].value == document.searchcp.dplace.options[dplace].value)
 {
  alert('Your origin and destination localities are the same. Please check.');       				
  document.searchcp.dplace.focus();
  return false;
 }
	
 return true;
}


