// search the client
// submit the form when click on button

//var cgiurl;

function doNetCourier(frm)
{
    frm.action = '/cgi-bin/dwsrun?netc/NCLOGIN3';
    frm.hidSys.value = "NETC01";
    frm.hidAction.value = "ENTER";
    frm.submit();
}

function doEnter(evt,frm)
{
  var AsciiValue =  evt.keyCode ;
  if(AsciiValue ==13)
  {
    doNetCourier(frm);
  }
}

function doSubmitWG(frm,type,action,param)
{
  //var cgi_path = '/cgi-bin/dwsrun?mwg';

  frm.action = cgi_path+'/MWGHOME.DWO';
  frm.hidNext.value = 15*1;
  frm.hidPrev.value = 1*1;
  if (type == 'PO')
  {
    frm.hidBgcolor.value= 'PO';
    if (action == '')
    {
      action='goAddress'
    }
    frm.hidAction.value = action;
    // this is for details information on address
    //if (param != '' )
    //{
      frm.hidParam.value=param;
    //}
    frm.submit();
  }
  else if (type == 'CO' )
  {
    frm.hidBgcolor.value= 'CO';
    if (action == '')
    {
      action='goCountry'
    }
    frm.hidAction.value = action;
    // this is for details information on address
    //if (param != '' )
    //{
      frm.hidParam.value=param;
    //}
    frm.submit();
  }
  else if (type == 'AR' )
  {
    // it's for clear the select box
    frm.hidBgcolor.value= 'AR';
    if (action == '')
    {
      action='goAirport'
    }
    frm.hidAction.value = action;
    // this is for details information on address
    //if (param != '' )
    //{
      frm.hidParam.value=param;
    //}
    frm.submit();
  }
  else if (type == 'CU' )
  {
    // it's for clear the select box
    frm.hidBgcolor.value= 'CU';
    if (action == '')
    {
      action='goCurrency'
    }
    frm.hidAction.value = action;
    // this is for details information on address
    //if (param != '' )
    //{
      frm.hidParam.value=param;
    //}
    frm.submit();
  }
  else if (type == 'CT' )
  {
    // it's for clear the select box
    frm.hidBgcolor.value= 'CT';
    if (action == '')
    {
      action='goCity'
    }
    frm.hidAction.value = action;
    // this is for details information on address
    //if (param != '' )
    //{
      frm.hidParam.value=param;
    //}
    frm.submit();
  }
  else if(type == 'GG')
  {
      var left = (screen.AvailWidth - 600)/2;
      var top = (screen.AvailHeight - 700)/2;
      var searchString = frm.txtSTR.value;
      var googlePage = "http://www.google.com/search?q="+searchString;
      var win =
      window.open(googlePage,"","left="+left+"top="+top+"width=500,height=600" +
      " statusbar,menubar,toolbar " );
  }
}

// prevent from form submition when press enter on input textbox
//

function preventEnter(evt,frm,type,action)
{
  var AsciiValue =  evt.keyCode ;
  var page='MWGHOME' ;
  frm.hidParam.value='';
  if(AsciiValue ==13)
  {
    // it's a postcode findings
    if (type == 'PO')
    {
      if (action=='')
      {
        action='goAddress';
      }
    }
    // Country findings
    else if (type == 'CO')
    {
      if (action=='')
      {
        action='goCountry';
      }
    }
    // airport findings
    else if (type == 'AR')
    {
      if (action=='')
      {
        action='goAirport';
      }
    }
    // Currency findings
    else if (type == 'CU')
    {
      if (action=='')
      {
        action='goCurrency';
      }
    }
    // City findings
    else if (type == 'CT')
    {
      if (action=='')
      {
        action='goCity';
      }
    }
    frm.hidAction.value = action;
    frm.action = cgi_path+'/'+page;
    frm.submit();
    
    
    /*if(document.addEventListener)
    {
      evt.preventDefault();
    }
    else if(window.event)
    {
      event.returnValue = false;
    }*/
     
  }
}
// strip leading and trailing spaces from a given string
//
function strip(str)
{
    var i, j;
    
    i = 0;
    while (str.charAt(i) == " ") i++;
    j = str.length - 1;
    while ((str.charAt(j) == " ") && (i < j)) j--;
    return str.substring(i, j+1);
}
// this is the metafour timer
// which take the system time 
// from which it get the GMT time.
// from gathered data it calculate the
// local time for some major cities
//
function m4Timer()
{
  // here the timezone value relating to GMT
  // here the very important data
  //
  var localToGMT = new Array(30);
  localToGMT[0] = -8; // PAC/LOS
  localToGMT[1] = -7; //MOU/ARI
  localToGMT[2] = -6;  // CEN/MEX
  localToGMT[3] = -5; // ATL/NYC
  localToGMT[4] = -5; //SAN/BOS
  localToGMT[5] = -3; //BUE/SAO
  localToGMT[6] = +0;  // GMT/LON
  localToGMT[7] = +1; // AMS/MAD
  localToGMT[8] = +1;  // BRU/BER
  localToGMT[9] = +2  // ATH/HEL
  localToGMT[10] = +3;  // MOS/BAH
  localToGMT[11] = +4;  // DUB/MUS
  localToGMT[12] = +5;  // TSK/KAC
  localToGMT[13] = +6;  // DHA/COL
  localToGMT[14] = +7;  // BAN/HAN
  localToGMT[15] = +8;  // BEI/HKG
  localToGMT[16] = +8;  // KUA/MAL
  localToGMT[17] = +9;   // SEO/TKO
  localToGMT[18] = +11;  // SYD/MEL
  //alert();
  // current time from the system
  var cTime = new Date();
  for(i =0; i <19 ; i++)
  {
    var element = "divTime"+i;
    var timeId = document.getElementById(element);
    var tempTime = cTime.getUTCHours();
    // here if time less than gmt value than subtract from 24
    // otherwise subtract from UTC hours
    //
    tempTime = tempTime+localToGMT[i] ;
    tempTime = tempTime > 0 ?tempTime:24+tempTime;
    tempTime = tempTime >= 24 ? tempTime - 24 : tempTime ;
    var hours = tempTime<10?"0"+tempTime:tempTime;
    var minutes = cTime.getMinutes()<10?"0"+cTime.getMinutes():cTime.getMinutes();
    timeId.innerHTML = hours+':'+minutes;
  }
  setTimeout("m4Timer()",60000);
}


// this function update the lower and upper limit of display
//
function goPrevNext(frm,type,fileName)
{
  var go= 0*1;
  if (type == 'prv' && frm.hidPrev.value >= 15)
  {
     go = -15*1 ;
     
  }
  else if (type == 'nxt')
  {
    go = +15*1;
  }
  frm.hidPrev.value = (frm.hidPrev.value*1) +(go*1);
  frm.hidNext.value = (frm.hidNext.value*1) +(go*1);
  frm.hidAction.value = 'goFile';
  frm.action = cgi_path+'/'+'MWGHOME';
  frm.fileName.value = fileName;
  frm.submit();
}
