    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='£' + newPounds + '.' + newPence + '';
        } else {
            newString='£' + 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 (eval(advFrom) > 0 && eval(advFrom) > eval(qty)) applicable=false;
             if (eval(advTo) > 0 && eval(advTo) < eval(qty)) applicable=false;
             if (curr==1 && applicable==true) advnewprice=advPrice;
             if (curr==2 && applicable==true) 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 forceitemtotalinstring(tstring) {
        nstring='';
        for (var i=0; i <= tstring.length; i++) {
            if (tstring.charAt(i)==']') { nstring=nstring+'|1]';
            } else { nstring=nstring+tstring.charAt(i); }
        }
        return nstring;
    }


    function goBuy() {
        ilist='';
        index=document.cookie.indexOf('TiffanyRoseCart');
        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=forceitemtotalinstring(ilist);	
	document.writeln('<input type=hidden name="secuitems" value="'+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;
    }

 taxfield='United Kingdom';

 function showBasket() {
     currency=1;
	     postageprice=3.95;
	     grandtotal=3.95;
     index=document.cookie.indexOf('TiffanyRoseCart');
     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('<h3 class="order">Your order:</h3>');
     document.writeln('<table>');
     document.writeln('<tr class="color">');
     document.writeln('<th width="80"><p class="item"></p></th>');
     document.writeln('<th width="45%">Description & Size</th>');
     document.writeln('<th width="20%"><p class="right_align">Price</p></th>');
     document.writeln('<th>Action</th>');
     document.writeln('</tr>');
     itemlist=0;
	 var thisitem;
	 var itemstart;
     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=1;
             itemtotal=0;itemtotal2=0;
             itemtotal=(eval(theprice*thequantity));
             temptotal=itemtotal*100;
             totprice=totprice+itemtotal;
	     grandtotal=totprice+postageprice;
             itemlist=itemlist+1;

			 
			 
        document.writeln('<tr><td class="shopping_bag"><div id="thumbnails_shopping_bag"><img src="/new-img/products/'+theCode+'-thumb.gif" width="50" height="50" alt="'+theitem+'" border="0"></div></td><td class="shopping_bag">'+theitem+'</td>');
    	document.writeln('<td class="shopping_bag"><p class="right_align">'+presentValue(eval(theprice))+'</td>');
		document.writeln('<td><div style=" width: 80px;"><div id="remove_button"><A HREF="javascript:removeItem('+itemlist+')"><IMG src="/new-img/button_x.gif" style="width: 19px; height: 19px; border-width: 0px;" alt="Remove"></div><div id="remove_text">Remove</div></div></td></tr>');
             } else if (fulllist.substring(i,i+1)=='|') {
                 if (thisitem==1) theCode=fulllist.substring(itemstart,i);
                 if (thisitem==2) theSKU=fulllist.substring(itemstart,i);
                 if (thisitem==3) theitem=fulllist.substring(itemstart,i);
                 if (thisitem== 4) theprice=fulllist.substring(itemstart,i);
               thisitem++; itemstart=i+1;
             }

         }


     document.writeln('<tr class="color"><td colspan="2"><p class="totals">Sub-Total&nbsp;</p></td>');
     document.writeln('<td><p class="right_align"><strong>'+presentValue(totprice)+'</strong></p></td>');
     document.writeln('<td>&nbsp;</td>');
     document.writeln('</tr>');


 if (totprice==0) 

	{ 

     document.writeln('</table>');
     document.writeln('<table border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff width=100%>');
     document.writeln('<tr bgcolor=#ffffff align=center>');
     document.writeln('<td align=center>&nbsp;</td>');
     document.writeln('</tr>');
     document.writeln('<tr bgcolor=#ffffff align=center>');
     document.writeln('<td align=center><font color="862c47"><b>There are no items in your basket</b></font></td>');
     document.writeln('</tr>');
//     document.writeln('</table>');
	}

  
     // document.writeln('<br><div align="center"><a href="javascript:clearBasket();"><img src="/images/button_emptybasket.gif" width=125 height=23 BORDER=0></a>');
     // document.writeln('<a href="javascript:updateBasket();"><img src="/images/button_updatebasket.gif" width=125 height=23 BORDER=0></a></div>');

}

    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('TifffanyRoseCart');
			var expire_days = 30
			var expire_date = new Date()
			var ms_from_now = expire_days * 24 * 60 * 60 * 1000
			expire_date.setTime(expire_date.getTime() + ms_from_now)
			var expire_string = expire_date.toGMTString()
		         document.cookie='TiffanyRoseCart='+newItemList+'; expires= '+expire_string+'; path=/;'
        self.location = '/maternity/info/shopping-bag.html';
    }

    function clearBasket() {
        if (confirm('Are you sure you want to empty your Shopping Basket?')) {
            index=document.cookie.indexOf('TiffanyRoseCart');
            document.cookie='TiffanyRoseCart=.; path=/;'
            self.location='/maternity/info/shopping-bag.html';
        }
    }
    function changeCurrency(num) {
         index=document.cookie.indexOf('TheCurrency');
			var expire_days = 30
			var expire_date = new Date()
			var ms_from_now = expire_days * 24 * 60 * 60 * 1000
			expire_date.setTime(expire_date.getTime() + ms_from_now)
			var expire_string = expire_date.toGMTString()
         document.cookie='TheCurrency='+num+'; expires= '+expire_string+'; path=/;'
         self.location='/maternity/info/shopping-bag.html';
    }

    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('TiffanyRoseCart');
			var expire_days = 30
			var expire_date = new Date()
			var ms_from_now = expire_days * 24 * 60 * 60 * 1000
			expire_date.setTime(expire_date.getTime() + ms_from_now)
			var expire_string = expire_date.toGMTString()
        document.cookie='TiffanyRoseCart='+newItemList+'; expires= '+expire_string+'; path=/;'
        self.location='/maternity/info/shopping-bag.html';
    }



function getcookie(name)
{
	return parseCookie(document.cookie,name,";");
}

function parseCookie(s,token,separator)
{
	var search=token+"=";
	s=""+s; //IE4.0 bug requires this
	if(s.length>0)
	{
		var offset=s.indexOf(search);
		if (offset!=-1)
		{
			offset+=search.length;
			var end=s.indexOf(separator,offset);
			if (end==-1)
				end = s.length;
			return unescape(s.substring(offset,end));
		}
	}
	return "";
}
