// JavaScript Document

function buy(id){
	window.location.href="basket.php?buy="+id	
}


function clearlogin(){
	document.form1.nextaction.value="exit"
	document.form1.submit()	
}


function currencyToValue(pounds){
	pounds=" " + pounds;
	valstr="";
	for(i=0; i<pounds.length; i++){
		c=pounds.charAt(i)
		if(c!=" "){
			if(!isNaN(c)||c=="."){
				valstr+=c
			}
		}
	}
	pounds=valstr
	return pounds
}


function email(a,b){
	document.location = "mailto:" + a + "\x40" + b;
}

function email2(addr){
	//addr is the address with a @ sign replaced by an image
	//find the first <
	str=addr.innerHTML
	//alert (str)
	bit=str.split(/[<>]/)
	a=bit[0]
	b=bit[2]
	document.location = "mailto:" + a + "\x40" + b;
}



function valueToCurrency(val, dponly){ //dponly doesn't give the pounds sign
	//debugger
	valstr=" " + val
	vallength=valstr.length
	p="&pound;"
	if(dponly){
		p="";
	}
	
	if(vallength==1){
		return p+"0.00"
	}
	//if (vallength==2 || vallength==3){
	//	 return p+val+".00"
	//}
	pennies=Math.round(val*100)
	strpennies=" " + pennies
	penlength=strpennies.length
	if (penlength==2){
		return p + "0.0" + strpennies.slice(-1)
	}
	if (penlength==3){
		return p + "0." + strpennies.slice(-2)
	}	
			
	pounds=strpennies.slice(1,penlength-2)
	pence=strpennies.slice(-2)
	return p + pounds + "." + pence
}	