//------------------------------------
var ID_PEDIDO  = "Balmat_ID_PEDIDO"  ;
var ID_CLIENTE = "Balmat_ID_CLIENTE" ;
var ID_ULT_DEP = "Balmat_ID_ULT_DEP" ;
var ID_ULT_MAR = "Balmat_ID_ULT_MAR" ;
var ID_ULT_FAM = "Balmat_ID_ULT_FAM" ;
var ID_ULT_TRI = "Balmat_ID_ULT_TRI" ;
var ID_ULT_OFT = "Balmat_ID_ULT_OFT" ;
var ID_ULT_RUT = "Balmat_ID_ULT_RUT" ;
//-----------------------------
function getCookie ( szNombre )
   {
   arrayCookie = document.cookie.split( "; " );
   for ( n=0; n < arrayCookie.length; ++n )
       {
       if ( szNombre == arrayCookie[n].split( "=" )[0] )
          { return unescape( arrayCookie[n].split( "=" )[1] ) ; }
       }
   return "" ;
   }
function setCookie ( szNombre, szValor, Caduc )
   {
   document.cookie = szNombre + "=" + escape(szValor) + "; expires=" + Caduc.toGMTString();
   }
function delCookie ( szNombre )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() - 1 );
   document.cookie = szNombre + "=; expires=" + Caduc.toGMTString();
   }
//---------- Funciones GET --------------------------------------
function getSocioID   () { return ( getCookie ( ID_CLIENTE )) ; }
function getClienteID () { return ( getCookie ( ID_CLIENTE )) ; }
function getCestaID   () { return ( getCookie ( ID_PEDIDO  )) ; }
function getPedidoID  () { return ( getCookie ( ID_PEDIDO  )) ; }
function getUltDep    () { return ( getCookie ( ID_ULT_DEP )) ; }
function getUltMar    () { return ( getCookie ( ID_ULT_MAR )) ; }
function getUltFam    () { return ( getCookie ( ID_ULT_FAM )) ; }  
function getUltTri    () { return ( getCookie ( ID_ULT_TRI )) ; }  
function getUltOft    () { return ( getCookie ( ID_ULT_OFT )) ; } 
function getUltRut    () { return ( getCookie ( ID_ULT_RUT )) ; }
//---------- Funciones DEL ---------------------------
function delSocio     () { delCookie ( ID_CLIENTE ); }
function delCliente   () { delCookie ( ID_CLIENTE ); }
function delCesta     () { delCookie ( ID_PEDIDO  ); }
function delPedido    () { delCookie ( ID_PEDIDO  ); }
function delUltDep    () { delCookie ( ID_ULT_DEP ); }  
function delUltMar    () { delCookie ( ID_ULT_MAR ); }   
function delUltFam    () { delCookie ( ID_ULT_FAM ); }  
function delUltTri    () { delCookie ( ID_ULT_TRI ); }  
function delUltOft    () { delCookie ( ID_ULT_OFT ); }   
function delUltRut    () { delCookie ( ID_ULT_RUT ); } 
//------- Funciones SET -------------------
function setSocioID ( nVal )
   { setClienteID ( nVal ) ; }

function setClienteID ( nVal )
   {
   var Min_Cli = 10       ;
   var Caduc   = new Date ;

   var Act_Di  = Caduc.getDate () ;
   var Act_Hr  = Caduc.getHours () ;
   var Act_Mn  = Caduc.getMinutes() ;

   var New_Mn  = (Act_Mn < (60-Min_Cli)) ? (Act_Mn + Min_Cli) : (Act_Mn + Min_Cli - 60) ;
   var New_Hr  = (New_Mn > Act_Mn)       ? (Act_Hr + 0)       : (Act_Hr + 1) ;
   var New_Hr  = (New_Hr > 23)           ? ( 0 )              : (New_Hr + 0) ;
   var New_Di  = (New_Hr < Act_Hr)       ? (Act_Di + 1)       : (Act_Di + 0) ; 

   Caduc.setDate    (New_Di) ;
   Caduc.setHours   (New_Hr) ;
   Caduc.setMinutes (New_Mn) ;

   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_CLIENTE, nVal, Caduc ) ; }
   }

function setCestaID ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_PEDIDO, nVal, Caduc ) ; }
   }

function setUltDep ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_DEP, nVal, Caduc ) ; }
   else
      { delUltDep () ; }
   }
   
function setUltMar ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_MAR, nVal, Caduc ) ; }
   else
      { delUltMar () ; }	  
   }
   
function setUltFam ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_FAM, nVal, Caduc ) ; }
   else
      { delUltFam () ; }	  
   }
   
 function setUltTri ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_TRI, nVal, Caduc ) ; }
   else
      { delUltTri () ; }	  
   }  
   
function setUltOft ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_OFT, nVal, Caduc ) ; }
   else
      { delUltOft () ; }	  
   }
   
function setUltRut ( nVal )
   {
   var Caduc = new Date() ; Caduc.setDate( Caduc.getDate() + 1 );
   if ( (nVal != "0") & (nVal != "") )
      { setCookie ( ID_ULT_RUT, nVal, Caduc ) ; }
   else
      { delUltRut () ; }	  
   }   
//-------------------------------
