function changePrice(selectBox)
{
	var priceDiv = document.getElementById('thePrice');
	
	var theVal = selectBox.value;
	
	var theSplit = theVal.split("_");
	
	var incVAT = getPriceIncVAT(theSplit[0]);
	
	priceDiv.innerHTML = '<span style="color: rgb(0, 102, 153);">'+incVAT+'</span><br /><span style="font-size: 11px;">(&pound;'+theSplit[0]+' exc. VAT)</span>';

	if(document.getElementById('stock_notice')){
		if(typeof(theSplit[2]) != "undefined" && theSplit[2] > 0){
			document.getElementById('stock_notice').innerHTML = 'In Stock Ready For Dispatch';
		}
		else{
			document.getElementById('stock_notice').innerHTML = 'Available for order';
		}
	}
}

function getPriceIncVAT(price)
{
	var theVAT = 20;
	
	var thePrice = eval(price);
	
	// add on the vat
	thePrice += (theVAT/100) * thePrice;
	
	thePrice = Math.round(thePrice*100)/100;
	
	thePrice = number_format(thePrice, 2, ".", "");
	
	return '<span>&pound;'+thePrice+'</span>';
}

function number_format(number, decimals, dec_point, thousands_sep) {
    // Formats a number with grouped thousands  
    number = (number+'').replace(',', '').replace(' ', '');
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }    return s.join(dec);
}

function confirm_delete()
{
	var r=confirm("Are you sure you would like to delete your shopping cart?");
	if (r==true)
	  {
	  	window.location = "cart.php?cd=1";
	  }

};

function show(id)
{
	var vars = new Array();
	vars.push(id);
	//if (typeof id2 !== "undefined") { vars.push(id2); }
	
	//for ( var i=0, len=vars.length; i<len; ++i ){
	
		el = document.getElementById(id);
		if (el.style.display == 'none')
		{
			if (id == "email") {
				document.frmRadio.by[0].checked = true;
				document.frmRadio.by[1].checked = false;
				//el2 = document.getElementById('phone');
				//el2.style.display = 'none';
			} else if (id == "phone") {
				document.frmRadio.by[0].checked = false;
				document.frmRadio.by[1].checked = true;
				//el2 = document.getElementById('email');
				//el2.style.display = 'none';
			}
			//el.style.display = '';
		} else {
			if (id == "email") {
				document.frmRadio.by[0].checked = true;
				document.frmRadio.by[1].checked = false;
				//el2 = document.getElementById('phone');
				//el2.style.display = 'none';
			} else if (id == "phone") {
				document.frmRadio.by[0].checked = false;
				document.frmRadio.by[1].checked = true;
				//el2 = document.getElementById('email');
				//el2.style.display = 'none';
			}
			//el.style.display = 'none';
		}
	//}
}
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
