<?php
/**
 * ship_fedex.php 
 *
 * @package fedex automated shipping labels
 * @copyright Copyright 2007-2008 Numinix Technology http://www.numinix.com
 * @copyright Portions Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: ship_fedex.php 31 2009-11-11 02:23:56Z numinix $
 * @author Numinix Technology
 */
  
function name_case($name){
  $newname = strtoupper($name[0]);   
  for ($i=1; $i < strlen($name); $i++) {
    $subed = substr($name, $i, 1);   
    if (((ord($subed) > 64) && (ord($subed) < 123)) ||
       ((ord($subed) > 48) && (ord($subed) < 58)))
    {
       $word_check = substr($name, $i - 2, 2);
       if (!strcasecmp($word_check, 'Mc') || !strcasecmp($word_check, "O'"))
       {
           $newname .= strtoupper($subed); 
       }
       else if ($break)
       {
          
           $newname .= strtoupper($subed);
       }
       else     
       {
           $newname .= strtolower($subed);
       }
         $break=0;
    } else {
       // not a letter - a boundary
         $newname .= $subed;
       $break=1;
    }
  }   
  return $newname;
}

function name_length($name) {
  if (strlen($name) > 35) {
    // need to cut the name into only two names
    $customers_name_array = split(' ', $name);
    $customers_name_words = count($customers_name_array);
    $customers_name = $customers_name_array[0] . ' ' . $customers_name_array[$customers_name_words - 1];
    if (strlen($customers_name) <= 35) {
      return $customers_name;
    } else {
      $customers_name = substr($customers_name_array[0], 0, 1) . ' ' . $customers_name_array[$customers_name_words - 1];
      return $customers_name;
    }
  } else {
    return $name;
  }
}
?>