<!--
today=new Date();
today.setTime(today.getTime() + (3600000));
today=today.toGMTString();
currentdate=new Date();
currentdate=currentdate.toLocaleString();
index = document.cookie.indexOf('MemTyPCode');
if (index > -1) {
   countbegin=(document.cookie.indexOf('=',index)+1);
   countend=document.cookie.indexOf(';',index);
   if(countend==-1) {
      fulllist='';
   } else {
      fulllist=document.cookie.substring(countbegin,countend);
   }
} else {
   fulllist='';
}
if(fulllist.length < 1) {
   document.cookie='MemTyPCode=.; expires='+today+';path=/';
   document.cookie='MemTyPName=.; expires='+today+';path=/';
   document.cookie='MemTyPWeight=.; expires='+today+';path=/';
   document.cookie='MemTyPTaxable=.; expires='+today+';path=/';
   document.cookie='MemTyPPrice=.; expires='+today+';path=/';
   document.cookie='MemTyPExtraFields=.; expires='+today+';path=/';
   document.cookie='MemTyPQuantity=.; expires='+today+';path=/';
   document.cookie='TheCurrency=1; expires=Friday, 31-Dec-2010 08:00:00 GMT'+';path=/';
   document.cookie='JShopReferrer=.; expires='+today+';path=/';
}

currencyCode = new Array(1); currencyName = new Array(1); currencyDecimals = new Array(1); currencyPre = new Array(1); currencyMiddle = new Array(1); currencyPost = new Array(1); 
currencyCode[1]='GBP'; currencyName[1]='Colombian peso'; currencyDecimals[1]='2'; currencyPre[1]='$'; currencyMiddle[1]='.'; currencyPost[1]=''; 
    function goBuy() {
        ilist='';
        ilist=ilist+retrieveCookie('MemTyPCode',0,0)+'^';
        ilist=ilist+retrieveCookie('MemTyPName',0,0)+'^';
        ilist=ilist+retrieveCookie('MemTyPWeight',0,0)+'^';
        ilist=ilist+retrieveCookie('MemTyPTaxable',0,0)+'^';
        ilist=ilist+retrieveCookie('MemTyPPrice',0,0)+'^';
        ilist=ilist+retrieveCookie('MemTyPExtraFields',0,0)+'^';
ilist=ilist+retrieveCookie('MemTyPQuantity',0,0)+'^';
        ilist=ilist+retrieveCookie('TheCurrency',0,0)+'^';
        ilist=ilist+retrieveCookie('JShopReferrer',0,0)+'^';
        ilist=changeUnwanted(ilist);
        ilist=escape(ilist);
        ilist=changePercent(ilist);
        top.name=ilist;
        self.location='buy.htm';
    }

function changeUnwanted(tstring) {
    nstring='';
    for (var i=0; i <= tstring.length; i++) {
        nchar=tstring.charAt(i);
        if (nchar=='*') { nchar='!&1'; }
        if (nchar=='+') { nchar='!&2'; }
        if (nchar=='@') { nchar='!&3'; }
        if (nchar=='.') { nchar='!&4'; }
        if (nchar=='/') { nchar='!&5'; }
        if (nchar=='-') { nchar='!&6'; }
        nstring=nstring+nchar;
    }
    return nstring;
}
function changePercent(tstring) {
    nstring='';
    for (var i=0; i <= tstring.length; i++) {
        nchar=tstring.charAt(i);
        if (nchar=='%') { nchar='_'; }
        nstring=nstring+nchar;
    }
    return nstring;
}

function showPrice(pricestring) {
    index = document.cookie.indexOf('TheCurrency');
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    theCurrency=document.cookie.substring(countbegin,countend);
    thisitem=0;
    itemstart=0;
    theprice=0;
    for (var i=0; i<pricestring.length; i++) {
       if (pricestring.substring(i,i+1)=='~') {
          thisitem++;
          if (thisitem==eval(theCurrency)) {
             theprice=pricestring.substring(itemstart,i);
          }
          itemstart=i+1;
       }
    }
    return presentValue(theprice,currencyDecimals[theCurrency],currencyPre[theCurrency],currencyMiddle[theCurrency],currencyPost[theCurrency]);
}
function showPriceSingle(pricestring) {
    index = document.cookie.indexOf('TheCurrency');
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    theCurrency=document.cookie.substring(countbegin,countend);
    return presentValue(pricestring,currencyDecimals[theCurrency],currencyPre[theCurrency],currencyMiddle[theCurrency],currencyPost[theCurrency]);
}
function showPricePlain(pricestring) {
    index = document.cookie.indexOf('TheCurrency');
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    theCurrency=document.cookie.substring(countbegin,countend);
    return presentValue(pricestring,currencyDecimals[theCurrency],'',currencyMiddle[theCurrency],'');
}
function getPrice(pricestring) {
    index = document.cookie.indexOf('TheCurrency');
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    theCurrency=document.cookie.substring(countbegin,countend);
    thisitem=0;
    itemstart=0;
    theprice=0;
    for (var i=0; i<pricestring.length; i++) {
       if (pricestring.substring(i,i+1)=='~') {
          thisitem++;
          if (thisitem==eval(theCurrency)) {
             theprice=pricestring.substring(itemstart,i);
          }
          itemstart=i+1;
       }
    }
    return theprice;
}
    function presentValue(value,dp,pt,mt,at) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        dec='1';
        for (var i=1; i<=dp;i++) {
            dec=dec+'0';
        }
        if (value>0) {
            newPence=Math.round((eval(value)+.000008 - newPounds)*(eval(dec)));
        } else {
            newPence=0;
        }
        compstring='9';
        for (var i=1; i <=dp-1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        if (dp>0) {
            if (newPence==eval(dec)) { newPounds++; newPence=0; }
            newString=pt+newPounds+mt+newPence+at;
        } else {
            newString=pt+newPounds+at;
        }
        return (newString);
    }

function retrieveCookie(thecookie,thenumber,theadditional) {
    index = document.cookie.indexOf(thecookie);
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    fulllist=document.cookie.substring(countbegin,countend);
    if (thenumber==0) { return fulllist; }
    thisitem=0;
    newcookie='';
    itemstart=0;
    for(var i=0; i<fulllist.length;i++) {
        if (fulllist.substring(i,i+1)=='|') {
            thisitem++;
           itemvalue=fulllist.substring(itemstart,i);
           if (thisitem==thenumber) {
                if (theadditional==0) {
                    return itemvalue;
                } else {
                    itemstarttwo=0;
                    thisitemtwo=0;
                    for (var j=0; j<itemvalue.length; j++) {
                        if (itemvalue.substring(j,j+1)=='~') {
                            thisitemtwo++;
                            itemvaluetwo=itemvalue.substring(itemstarttwo,j);
                            if (thisitemtwo==theadditional) {
                                return itemvaluetwo;
                            }
                            itemstarttwo=j+1;
                        }
                    }
                }
            }
            itemstart=i+1;
        }
    }
    return '';
}
function addToCookie(thecookie,thevalue) {
    fulllist=retrieveCookie(thecookie,0,0);
    if (fulllist=='.') { fulllist=''; }
    fulllist=fulllist+thevalue+'|';
    document.cookie=thecookie+'='+fulllist+'; expires='+today+';path=/';
}
function removeFromCookie(thecookie,thenumber) {
    fulllist=retrieveCookie(thecookie,0,0);
    thisitem=0;
    newcookie='';
    itemstart=0;
    for(var i=0; i<fulllist.length;i++) {
        if (fulllist.substring(i,i+1)=='|') {
            thisitem++;
            itemvalue=fulllist.substring(itemstart,i);
            if (thisitem!=thenumber) {
                newcookie=newcookie+itemvalue+'|';
            }
            itemstart=i+1;
        }
    }
    if (newcookie=='') { newcookie='.'; }
    document.cookie=thecookie+'='+newcookie+'; expires='+today+';path=/';
}
function changeCookieValue(thecookie,thenumber,thevalue) {
    fulllist=retrieveCookie(thecookie,0,0);
    thisitem=0;
    newcookie='';
    itemstart=0;
    for(var i=0; i<fulllist.length;i++) {
        if (fulllist.substring(i,i+1)=='|') {
            thisitem++;
            itemvalue=fulllist.substring(itemstart,i);
            if (thisitem==thenumber) {
                itemvalue=thevalue;
            }
            newcookie=newcookie+itemvalue+'|';
            itemstart=i+1;
        }
    }
    document.cookie=thecookie+'='+newcookie+'; expires='+today+';path=/';
}
function retrieveCookieCount(thecookie) {
   fulllist=retrieveCookie(thecookie,0,0);
   thisitem=0; newcookie=''; itemstart=0;
   for(var i=0; i<fulllist.length;i++) {
    if (fulllist.substring(i,i+1)=='|') {
        thisitem++;
        itemstart=i+1;
    }
   }
   return thisitem;
}
function getAdvanced(adv,qty) {
     newAdv='';advlist=0;applicable=true;advnewprice='';
    for (var j=0;j<=adv.length;j++) {
            if (adv.substring(j,j+1) == '{') {
            thisadv=1;
            advstart=j+1;
        } else if (adv.substring(j,j+1) == '}') {
            advend=j;
            advPrice=adv.substring(advstart,advend);
            advlist++; applicable=true;
            if (applicable==true) {
                if (advFrom > 0 && advFrom > eval(qty)) applicable=false;
                if (advTo > 0 && advTo < eval(qty)) applicable=false;
                if (applicable==true) advnewprice=advPrice;
            }
        } else if (adv.substring(j,j+1)=='!') {
            if (thisadv== 1) advFrom=adv.substring(advstart,j);
            if (thisadv== 2) advTo=adv.substring(advstart,j);
            thisadv++;advstart=j+1;
        }
    }
    return advnewprice;
}
function showBasket() {
   totprice=0;
   document.writeln('<table width=560 cellpadding=2 cellspacing=1 bgcolor=000000>');
   document.writeln('<tr>');
   document.writeln("<td bgcolor=333333 align=center><font face='verdana,helvetica,arial' size=1 color=dddddd><b>Codigo</b></font></td>");
   document.writeln("<td bgcolor=333333 align=left><font face='verdana,helvetica,arial' size=1 color=dddddd><b>  Nombre del Producto</b></font></td>");
   document.writeln("<td bgcolor=333333 align=center><font face='verdana,helvetica,arial' size=1 color=dddddd><b>Cant.</b></font></td>");
   document.writeln("<td bgcolor=333333 align=center><font face='verdana,helvetica,arial' size=1 color=dddddd><b>V. Unit.</b></font></td>");
   document.writeln("<td bgcolor=333333 align=center><font face='verdana,helvetica,arial' size=1 color=dddddd><b>Dcto.</b></font></td>");
   document.writeln("<td bgcolor=333333 align=center><font face='verdana,helvetica,arial' size=1 color=dddddd><b>V. Total</b></font></td>");
   document.writeln("<td bgcolor=333333 align=right><font face='verdana,helvetica,arial' size=1 color=dddddd><b></b></font></td>");
   document.writeln("</tr>");
   for (var i=1;i<=retrieveCookieCount('MemTyPCode');i++) {
       theCode=retrieveCookie('MemTyPCode',i,0);
       theName=retrieveCookie('MemTyPName',i,0);
       theWeight=retrieveCookie('MemTyPWeight',i,0);
       theTaxable=retrieveCookie('MemTyPTaxable',i,0);
       thePrice=retrieveCookie('MemTyPPrice',i,0);
       
theQuantity=retrieveCookie('MemTyPQuantity',i,0);
itemtotal=eval(theQuantity)*eval(getPrice(thePrice));
       totprice=totprice+itemtotal;
       document.writeln("<td bgcolor=FFFFFF align=center><font face='arial narrow' size=1 color=000000>"+theCode+"</font></td>");
       document.writeln("<td bgcolor=FFFFFF><font face='Arial Narrow' size=2 color=000000>"+theName+"</font></td>");
       document.writeln("<td bgcolor=FFFFFF align=center><font face='Arial,Helvetica' size=2 color=000000><input type=text name='quant"+i+"' value='"+theQuantity+"' size=3></font></td>");
       document.writeln("<td bgcolor=FFFFFF align=right><font face='Arial narrow' size=2 color=000000></font></td>");
       document.writeln("<td bgcolor=FFFFFF align=right><font face='Arial narrow' size=2 color=000000></font></td>");
       document.writeln("<td bgcolor=dddddd align=center><font face='Arial narrow' size=2 color=000000>Por confirmar</font></td>");
       document.writeln("<td bgcolor=FFFFFF align=center><font face='Arial,Helvetica' size=2 color=000000><a href='javascript:removeItem("+i+");'><img src='shopimages/quitaritems.gif' border=0 alt='Quitar Artículo del Pedido'></a></font></td>");
       document.writeln("</tr>");
   }
   document.writeln("<tr>");
   document.writeln("<td bgcolor=dddddd colspan=7><font face='Arial,Helvetica' size=2 color=000000> <b>Nota: </b><br> A vuelta de correo recibirá la cotizacion con los precios, los cuales están sujetos a<br> DESCUENTOS (en todas las referencias) que serán asignados de acuerdo al volúmen, valor<br> total y forma de pago que haya elegido.</font></td>");
   document.writeln("</tr>");
   sepchar='"';
   document.writeln("</table>");
   document.writeln("<table width=560 align=center><tr><td align=left><font color=333366 face='verdana,helvetica,arial' size=1>Para agregar o quitar cantidades, utilice la columna de Cant. Después, de click en Actualizar<br>Click en 'x' para remover un artículo de su pedido</font><td align=right><font face=verdana,helvetica size=1></FONT><tr><td align=left><a href='javascript:history.back(1)'><img src='shopimages/regresar.gif' border=0 alt='Regresar a la página anterior'></a></table>");
   document.writeln("<a href='javascript:clearBasket();'><img src='shopimages/vaciarpedido.gif' border=0></a>&nbsp;");
   document.writeln("<a href='javascript:updateBasket();'><img src='shopimages/actualizar.gif' border=0 ></a>");
}

function flipImage(imgname,imgsrc) {
    document.images[imgname].src=imgsrc;
}
    function removeItem(itemno) {
        removeFromCookie('MemTyPCode',itemno);
        removeFromCookie('MemTyPName',itemno);
        removeFromCookie('MemTyPWeight',itemno);
        removeFromCookie('MemTyPTaxable',itemno);
        removeFromCookie('MemTyPPrice',itemno);
        removeFromCookie('MemTyPExtraFields',itemno);
        removeFromCookie('MemTyPQuantity',itemno);
        self.location = 'basket.htm';
    }

    function clearBasket() {
        if (confirm('Está seguro de eliminar el pedido?')) {
            index=document.cookie.indexOf('MemTyP');
            document.cookie='MemTyPCode=.; expires='+today+';path=/';
            document.cookie='MemTyPName=.; expires='+today+';path=/';
            document.cookie='MemTyPWeight=.; expires='+today+';path=/';
            document.cookie='MemTyPTaxable=.; expires='+today+';path=/';
            document.cookie='MemTyPPrice=.; expires='+today+';path=/';
            document.cookie='MemTyPExtraFields=.; expires='+today+';path=/';
          
document.cookie='MemTyPQuantity=.; expires='+today+';path=/';
            self.location='basket.htm';
        }
    }
    function changeCurrency(num) {
         index=document.cookie.indexOf('TheCurrency');
         document.cookie='TheCurrency='+(num+1)+'; expires=Friday, 31-Dec-2010 08:00:00 GMT'+';path=/';
         self.location='basket.htm';
    }

    function updateBasket() {
        newItemList='';
        itemlist=0;
        for (var i=1;i<=retrieveCookieCount('MemTyPCode');i++) {
            if (!isNaN(document.basketform.elements['quant'+i].value)) {
                changeCookieValue('MemTyPQuantity',i,eval(document.basketform.elements['quant'+i].value));
            }
        }
        self.location='basket.htm';
    }

// ----->