function formatCurrency(num) {
num = num.toString().replace(/\R|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '&pound' + num + '.' + cents);
}

function tel(id_nr,hoeveel,des,prise,titel,gewig1){

var objs
var obj
var new_string
var new_value
var does_exist
var total_products
round_number = eval("document.vorm1.anum"+id_nr+".value")
round_number = Math.round(round_number)


if(isNaN(eval("document.vorm1.anum"+id_nr+".value")) || eval("document.vorm1.anum"+id_nr+".value")=="" || eval("document.vorm1.anum"+id_nr+".value") != eval(round_number) || eval("document.vorm1.anum"+id_nr+".value") < 0
|| eval("document.vorm1.anum"+id_nr+".value")== 0 ){
alert("please enter a valid quantity.")
o = eval("document.vorm1.anum"+id_nr+"")
o.focus()
}else{

does_exist = 0

new_string = "<html><head></head><body><form name='vorm' method='post' action='view_cart.asp'><input type='hidden' name='total_products' value='0'><input type='hidden' name='total_price' value='0'>"
obj = parent.basket.document.vorm
objs = obj.length
objs = eval(objs)
for (z=0;z<objs;z++){
if (obj.elements[z].name.substring(0,4)=="item"){
	if (obj.elements[z].name=="item"+id_nr+""){
	does_exist = 1
		if (eval(hoeveel)<0 && eval("-"+obj.elements[z].value)>eval(hoeveel)){
		hoeveel = eval("-"+obj.elements[z].value)
		}
	new_value = eval(obj.elements[z].value)+eval(hoeveel)
	}else{
	new_value = eval(obj.elements[z].value)
	}
	if (new_value == 0){
	does_exist = 0
	}else{
	new_string = new_string+"<input type='hidden' name='"+obj.elements[z].name+"' value='"+new_value+"'><br>"
	field_name = obj.elements[z].name
	field_name = "description"+field_name.replace("item","")
	field_name2 = "price"+field_name.replace("description","")
	field_name3 = "titel"+field_name.replace("description","")
	field_name4 = "gewig"+field_name.replace("description","")
	new_string = new_string+"<input type='hidden' name='"+field_name+"' value='"+eval("obj."+field_name+".value")+"'>"
	new_string = new_string+"<input type='hidden' name='"+field_name3+"' value='"+eval("obj."+field_name3+".value")+"'>"
	new_string = new_string+"<input type='hidden' name='"+field_name2+"' value='"+eval("obj."+field_name2+".value")+"'>"
	new_string = new_string+"<input type='hidden' name='"+field_name4+"' value='"+eval("obj."+field_name4+".value")+"'>"
	eval("document.vorm1.naam"+id_nr+"").value = new_value
	}
}
}
if (does_exist == 0){
	if (eval(hoeveel)<=0){
		hoeveel=0
	}else{
		new_string = new_string+"<input type='hidden' name='item"+id_nr+"' value='"+hoeveel+"'>"
		new_string = new_string+"<input type='hidden' name='description"+id_nr+"' value='"+des+"'>"
		new_string = new_string+"<input type='hidden' name='titel"+id_nr+"' value='"+titel+"'>"
		new_string = new_string+"<input type='hidden' name='price"+id_nr+"' value='"+prise+"'>"
		new_string = new_string+"<input type='hidden' name='gewig"+id_nr+"' value='"+gewig1+"'>"
		eval("document.vorm1.naam"+id_nr+"").value = hoeveel
	}
}
new_string = new_string+"</form></body></html>"
total_products = eval(obj.total_products.value)+eval(hoeveel)
parent.basket.document.write(new_string)
parent.basket.document.close()
parent.basket.document.vorm.total_products.value = total_products

if (does_exist == 1 ){
nuwe_waarde = eval("parent.basket.document.vorm.item"+id_nr+".value")
}
else{
nuwe_waarde = hoeveel
}
eval("document.vorm1.naam"+id_nr+"").value = nuwe_waarde
eval("document.vorm1.anum"+id_nr+"").value = ""
show_basket()
}
}

function get_product(nr){
var nuwe_waarde
var obj
nuwe_waarde = 0
obj = eval(parent.basket.document.vorm)
if (eval("obj.item"+nr)== eval(obj.niks)){
nuwe_waarde = 0
}else{
nuwe_waarde = eval("obj.item"+nr+".value")
}
eval("document.vorm1.naam"+nr+"").value = nuwe_waarde
}

function show_basket(){

var objs
var obj
var new_string
var field_name
//basket
new_string = "<html><head></head><body bgcolor=#C8D4C8 topmargin=5>"
total_price = 0
qty = 0
obj = parent.basket.document.vorm
objs = obj.length
objs = eval(objs)
	for (q=0;q<objs;q++){
		if (obj.elements[q].name.substring(0,4)=="desc"){
			subtotal = 0
			field_name = obj.elements[q].name
			field_name = field_name.replace("description","item")
			field_name2 = field_name.replace("item","price")
			qty = eval(qty)+eval(eval("obj."+field_name+".value"))
subtotal = eval("obj."+field_name2+".value")*eval("obj."+field_name+".value")
total_price = total_price+subtotal
		}
	}
new_string = new_string+"<table border=0 width=100% height=100% >"
new_string = new_string+"<tr><td align='center' colspan=2 style='border-bottom: thin solid #ffffff 1pt'><a href='view_cart.asp' target='main' onFocus='if(this.blur)this.blur()'><img src='images/viewbasket.gif' width='110' height='12' alt='' border='0'></a></td></tr>"
new_string = new_string+"<tr style='font-family:arial; font-size:9pt;color:#000000'>"
new_string = new_string+"<td>"+qty+" items</td>"
new_string = new_string+"<td align='right'>"+formatCurrency(total_price)+"</td>"
new_string = new_string+"</tr>"
new_string = new_string+"</table>"


parent.cart.document.write(new_string)
parent.cart.document.close()
}

function view_cart(con){

output_string = ""
output_string = output_string+""

output_string = output_string+"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>"
output_string = output_string+"<html>"
output_string = output_string+"<head>"
output_string = output_string+"<title>Untitled</title><link rel='STYLESHEET' type='text/css' href='styles.css'>"

output_string = output_string+"<SCRIPT LANGUAGE='JavaScript' SRC='./javascript.js'></script>"

output_string = output_string+"<body><form name=vorm1 action=signin.asp method=post >"
output_string = output_string+"<table border=0 width=630 cellpadding=2 cellspacing=2>"
output_string = output_string+"<tr><td valign='top' style='padding-top:5px' class='alltext'>"
output_string = output_string+"<h3>VIEW BASKET</h3></td></tr>"

output_string = output_string+"<tr><td class='smalltext'>This page shows the contents of your shopping cart. Use the arrows to increase or decrease the quantity of that item by one. By clicking the remove button, an item will be deleted completely from your shopping cart."

output_string = output_string+"<p class='alltext'><b>Please note:</b><br>Next day delivery in the UK and Scotland, Monday to Thursday<br><font size=1>(we do not deliver on Friday, Saturday or Sunday)</font><br>All orders are subject to our standard terms and conditions<br><span style=color:#ff0000>Payments are processed offline, we will contact you to confirm your order and payment details</span></td></tr></table>"

items_string = ""
obj = parent.basket.document.vorm
objs = obj.length
objs = eval(objs)
count_items = 0
tot = 0
tot_gewig = 0
for (z=0;z<objs;z++){
if (obj.elements[z].name.substring(0,4)=="item"){
naam = obj.elements[z].name
nommer = naam.replace("item","")
count_items = count_items+1
qty = eval("parent.basket.document.vorm.item"+nommer+".value")
description = eval("parent.basket.document.vorm.description"+nommer+".value")
price = eval("parent.basket.document.vorm.price"+nommer+".value")
titel = eval("parent.basket.document.vorm.titel"+nommer+".value")
gewig = eval("parent.basket.document.vorm.gewig"+nommer+".value")
//if ( NaN(eval(gewig))==true){
//gewig = 0
//}else{
//alert(NaN(gewig))
gewig = eval(gewig)*eval(qty)
//}
tot_gewig = eval(tot_gewig)+eval(gewig)


items_string = items_string+"<tr>"
items_string = items_string+"<td class='carttext' id='sp"+nommer+"' ><input type='hidden' name='anum"+nommer+"' value='"+qty+"'><input type='text' name='naam"+nommer+"' value='"+qty+"' size='3' readonly onfocus='this.blur()'  style='background-color: transparent; border-style: none;' ></td>"
items_string = items_string+"<td width=8 class='carttext'><a href=javascript:tel("+nommer+",'1','','"+price+"','','');view_cart('"+con+"') ><img src='images/up.gif' width='8' height='8' border='0' alt=''></a><br><a href=javascript:tel("+nommer+",'-1','','"+price+"','','');view_cart('"+con+"') ><img src='images/down.gif' width='8' height='8' border='0' alt=''></a></td>"
items_string = items_string+"<td class='carttext'><b>"+titel+"</b><input type='hidden' name='nommer"+count_items+"' value='"+nommer+"'><input type='hidden' name='qty"+count_items+"' value='"+qty+"'><input type='hidden' name='title"+count_items+"' value='"+titel+"'><input type='hidden' name='description"+count_items+"' value='"+description+"'></td>"
//items_string = items_string+"<td class='carttext' width=10 ><input type='hidden' name='description"+count_items+"' value='"+description+"'>"+description+"</td>"
items_string = items_string+"<td class='carttext'><input type='hidden' name='gewig"+count_items+"' value='"+gewig+"'>"+gewig+"</td>"
items_string = items_string+"<input type='hidden' name='price"+count_items+"' value='"+price+"'><td align='right' class='carttext'>&pound; "+price+"</td>"
items_string = items_string+"<td align='right' class='carttext'><a href=javascript:tel('"+nommer+"','-'+vorm1.naam"+nommer+".value,'','"+price+"','','');view_cart('"+con+"') ><img src='images/remove.jpg' width='55' height='14' alt='' border='0' vspace=1></a></td></tr>"

tot = eval(tot)+(eval(price)*eval(qty))

}
}

output_string = output_string+"<input type='hidden' name='count_items' value='"+count_items+"'>"
output_string = output_string+"<p><table width=630 border=0 cellpadding=0 cellspacing=0 class='border' bgcolor=#F2F4F2>"
output_string = output_string+"<tr>"
output_string = output_string+"<td colspan=2 class='title'>Qty</td>"
output_string = output_string+"<td class='title'>Item</td>"
//output_string = output_string+"<td class='title'>Description</td>"
output_string = output_string+"<td class='title'>Weight</td>"
output_string = output_string+"<td class='title' align='right'>Price</td>"
output_string = output_string+"<td class='title'>&nbsp;<td></tr>"

if (eval(count_items)==0){
output_string = output_string+"<tr><td colspan=6 class=title >no items added to your shopping cart</td></tr>"
}else{
output_string = output_string+items_string
output_string = output_string+"<tr><td colspan=7>&nbsp;</td></tr>"
}
if (con =="oth"){
s = "0.00"
output_string = output_string+"<tr><td colspan=2 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Shipping fees cannot be calculated as your country is not listed</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}else{
if (con=="no"){
s = "0.00"
output_string = output_string+"<tr><td colspan=2 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Please log in to calculate your shipping fees</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}else{
tot = eval(tot)+eval(con)

if (tot_gewig>10){
output_string = output_string+"<tr><td colspan=2 class='cartbottom' align='right'>Note:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Orders over 10 kg attract an additional shipping fee, to be confirmed</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}
output_string = output_string+"<tr><td colspan=4 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td class='cartbottom' align='right'><b> "+formatCurrency(con)+"</b></td>"
s = con
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}
}

output_string = output_string+"<tr><td colspan=4 class='cartbottom' align='right'>Sub-Total:</td>"
output_string = output_string+"<td class='cartbottom' align='right'><b> "+formatCurrency(tot)+"</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'>including VAT</td></tr>"
output_string = output_string+"</table>"

output_string = output_string+"<br>"
//output_string = output_string+"<form action='signin.htm'>"
if (eval(count_items)==0){
}else{
output_string = output_string+"<table width=630>"
output_string = output_string+"<tr class='subtitle'>"
output_string = output_string+"<td align='right'><input type='button' value='empty cart' style='font-family:arial; font-size:9pt; background:#FFE098; border: thin solid #351B00 1pt' onclick=empty_all();view_cart('"+con+"'); ></td>"
output_string = output_string+"<td align='right' width=80><input type='button' value='check out' style='font-family:arial; font-size:9pt; background:#FFE098; border: thin solid #351B00 1pt' onclick=note1() ><input type='hidden' name='ship' value='"+ s +"'></td></tr></table>"
}
output_string = output_string+"</form>"

output_string = output_string+"<p>&nbsp;</p>"

output_string = output_string+"</body>"
output_string = output_string+"</html>"
document.write(output_string)
document.close()
}

function empty_all(){

output_string = ""
output_string = output_string+"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>"
output_string = output_string+"<html>"
output_string = output_string+"<head>"
output_string = output_string+"<title>Untitled</title>"
output_string = output_string+"</head>"
output_string = output_string+"<body>"
output_string = output_string+"<form name=vorm method=post action='view_cart.asp'>"
output_string = output_string+"<input type='hidden' name='total_products' value='0'>"
output_string = output_string+"<input type='hidden' name='total_price' value='0'>"
output_string = output_string+"</form>"
output_string = output_string+"</body>"
output_string = output_string+"</html>"

parent.basket.document.write(output_string)
parent.basket.document.close()
show_basket()

}

function note1(){
if (confirm("This will send your order, do you wish to continue?")==true){
document.vorm1.submit();
}
}


function view_cart2(con){

output_string = ""
output_string = output_string+""

output_string = output_string+"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>"
output_string = output_string+"<html>"
output_string = output_string+"<head>"
output_string = output_string+"<title>Untitled</title><link rel='STYLESHEET' type='text/css' href='styles.css'>"

output_string = output_string+"<SCRIPT LANGUAGE='JavaScript' SRC='./javascript.js'></script>"

output_string = output_string+"<body><form name=vorm1 action=signin.asp method=post >"
output_string = output_string+"<table border=0 width=630 cellpadding=2 cellspacing=2>"
output_string = output_string+"<tr><td valign='top' style='padding-top:5px' class='alltext'>"
output_string = output_string+"<h3>THANK YOU FOR ORDERING</h3></td></tr>"

output_string = output_string+"<tr><td class='smalltext'>This page shows the contents of your shopping cart."

output_string = output_string+"<p class='alltext'>All orders are subject to our <u>standard terms and conditions</u></p></td></tr></table>"

items_string = ""
obj = parent.basket.document.vorm
objs = obj.length
objs = eval(objs)
count_items = 0
tot = 0
tot_gewig = 0
for (z=0;z<objs;z++){
if (obj.elements[z].name.substring(0,4)=="item"){
naam = obj.elements[z].name
nommer = naam.replace("item","")
count_items = count_items+1
qty = eval("parent.basket.document.vorm.item"+nommer+".value")
description = eval("parent.basket.document.vorm.description"+nommer+".value")
price = eval("parent.basket.document.vorm.price"+nommer+".value")
titel = eval("parent.basket.document.vorm.titel"+nommer+".value")
gewig = eval("parent.basket.document.vorm.gewig"+nommer+".value")

gewig = eval(gewig)*eval(qty)

tot_gewig = eval(tot_gewig)+eval(gewig)


items_string = items_string+"<tr>"
items_string = items_string+"<td class='carttext' id='sp"+nommer+"' >"+qty+"</td>"
items_string = items_string+"<td class='carttext'><b>"+titel+"</b></td>"
//items_string = items_string+"<td class='carttext'>"+description+"</td>"
items_string = items_string+"<td class='carttext'>"+gewig+"</td>"
items_string = items_string+"<td align='right' class='carttext'>&pound; "+price+"</td>"

tot = eval(tot)+(eval(price)*eval(qty))

}
}

output_string = output_string+"<input type='hidden' name='count_items' value='"+count_items+"'>"
output_string = output_string+"<p><table width=630 border=0 cellpadding=0 cellspacing=0 class='border' bgcolor=#F2F4F2>"
output_string = output_string+"<tr>"
output_string = output_string+"<td class='title'>Qty</td>"
output_string = output_string+"<td class='title'>Item</td>"
//output_string = output_string+"<td class='title'>Description</td>"
output_string = output_string+"<td class='title'>Weight</td>"
output_string = output_string+"<td class='title' align='right'>Price</td>"
output_string = output_string+"<td class='title'>&nbsp;<td></tr>"

if (eval(count_items)==0){
output_string = output_string+"<tr><td colspan=6 class=title >no items added to your shoping cart</td></tr>"
}else{
output_string = output_string+items_string
output_string = output_string+"<tr><td colspan=6>&nbsp;</td></tr>"
}
if (con =="oth"){
output_string = output_string+"<tr><td colspan=1 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Shipping fees cannot be calculated as your country is not listed</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}else{
if (con=="no"){
output_string = output_string+"<tr><td colspan=1 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Please log in to calculate your shipping fees</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}else{
tot = eval(tot)+eval(con)

if (tot_gewig>10){
output_string = output_string+"<tr><td colspan=1 class='cartbottom' align='right'>Note:</td>"
output_string = output_string+"<td colspan=3 class='cartbottom' align='right'><b>Orders over 10 kg attract an additional shipping fee, to be confirmed</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}
output_string = output_string+"<tr><td colspan=3 class='cartbottom' align='right'>Shipping fees:</td>"
output_string = output_string+"<td class='cartbottom' align='right'><b> "+formatCurrency(con)+"</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'></td></tr>"
}
}

output_string = output_string+"<tr><td colspan=3 class='cartbottom' align='right'>Sub-Total:</td>"
output_string = output_string+"<td class='cartbottom' align='right'><b> "+formatCurrency(tot)+"</b></td>"
output_string = output_string+"<td class='cartbottom' align='right'>including VAT</td></tr>"
output_string = output_string+"</table>"

output_string = output_string+"<br>"

if (eval(count_items)==0){
}else{
output_string = output_string+"<table width=630>"
output_string = output_string+"<tr class='subtitle'>"
output_string = output_string+"<td align='right' width=80><input type='button' value='Thank you for ordering please print this page for your records.' style='font-family:arial; font-size:9pt; background:#FFE098; border: thin solid #351B00 1pt' onclick=print() ></td></tr></table>"
}
output_string = output_string+"</form>"

output_string = output_string+"<p>&nbsp;</p>"

output_string = output_string+"</body>"
output_string = output_string+"</html>"
document.write(output_string)
document.close()

empty_all()

}

