        function Mostra(theURL,winName,features) 
        { //v1.2
          window.open(theURL,winName,features);
        }
//******************************************************************************

	function flipImage(url, names)
	{
	   if(navigator.appVersion.lastIndexOf("MSIE 3.0") == -1) document[names].src = url;
	}
    	ua=navigator.userAgent;
    	v=navigator.appVersion.substring(0,1);
    	if ((ua.lastIndexOf("MSIE")!=-1) && (v!='1') && (v!='2') && (v!='3')) 
	{
           document.onmouseover=makeEspecial;
           document.onmouseout=makeNormal;
    	}
    	function makeEspecial() 
	{
           src = event.toElement;
           if (src.tagName == "A") 
	   {
              src.oldcol = src.style.color;
              src.style.color = "red"; 
           }
    	}
	function makeNormal() 
	{
           src=event.fromElement;
           if (src.tagName == "A") 
	   {
              src.style.color = src.oldcol;
	   }
	}

//**********************************************************************************************
function Data() {
   hoje = new Date()
   document.basketform.data.value = hoje;
}
//**********************************************************************************************


    function goBuy() {
        ilist='';
     index=document.cookie.indexOf('TheCurrency');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     currency=document.cookie.substring(countbegin,countend);
        index=document.cookie.indexOf('TheBasket');
        countbegin=(document.cookie.indexOf('=', index)+1);
        countend=document.cookie.indexOf(';',index);
        if(countend==-1) { countend=document.cookie.length; }
        fulllist=document.cookie.substring(countbegin,countend);
        for(var i=0; i<= fulllist.length;i++) {
            if(fulllist.substring(i,i+1)=='[') {
                itemstart=i;
            } else if (fulllist.substring(i,i+1)==']') {
                itemend=i+1;
                ilist=ilist+fulllist.substring(itemstart,itemend);
            }
        }
        ilist=changeSpaces(ilist);
        top.location='buy.htm?currency='+currency+'&items='+ilist;
    }
//**********************************************************************************************


    function goBuyssl() {
        ilist='';
     index=document.cookie.indexOf('TheCurrency');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     currency=document.cookie.substring(countbegin,countend);
        index=document.cookie.indexOf('TheBasket');
        countbegin=(document.cookie.indexOf('=', index)+1);
        countend=document.cookie.indexOf(';',index);
        if(countend==-1) { countend=document.cookie.length; }
        fulllist=document.cookie.substring(countbegin,countend);
        for(var i=0; i<= fulllist.length;i++) {
            if(fulllist.substring(i,i+1)=='[') {
                itemstart=i;
            } else if (fulllist.substring(i,i+1)==']') {
                itemend=i+1;
                ilist=ilist+fulllist.substring(itemstart,itemend);
            }
        }
        ilist=changeSpaces(ilist);
        top.location='buyssl.php?currency='+currency+'&items='+ilist;
    }
//**********************************************************************************************

    function changeSpaces(tstring) {
        nstring='';
        for (var i=0; i <= tstring.length; i++) {
            if (tstring.charAt(i)==' ') { nstring=nstring+'^';
            } else { nstring=nstring+tstring.charAt(i); }
        }
        return nstring;
    }

//**********************************************************************************************

function checkAdvanced(adv) {
     newAdv='';advlist=0;
    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;
            advPrice2=adv.substring(advstart,advend);
            advlist++; applicable=true;
            if (applicable==true) {
                newAdv = newAdv+ '{'+advFrom+'~'+advTo+'~'+advPrice+'~'+advPrice2+'}'
            }
        } else if (adv.substring(j,j+1)=='~') {
            if (thisadv== 1) advFrom=adv.substring(advstart,j);
            if (thisadv== 2) advTo=adv.substring(advstart,j);
            if (thisadv== 3) advPrice=adv.substring(advstart,j);
            if (thisadv== 4) advPrice2=adv.substring(advstart,j);
            thisadv++;advstart=j+1;
        }
    }
    if (newAdv=='') newAdv='none';
    return newAdv;
}
//**********************************************************************************************

function continuacompra() {
 if (confirm('Muda para tela de Cesta de Compras ? ')) 
self.location.href = 'basket.htm'
}
//**********************************************************************************************
    function buyItem(newItem,newPrice,newPrice2,newTaxable,newWeight,newAP,newQuantity) {
        if(newQuantity<=0) {
            rc = alert('A quantidade está incorreta');
        } else {
            if (confirm('Colocar o produto  '+newItem+'  ( R$ '+newPrice+',00 ) em seu pedido? ')) {
                 if (newAP!='none') {
                     newAP=checkAdvanced(newAP,newField1,newField2);
                 }
                index=document.cookie.indexOf('TheBasket');
                countbegin=(document.cookie.indexOf('=',index)+1);
                countend=document.cookie.indexOf(';',index);
                if(countend==-1) { countend=document.cookie.length; }
                 fulllist = document.cookie.substring(countbegin,countend);
                 amended = false;
                 newItemList=''; itemlist=0;
                 for (var i=0;i<=fulllist.length;i++) {
                     if (fulllist.substring(i,i+1) == '[') {
                         thisitem=1;
                         itemstart=i+1;
                         fullstart=i+1;
                     } else if (fulllist.substring(i,i+1) == ']') {
                         itemend=i;
                         thequantity=fulllist.substring(itemstart,itemend);
                         itemlist++;
                         if (theItem==newItem ) {
                             amended=true;
                             tempquantity=eval(thequantity)+eval(newQuantity);
                             newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+thePrice2+'|'+theTaxable+'|'+theWeight+'|'+newAP+'|'+tempquantity+']';
                         } else {
                             newItemList=newItemList+'['+theItem+'|'+thePrice+'|'+thePrice2+'|'+theTaxable+'|'+theWeight+'|'+theAP+'|'+thequantity+']';
                         }
                     } else if (fulllist.substring(i,i+1)=='|') {
                         if (thisitem==1) theItem=fulllist.substring(itemstart,i);
                         if (thisitem== 2) thePrice=fulllist.substring(itemstart,i);
                         if (thisitem== 3) thePrice2=fulllist.substring(itemstart,i);
                         if (thisitem== 4) theTaxable=fulllist.substring(itemstart,i);
                         if (thisitem== 5) theWeight=fulllist.substring(itemstart,i);
                         if (thisitem== 6) theAP=fulllist.substring(itemstart,i);
                         thisitem++;itemstart=i+1;
                     }
                 }
                 if (amended==false) {
                     newItemList=newItemList+'['+newItem+'|'+newPrice+'|'+newPrice2+'|'+newTaxable+'|'+newWeight+'|'+newAP+'|'+newQuantity+']'; }
                 index = document.cookie.indexOf('TheBasket');
                 document.cookie='TheBasket='+newItemList+'; expires=Friday, 31-Dec-2050 08:00:00 GMT';
            }
        }
    }

//**********************************************************************************************

    function presentValue(value) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        dec='1';
        for (var i=1; i<=2;i++) {
            dec=dec+'0';
        }
        if (value>0) {
            newPence=Math.round((value+.000008 - newPounds)*(eval(dec)));
        } else {
            newPence=0;
        }
        compstring='9';
        for (var i=1; i <=2-1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        if (2>0) {
            newString='R$' + newPounds + '.' + newPence + '';
        } else {
            newString='R$' + newPounds + '';
        }
        return (newString);
    }
//**********************************************************************************************
function getAdvanced(adv,curr,qty) {
     newAdv='';advlist=0;applicable=true;advnewprice=0;
    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;
            advPrice2=adv.substring(advstart,advend);
            advlist++; applicable=true;
            if (applicable==true) {
             if (advFrom > 0 && advFrom > qty) applicable=false;
             if (advTo > 0 && advTo < qty) applicable=false;
             if (curr==1) advnewprice=advPrice;
             if (curr==2) advnewprice=advPrice2;
            }
        } else if (adv.substring(j,j+1)=='~') {
            if (thisadv== 1) advFrom=adv.substring(advstart,j);
            if (thisadv== 2) advTo=adv.substring(advstart,j);
            if (thisadv== 3) advPrice=adv.substring(advstart,j);
            if (thisadv== 4) advPrice2=adv.substring(advstart,j);
            thisadv++;advstart=j+1;
        }
    }
     return advnewprice;
}
//*********************************************************************************************
    function presentValue2(value) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        dec='1';
        for (var i=1; i<=2;i++) {
            dec=dec+'0';
        }
        if (value>0) {
            newPence=Math.round((value+.000008 - newPounds)*(eval(dec)));
        } else {
            newPence=0;
        }
        compstring='9';
        for (var i=1; i <=2-1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        if (2>0) {
            newString='US$' + newPounds + '.' + newPence + '';
        } else {
            newString='US$' + newPounds + '';
        }
        return (newString);
    }

//*********************************************************************************************

 taxfield='United Kingdom';
 function showBasket() {
     index=document.cookie.indexOf('TheCurrency');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     currency=document.cookie.substring(countbegin,countend);
     index=document.cookie.indexOf('TheBasket');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     fulllist=document.cookie.substring(countbegin,countend);
    totprice=0;totprice2=0;shippingtotal=0;shippingtotal2=0;taxtotalone=0;taxtotalone2=0;taxtotaltwo=0;taxtotaltwo2=0;ordertotal=0;ordertotal2=0;
     taxablestandard=0;taxablesecond=0;taxable=0;
     document.writeln('<table border=0 cellpadding=4 cellspacing=3>');
     document.writeln('<tr>');
     document.writeln('<td align="center" width="100" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Produto</font></b></td>');
     if (currency==1) { document.writeln('<td align="center" width="64" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Preço</font></b></td>');}
     if (currency==2) { document.writeln('<td align="center" width="64" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Preço</font></b></td>');}
     document.writeln('<td align="center" width="77" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Quantidade</font></b></td><td align="center" width="89" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Valor Total</font></b></td><td align="center" width="79" bgcolor="5000A0"><b><font face="Verdana" size="2" color="FFFFFFF">Ação</font></b></td></td>');
     document.writeln('</tr>');
     itemlist=0;
     for (var i=0; i<=fulllist.length;i++) {
         if (fulllist.substring(i,i+1)=='[') {
             itemstart=i+1;
             thisitem=1;
         } else if (fulllist.substring(i,i+1)==']') {
             itemend=i;
             thequantity=fulllist.substring(itemstart,itemend);
             itemtotal=0;itemtotal2=0;
             if (theAP!='none') {
             if (currency==1) { tempprice=getAdvanced(theAP,1,thequantity); if (tempprice>0) theprice=tempprice; }
             if (currency==2) { tempprice=getAdvanced(theAP,2,thequantity); if (tempprice>0) theprice2=tempprice; }
             }
             itemtotal=(eval(theprice*thequantity));
             temptotal=itemtotal*100;
             totprice=totprice+itemtotal;
             itemtotal2=(eval(theprice2*thequantity));
             totprice2=totprice2+itemtotal2;
             temptotal2=itemtotal2*100;
             itemlist=itemlist+1;
         document.writeln('<tr><td align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF">'+theitem+'</td>');
     if (currency==1) { document.writeln('<td align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF">'+presentValue(eval(theprice))+'</td>');}
     if (currency==2) { document.writeln('<td align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF">'+presentValue2(eval(theprice2))+'</td>');}
     document.writeln('<td  align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF" <b><font face="Verdana" size="2" color="FFFFFFF"><input type=text name="quant'+itemlist+'" value='+thequantity+' size=2></td>');
     if (currency==1) { document.writeln('<td  align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF">'+presentValue(itemtotal)+'</td>');}
     if (currency==2) { document.writeln('<td  align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF">'+presentValue2(itemtotal2)+'</td>');}
     document.writeln('<td  align=center bgcolor="6880ff" <b><font face="Verdana" size="2" color="FFFFFFF"><a href="javascript:removeItem('+itemlist+');">Remover</a></td></tr>');
             } else if (fulllist.substring(i,i+1)=='|') {
                 if (thisitem==1) theitem=fulllist.substring(itemstart,i);
                 if (thisitem== 2) theprice=fulllist.substring(itemstart,i);
                 if (thisitem== 3) theprice2=fulllist.substring(itemstart,i);
                 if (thisitem== 4) thetaxable=fulllist.substring(itemstart,i);
                 if (thisitem== 5) theweight=fulllist.substring(itemstart,i);
                     if (thisitem== 6) theAP=fulllist.substring(itemstart,i);
               thisitem++; itemstart=i+1;
             }
         }
     document.writeln('<tr><td bgcolor="6880ff" colspan=3 <b><font face="Verdana" size="2" color="000820" >Total em Produtos</td align=center bgcolor="2024ff" <b><font face="Verdana" size="2" color="2024ff">');
     if (currency==1) { document.writeln('<td  align=center bgcolor="90a9b9"<b><font face="Verdana" size="2" color="FFFFFFF">'+presentValue(totprice)+'</td>');}
     if (currency==2) { document.writeln('<td align="center" width="103" bgcolor="6880ff"<b><font face="Verdana" size="2" color="FFFFFFF">&nbsp;</td>'+presentValue2(totprice2)+'</td>');}
     document.writeln('<td align="center" width="103" bgcolor="6880ff" <b><font face="Verdana" size="2" color="red">&nbsp;</td>');
     document.writeln('</tr>');
     document.writeln('</table><br>');
     document.writeln('<a href="javascript:clearBasket();">Esvaziar Minha Cesta de Compras</a> | ');
     document.writeln('<a href="javascript:updateBasket();">Atualizar Minha Cesta de Compras</a> | ');

}
//*********************************************************************************************
    function removeItem(itemno) {
        newItemList=null;
        itemlist=0;
        for(var i=0;i<=fulllist.length;i++) {
            if (fulllist.substring(i,i+1)=='[') {
                itemstart=i+1;
            } else if (fulllist.substring(i,i+1)==']') {
                itemend=i;
                theitem = fulllist.substring(itemstart,itemend);
                itemlist=itemlist+1;
                if(itemlist != itemno) {
                    newItemList = newItemList+'['+fulllist.substring(itemstart,itemend)+']';
                }
            }
        }
        index = document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket='+newItemList+'; expires=Friday, 31-Dec-2050 08:00:00 GMT';
        self.location = 'basket.htm';
    }
//*********************************************************************************************
    function clearBasket() {
        if (confirm('Você deseja Esvaziar Toda a Cesta de Compras ?')) {
            index=document.cookie.indexOf('TheBasket');
            document.cookie='TheBasket=.';
            self.location='basket.htm';
        }
    }
//*********************************************************************************************
    function updateBasket() {
        newItemList='';
        itemlist=0;
        for(var i=0;i<=fulllist.length; i++) {
            if(fulllist.substring(i,i+1)=='[') {
                thisitem=1;
                itemstart=i+1;
                fullstart=i+1;
            } else if(fulllist.substring(i,i+1)==']') {
                itemend=i;itemlist++;
                thiselement=document.basketform.elements['quant'+itemlist].value;
                newItemList=newItemList+'['+partList+'|'+thiselement+']'
            } else if(fulllist.substring(i,i+1)=='|') {
                partList=fulllist.substring(itemstart,i);
            }
        }
        index=document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket='+newItemList+'; expires=Friday, 31-Dec-2050 08:00:00 GMT';
        self.location='basket.htm';
    }

//*********************************************************************************************

function variaveis() {
    document.basketform.bappName.value = navigator.appName;
    document.basketform.bappVersion.value = parseInt(navigator.appVersion);
}

//*********************************************************************************************

function vfulllist() {
     index=document.cookie.indexOf('TheCurrency');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     currency=document.cookie.substring(countbegin,countend);
     index=document.cookie.indexOf('TheBasket');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     fulllist=document.cookie.substring(countbegin,countend);

     document.basketform.flist.value = fulllist;
}

//*********************************************************************************************
   function pedido() {
   taxfield='United Kingdom';
     index=document.cookie.indexOf('TheCurrency');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     currency=document.cookie.substring(countbegin,countend);
     index=document.cookie.indexOf('TheBasket');
     countbegin=(document.cookie.indexOf('=',index)+1);
     countend=document.cookie.indexOf(';',index);
     if (countend==-1) { countend=document.cookie.length; }
     fulllist=document.cookie.substring(countbegin,countend);

    pedido = ' [<   item   >|<  preco unit   >|<    quantidade   > ]    ' ;

     taxablestandard=0;taxablesecond=0;taxable=0;
     itemlist=0;
     for (var i=0; i<=fulllist.length;i++) {
         if (fulllist.substring(i,i+1)=='[') {
             itemstart=i+1;
             thisitem=1;
         } else if (fulllist.substring(i,i+1)==']') {
             itemend=i;
             thequantity=fulllist.substring(itemstart,itemend);
             itemtotal=0;itemtotal2=0;
             if (theAP!='none') {
             if (currency==1) { tempprice=getAdvanced(theAP,1,thequantity); if (tempprice>0) theprice=tempprice; }
             if (currency==2) { tempprice=getAdvanced(theAP,2,thequantity); if (tempprice>0) theprice2=tempprice; }
             }
             itemtotal=(eval(theprice*thequantity));
             temptotal=itemtotal*100;
             totprice=totprice+itemtotal;
             itemtotal2=(eval(theprice2*thequantity));
             totprice2=totprice2+itemtotal2;
             temptotal2=itemtotal2*100;
             itemlist=itemlist+1;

             pedido = pedido+'     [<..'+theitem+'...>|<...'+theprice+'...>|<...'+thequantity+'..>]     '            

            } else if (fulllist.substring(i,i+1)=='|') {
                 if (thisitem==1) theitem=fulllist.substring(itemstart,i);
                 if (thisitem== 2) theprice=fulllist.substring(itemstart,i);
                 if (thisitem== 3) theprice2=fulllist.substring(itemstart,i);
                 if (thisitem== 4) thetaxable=fulllist.substring(itemstart,i);
                 if (thisitem== 5) theweight=fulllist.substring(itemstart,i);
                     if (thisitem== 6) theAP=fulllist.substring(itemstart,i);
               thisitem++; itemstart=i+1;
             }
     document.basketform.pedido.value = pedido; 
        }
}  
//********************************************************************************************
function replaceSpaces(tstring) {
        nstring='';
        for(var i=0;i<=tstring.length;i++) {
            if (tstring.charAt(i)=='^') { nstring=nstring+' ';
            } else { nstring=nstring+tstring.charAt(i); }
        }
        return nstring;
    }
//*********************************************************************************************
    function recalculateTax() {
        foundloc = false;
        tottax = 0.00;
        if (taxfield.toLowerCase() == 'france') {
            tottax = taxablestandard*(2/100);
            tottax = tottax+ taxablesecond*(4/100);
            foundloc = true;
        }
        if (taxfield.toLowerCase() == 'united kingdom') {
            tottax = taxablestandard*(2/100);
            tottax = tottax+ taxablesecond*(4/100);
            foundloc = true;
        }
         if (currency==1) {
        document.basketform.showtax.value = presentValue(tottax)
        document.basketform.Tax_Total.value = presentValue(tottax)
        document.basketform.showtotal.value = presentValue(tottax+totprice+shippingtotal)
        document.basketform.Order_Total.value = presentValue(tottax+totprice+shippingtotal)
        document.basketform.flist.value = fulllist
    }
     if (currency==2) {
        document.basketform.showtax.value = presentValue2(tottax)
        document.basketform.Tax_Total.value = presentValue2(tottax)
        document.basketform.showtotal.value = presentValue2(tottax+totprice+shippingtotal)
        document.basketform.Order_Total.value = presentValue2(tottax+totprice+shippingtotal)
        document.basketform.flist.value = fulllist
    }
    }

//*********************************************************************************************
    numFields=0;
    function addFiller(curnum) {
        newnum=parseInt(curnum);
        if (newnum<10) return '00'+newnum;
        if (newnum<100) return '0'+newnum;
        return newnum;
    }
//********************************************************************************************
    function nextField() {
        numFields++;
        return addFiller(numFields)+'-';
    }
//********************************************************************************************
    function changeCurrency(num) {
         index=document.cookie.indexOf('TheCurrency');
         document.cookie='TheCurrency='+num+'; expires=Friday, 31-Dec-2050 08:00:00 GMT';
         self.location='basket.htm';
    }
//********************************************************************************************

