function changePage(dropdown) {
  var listIndex = dropdown.selectedIndex;
  if (dropdown[listIndex].value != "") {
    document.location = dropdown[listIndex].value;
  }
}

function getWayBill(tripid, client_id) {
	open('/cgi-bin/waybills.pl?action=waybill&trip_id=' + tripid + '&CLIENT_ID=' + client_id, 'waybillPopUp',
	    'toolbar=no,resizable=yes,scrollbars=yes,width=675,height=600');
}

function getDoubleWayBill(tripid, client_id) {
	open('/cgi-bin/waybills.pl?action=waybill&print_twice=true&trip_id=' + tripid + '&CLIENT_ID=' + client_id, 'waybillPopUp',
	    'toolbar=no,resizable=yes,width=675,height=825');
}

function getIndex(dropList, item) {
  for (var i = 0; i < dropList.length; i++)
    if (dropList[i].value == item)
      return i;
  return -1;
}

function getLastIndex(dropList, item) {
  for (var i = dropList.length - 1; i >= 0; i--)
    if (dropList[i].value == item)
      return i;
  return -1;
}

function isAllDigits(text) {
  for(var m = 0; m < text.length; m++)
    if(!isDigit(text.charAt(m)))
      return false;
  return true;
}

function isDigit(num) {
	var string="1234567890";
  if (num.length > 1 || string.indexOf(num) == -1)
  	return false;
	return true;
}

function clearOptions(OptionList) {
  // Always clear an option list from the last entry to the first
  for (var x = OptionList.length; x >= 0; x--) {
    OptionList[x] = null;
  }
}

function addToOptionList(OptionList, OptionValue, OptionText) {
  // Add option to the bottom of the list
  OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}

function show_pager_strings(form) {
  var id_string = '';
  for (var i = 0; i < form.elements.length; i++) {
    // check for paging
    if (form.elements[i].value.indexOf('0000003') != -1) {
      id_string += ('&ids=' + form.elements[i].value.split('_')[0]);
    }
  }

  if (id_string != '')
  	open('/cgi-bin/shipping.pl?action=dispatch_pager_strings' + id_string, 'pagerPopup',
  	    'toolbar=no,width=800,height=450');

	return true;
}



