shipping = new Array(12);
shippingcountries = new Array(1);
shipping[0] = 1;
shipping[1] = 999;
shipping[2] = "8.00";
shipping[3] = 1;
shipping[4] = 1000;
shipping[5] = 99999;
shipping[6] = "15.00";
shipping[7] = 1;
shipping[8] = 100000;
shipping[9] = 999999;
shipping[10] = "20.00";
shipping[11] = 1;
shippingcountries[1] = "1,1000,100000";
alltheitems=0;singletax='';shippingfile='';primaryfield='';secondaryfield='';singlefield='';
function recalculateShipping() {
    found=false;
    thistotal=0;
    for(var i=0; i<= 11; i=i+4) {
        if(found==false) {
            countrylist=shippingcountries[shipping[i+3]]+',';
            countbegin=0;
            countend=countrylist.length;
            itemstart=0;
            for (var j=0; j<=countrylist.length;j++) {
                if (countrylist.substring(j,j+1)==',') {
                    thiscountry=countrylist.substring(itemstart,j);
                    itemstart=j+1;
                    if (found==false) {
                        if(shipping[i] <= totalforshipping && shipping[i+1] >= totalforshipping) {
                            thistotal=shipping[i+2];
                            found=true;
                        }
                    }
                }
            }
        }
    }
    thistotal=eval(thistotal);        
    shippingtotal=thistotal;
}
function recalculateTax() {
    tottax = 0.00;
    tottax = eval((taxablestandard+shippingtotal)*(17.5/100));
	ordertax = correct(tottax);
    ordertotal = ordertax+totprice+shippingtotal;
}
function showPrice(pricestring,symbol) {
	tmp=Math.round(pricestring*1000)/1000;
	tmp=Math.round(tmp*100)/100;
	if (tmp == parseInt(tmp)) {
		pounds=new String(tmp);
		pence="00";
	} else {
		tmp2=parseInt(tmp);
		tmp3=Math.round((tmp-tmp2)*100);
		pounds=new String(tmp2);
		if (tmp3 < 10 ) {
			pence="0"+new String(tmp3);
		} else {
			pence=new String(tmp3);
		}
		pence=pence.substr(0,2);
	}
	pricestring=symbol+pounds+"."+pence;
	return pricestring;
}
function correct(pricestring) {
	tmp=Math.round(pricestring*1000)/1000;
	tmp=Math.round(tmp*100)/100;
	return tmp;
}
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 goShopping(){
    index = document.cookie.indexOf('location');
    countbegin=(document.cookie.indexOf('=',index)+1);
    countend=document.cookie.indexOf(';',index);
    if(countend==-1) { countend=document.cookie.length; }
    pageId=document.cookie.substring(countbegin,countend);
	top.location=pageId;
}
