function update_basket()
{
	document.frm_basket.submit();
}

function continue_order()
{
	//validates the order form and sends if all is ok
	var frm = document.frm_step1;
	var bln_err = false;
	var err_msg = 'Please complete the following fields:\n\n';
//NJM:::
/*
	if(frm.first_name.value == '')
	{
		bln_err = true;
		err_msg+= '* Forename\n';
	}
	if(frm.last_name.value == '')
	{
		bln_err = true;
		err_msg+= '* Surname\n';
	}
	if(frm.email.value == '')
	{
		bln_err = true;
		err_msg+= '* Email address\n';
	}
	if(frm.tel.value == '')
	{
		bln_err = true;
		err_msg+= '* Daytime contact number\n';
	}
	if(frm.address1.value == '')
	{
		bln_err = true;
		err_msg+= '* Street\n';
	}
	if(frm.city.value == '')
	{
		bln_err = true;
		err_msg+= '* Town\n';
	}
	if(frm.state.value == '')
	{
		bln_err = true;
		err_msg+= '* County\n';
	}

	if(frm.zip.value == '')
	{
		bln_err = true;
		err_msg+= '* Postcode\n';
	}

	if(bln_err == true)
	{
		alert(err_msg);
	}
	else
	{
		frm.action = 'complete_order_step2.php';
		frm.submit();
	}
	*/
//NJM:::
frm.action = 'complete_order_step2.php';
frm.submit();
/***********/
}

function complete_order()
{
	var frm = document.frm_sendorder;
	frm.action="https://www.paypal.com/cgi-bin/webscr";
	frm.submit();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkPostCode () 
{
  // This array holds the regular expressions for the valid postcodes
  var pcexp = new Array ();

  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
  pcexp.push (/^([a-z]{1,2}[0-9]{1,2})(\s*)([0-9]{1}[abdefghijlnpqrstuwxyx][a-z])$/i);
  // Expression for postcodes: ANA NAA, and AANA  NAA
  pcexp.push (/^([a-z]{1,2}[0-9]{1}[a-z]{1})(\s*)([0-9]{1}[abdefghijlnpqrstuwxyx][a-z])$/i);
  // Exception for the special postcode GIR 0AA
  pcexp.push (/^(GIR)(\s*)(0AA)$/i);

  // Load up the string to check
  var postCode = document.frm_postcode.postcode.value;

  // Assume we're not going to find a valid postcode
  var valid = false;
  
  // Check the string against both post codes
  for (i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {
    
      // The post code is valid - split the post code into component parts
      pcexp[i].exec(postCode);
      
      // Copy it back into the original string, converting it to uppercase and
      // inserting a space between the inward and outward codes
      
      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
      
      // Load new postcode back into the form element
      valid = true;
      
      // Remember that we have found that the code is valid and break from loop

      break;
    }
  }
  
  // Return with either the reformatted valid postcode or the original invalid 
  // postcode
  if (valid) {return postCode;} else return false;
}

function test_code () 
{
	var frm = document.frm_postcode;

	if (checkPostCode ()) 
	{
		frm.postcode.value=checkPostCode ()
		frm.action = 'getmileage.php';
		frm.submit();
	} 
	else 
	{
		alert('You have entered an invalid postcode');
	}
}

function checkPostalCode(postCode) 
{
  // This array holds the regular expressions for the valid postcodes
  var pcexp = new Array ();

  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
  pcexp.push (/^([a-z]{1,2}[0-9]{1,2})(\s*)([0-9]{1}[abdefghijlnpqrstuwxyx][a-z])$/i);
  // Expression for postcodes: ANA NAA, and AANA  NAA
  pcexp.push (/^([a-z]{1,2}[0-9]{1}[a-z]{1})(\s*)([0-9]{1}[abdefghijlnpqrstuwxyx][a-z])$/i);
  // Exception for the special postcode GIR 0AA
  pcexp.push (/^(GIR)(\s*)(0AA)$/i);



  // Assume we're not going to find a valid postcode
  var valid = false;
  
  // Check the string against both post codes
  for (i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {
    
      // The post code is valid - split the post code into component parts
      pcexp[i].exec(postCode);
      
      // Copy it back into the original string, converting it to uppercase and
      // inserting a space between the inward and outward codes
      
      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
      
      // Load new postcode back into the form element
      valid = true;
      
      // Remember that we have found that the code is valid and break from loop

      break;
    }
  }
  
  // Return with either the reformatted valid postcode or the original invalid 
  // postcode
  if (valid) {return true;} else return false;
}