// Fun��es acopladas de ASP para PHP
// por Mauricio Cunha - mcunha98@terra.com.br

//Pega o valor de um cookie...
 function Get_Cookie($CookieName)
 {
  return $_COOKIE[$CookieName];
 }

//Grava o valor de um cookie... 
 function Set_Cookie($CookieName,$Value)
 {
  $Cookie_Life = time() + 31536000;
  $Cookie_Path = '/vbmania/cookies/';
  $Cookie_Hostname = 'vbmania.com.br';
  setcookie($CookieName, $Value, $Cookie_Life, $Cookie_Path, $Cookie_Hostname);
 }

//Null to zero, caso value n�o seja numerico retorna zero
 function NZ($Value)
 {
  if (strlen(trim($Value)) == 0)
  {
   return "0";
   break;
  }
  
  if (is_null($Value))
  {
   return "0";
   break;
  }
  
  if (empty($Value))
  {
   return "0";
   break;
  }
  
  if (!is_numeric($Value))
  {
   return "0";
   break;
  }
  
  return $Value;
  
 }
 
//Retorna o valor da string passada em caracteres 
 function left ($str, $howManyCharsFromLeft)
 {
  return substr ($str, 0, $howManyCharsFromLeft);
 }

//Retorna o valor da string passada em caracteres
function right ($str, $howManyCharsFromRight)
 {
  $strLen = strlen ($str);
  return substr ($str, $strLen - $howManyCharsFromRight, $strLen);
 }

//L� a string de uma posi��o por n caracteres
function mid ($str, $start, $howManyCharsToRetrieve = 0)
 {
  $start--;
  if ($howManyCharsToRetrieve === 0)
    $howManyCharsToRetrieve = strlen ($str) - $start;
  return substr ($str, $start, $howManyCharsToRetrieve);
 }

//Um if de uma linha s�, muito pr�tico !!!
function iif($Condition, $FalseValue, $TrueValue)
 {
  if ($Condition)
   {
    return $TrueValue;
   }
  else
   {
    return $FalseValue;
   }
 }