
function validZip(zip)
{
  if (zip.match(/^[0-9]{5}$/)) {
    return true;
  }
  zip=zip.toUpperCase();
  if (zip.match(/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/)) {
    return true;
  }
  if (zip.match(/^[A-Z][0-9][A-Z].[0-9][A-Z][0-9]$/)) {
    return true;
  }
  return false;
} 

function validSearch(){

   var msg = '';

   if(document.getElementById('country').selectedIndex == 0){
     msg += "\tWhere you live.\n";
   } else {
     if(
       document.getElementById('country').options[document.getElementById('country').selectedIndex].value == 'USA'
       || document.getElementById('country').options[document.getElementById('country').selectedIndex].value == 'CAN'
       ){
       if(!validZip(document.getElementById('zip').value)){
         msg += "\tA valid zip/postal code.\n";
       }
     }
   }
   if(document.getElementById('destination').selectedIndex == 0){
     msg += "\tWhere you want to study.\n";
   }
   if(document.getElementById('category').selectedIndex == 0){
      msg += "\tA Field you want to be in.\n";
   }
/*
   if(document.getElementById('program').selectedIndex == 0){
     msg += "\tWhat you want to study.\n";
   }
*/
   if(msg == ''){
     return true;
   } else {
     alert("Please provide the following:\n" + msg);
     return false;
   }

   return true;
}

function showZip(){
  if(
    document.getElementById('country').options[document.getElementById('country').selectedIndex].value == 'USA'
    || document.getElementById('country').options[document.getElementById('country').selectedIndex].value == 'CAN'
    ){
    document.getElementById('zipinput').style.display = 'block';
  } else {
    document.getElementById('zipinput').style.display = 'none';
  }
}

