/*function isNumeric(value) {
  if (value == null || !value.toString().match(/^\d*\.?\d*$/)) return false;
  return true;
}*/

function isValidAWB (value) { //alert (value);
  if (value == null || !value.toString().match( /^\d{3}-\d{8}$/) ) return false;
  return true;
}

function chkTrackForm(obj2) {
/*  obj = document.getElementById('awbpre');
  var nPre = parseInt(obj.value);
  if (!isNumeric(nPre)) { alert('AWB prefix should be numeric'); return false; }
field 1 suppressed :: for CV always 172  */
  //obj2 = document.getElementById('awbnum');

  var theVal = obj2.value;  
/*  var preVal = theVal.substr(0,3); alert (preVal);
  var separ = theVal.substr(3,1); alert (separ); 
  var sufVal = theVal.substr(4); alert (sufVal); 
  //alert ('chkTrackForm='+ preVal+'///'+sufVal);
  //var nNum1 = parseInt(preVal); 
  //var nNum2 = parseInt(sufVal);
 */
/* if (!isNumeric(preVal) || !isNumeric(sufVal) || (separ != '-') || (sufVal.length != 8) ) { 
    alert('Your air waybill number does not appear to have the correct format.\nPlease ensure that all entries include a 3-digit airline prefix and 8-digit number (123-12345678), \nwithout additional spaces or hyphens'); 
	return false; */
  if (!isValidAWB(theVal)) { 
  	alert('Your air waybill number does not appear to have the correct format.\nPlease ensure that all entries include a 3-digit airline prefix and 8-digit number (123-12345678), \nwithout additional spaces or hyphens');
     return false; 
  }
  
  return true;
}

function SubtForm () {
 theObj = document.getElementById('awbnum');//alert ('SubtForm:'+theObj.value);
 if (chkTrackForm(theObj)){		//alert ('callTrack:'+theObj.value.substring(4));
   callTrack (theObj.value.substring(0,3), theObj.value.substring(4));
 }
}

