	function popup(URL,winwidth,winheight,doscroll)  {
		day = new Date();
		id = day.getTime();
		pleft=(screen.width-winwidth)/2;
		ptop=(screen.height-winheight)/2;
		eval("page" + id + " = window.open('"+URL+"', '" + id + "', 'toolbar=0,scrollbars='+doscroll+',location=0,statusbar=0,menubar=0,resizable=1,width="+winwidth+",height="+winheight+",left="+pleft+",top="+ptop+"');");
		}
	// trims a string	function trim(s)   {
		l=s.length;	b=0; x=0;
		while (x<l&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x++; }
		if (b==0) s="";  
		else { 
			b=0; s=s.substr(x-1); x=s.length-1;
			while(x>=0&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x--; }	
			s=s.substr(0,x+2);
			}
		return s;
		}
	function initialiseHTTPRequest()   {

		var xmlhttp=false;

		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
		xmlhttp = false;
		}
		}
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest();
			}
		
		return xmlhttp;
		}

	// checks save-to-cart from the accessories list	function checkaddtocart(theform)   {		var qty="", ID, make, cat_type;		qty=trim(theform.qty.value);
		if (qty=="") theform.qty.value="0";
		else  {
			num_test=Number(qty);
			if (isNaN(num_test)) { 
				alert("Value must be a number - please re-enter"); 
				theform.qty.value="0";
				theform.qty.focus();
				return false;
				}
			}		ID=theform.ID.value;
		make=theform.make.value;
		cat_type=theform.cat_type.value;
		itype=theform.itype.value;
		xmlhttp=initialiseHTTPRequest(); 
		xmlhttp.open("GET", "save_cart.asp?ID="+ID+"&make="+make+"&cat_type="+cat_type+"&qty="+qty+"&itype="+itype, true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				returnData=xmlhttp.responseText;
				}
			}
		xmlhttp.send(null);
		document.getElementById("cartaddedtext_"+ID).className="confirmaddcart";		return false;		}			// does amendment to existing cart item and checks for valid entry	function updateCart(ID, sessionID)  {		var qty="";		qty=trim(document.getElementById("qty_" + ID).value);
		if (qty=="") theform.qty.value="0";
		else  {
			num_test=Number(qty);
			if (isNaN(num_test)) { 
				alert("Value must be a number - please re-enter"); 
				theform.qty.value="0";
				theform.qty.focus();
				return false;
				}
			}
		// save to cart using AJAX
		xmlhttp1 = initialiseHTTPRequest(); 
		setCart(xmlhttp1, ID, qty);
		document.getElementById("cartaddedtext_"+ID).className="confirmaddcart";		// get the row total using AJAX
		xmlhttp2 = initialiseHTTPRequest(); 
		setCartRowTotal(xmlhttp2, sessionID, ID);

		// get bottom totals using AJAX
		xmlhttp3 = initialiseHTTPRequest(); 
		setCartTotalValue(xmlhttp3, sessionID, "subtotal", "stotal");
		xmlhttp4 = initialiseHTTPRequest(); 
		setCartTotalValue(xmlhttp4, sessionID, "postpack", "delcharge");
		xmlhttp5 = initialiseHTTPRequest(); 
		setCartTotalValue(xmlhttp5, sessionID, "posttotal", "ptotal");
		xmlhttp6 = initialiseHTTPRequest(); 
		setCartTotalValue(xmlhttp6, sessionID, "VAT", "vattotal");
		xmlhttp7 = initialiseHTTPRequest(); 
		setCartTotalValue(xmlhttp7, sessionID, "grandtotal", "gtotal");
		}	function setCart(xmlhttpB, ID, qty)   {
		xmlhttpB.open("GET", "save_cart.asp?ID="+ID+"&qty="+qty, true);
		xmlhttpB.onreadystatechange=function() {
			if (xmlhttpB.readyState==4) {
				returnData=xmlhttpB.responseText;
				}
			}
		xmlhttpB.send(null);
		}

	function setCartRowTotal(xmlhttp0, sessionID, ID)  {
		xmlhttp0.open("GET", "get_cart_row_total.asp?ID="+ID+"&sessionID="+sessionID, true);
		xmlhttp0.onreadystatechange=function() {
			if (xmlhttp0.readyState==4) {
				returnData=xmlhttp0.responseText;
				document.getElementById("totprice_"+ID).innerHTML = returnData;
				}
			}
		xmlhttp0.send(null);
		}

	function setCartTotalValue(xmlhttpA, sessionID, paramDB, paramcart)  {
		xmlhttpA.open("GET", "get_cart_totals_value.asp?sessionID="+sessionID+"&param="+paramDB, true);
		xmlhttpA.onreadystatechange=function() {
			if (xmlhttpA.readyState==4) {
				returnData=xmlhttpA.responseText;
				document.getElementById(paramcart).innerHTML = returnData;
				}
			}
		xmlhttpA.send(null);
		}	// empties shopping cart, after initial check	function emptyCart()  {		if (confirm("Are you sure you want to do this?"))  {			window.location="empty_cart.asp";			}			}	// check e-newsletter subscription	function checkNL(theform)   {		var msg="";
		if (trim(theform.firstname.value)=="") { msg="Your first name is missing...\n"; }
		if (trim(theform.surname.value)=="") { msg=msg+"Your surname is missing...\n"; }
		email=theform.email.value;
		if (email==""||((email.indexOf("@") == -1)||email.indexOf(".") == -1)) { msg=msg+"Your email address is either missing or in an invalid format...\n"; }
		if (msg!="")  {			msg=msg+"\nPlease supply the additional information";			alert(msg);			return false;			}		else  {
			theform.action="do_newsletter_subscribe.asp"
			return true;			}
		}