	function PostcodeLookup() {

		var PostString = document.ContactDetails.postcode.value
		var PostString = PostString.replace(" ","")
		
		document.location = 'basket.asp?step=2&pc=' + PostString + '&hn=' + document.ContactDetails.flat.value ;
	}

	function PostcodeLookup2(URL) {

		var pcLookup;
		var pcWinAddress = URL;
		
		pcWinAddress += pcWinAddress + '?postcode=' + document.ContactDetails.postcode.value
		pcWinAddress += pcWinAddress + '&flat=' + document.ContactDetails.flat.value
		
		pcLookup = window.open(pcWinAddress,'Address found','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=390,height=400,left = 337,top = 284');
	}

	function VerifyColour(f)
	{
		
		if(f.colour.options[f.colour.selectedIndex].value == "")
		{
			alert("Please select a colour.")
			f.colour.focus();
			return false
		}
		
	}

	function RefineSelection(WkFld,WkMk,WkC1,WkC2,WkC3,WkC4,WkC5,WkCol,WkPr,WkC0,WkRec,WkPg,WkSO,WkNO,WkCO,WkS)
	{
		var LocationString = "productlist.asp?";
		var tmpText;
		
		if(WkFld == "C0") {
			tmpText = document.Refiner.mk.options[document.Refiner.mk.selectedIndex].value;
			LocationString += "mk=" + tmpText; }
		else {
			LocationString += "mk=" + WkMk; }

		if(WkFld == "C1") {
			tmpText = document.Refiner.C1.options[document.Refiner.C1.selectedIndex].value;
			LocationString += "&C1=" + tmpText;}
		else {
			LocationString += "&C1=" + WkC1; }

		if(WkFld == "C2") {
			tmpText = document.Refiner.C2.options[document.Refiner.C2.selectedIndex].value;
			LocationString += "&C2=" + tmpText; }
		else {
			LocationString += "&C2=" + WkC2; }

		if(WkFld == "C3") {
			tmpText = document.Refiner.C3.options[document.Refiner.C3.selectedIndex].value;
			LocationString += "&C3=" + tmpText;}
		else {
			LocationString += "&C3=" + WkC3; }

		if(WkFld == "C4") {
			tmpText = document.Refiner.C4.options[document.Refiner.C4.selectedIndex].value;
			LocationString += "&C4=" + tmpText;}
		else {
			LocationString += "&C4=" + WkC4; }

		if(WkFld == "C5") {
			tmpText = document.Refiner.C5.options[document.Refiner.C5.selectedIndex].value;
			LocationString += "&C5=" + tmpText;}
		else {
			LocationString += "&C5=" + WkC5; }

		if(WkFld == "C6") {
			tmpText = document.Refiner.Col.options[document.Refiner.Col.selectedIndex].value;
			LocationString += "&C6=" + tmpText; }
		else {
			LocationString += "&C6=" + WkCol; }

		if(WkFld == "C7") {
			tmpText = document.Refiner.pr.options[document.Refiner.pr.selectedIndex].value;
			LocationString += "&C7=" + tmpText; }
		else {
			LocationString += "&C7=" + WkPr; }

		if(WkFld == "C8") {
			tmpText = document.Refiner.C0.options[document.Refiner.C0.selectedIndex].value;
			LocationString += "&C8=" + tmpText; }
		else {
			LocationString += "&C8=" + WkC0; }
			
		if(WkRec != "") {
			LocationString += "&rec=" + WkRec }
		else {
			LocationString += "&rec=" }
		
		if(WkPg != "") {
			LocationString += "&pg=" + WkPg }
		else {
			LocationString += "&pg=" }
		
		if(WkSO != "") {
			LocationString += "&so=" + WkSO }
		else {
			LocationString += "&so=" }
		
		if(WkNO != "") {
			LocationString += "&no=" + WkNO }
		else {
			LocationString += "&no=" }
		
		if(WkCO != "") {
			LocationString += "&co=" + WkCO }
		else {
			LocationString += "&co=" }
		
		if(WkS != "") {
			LocationString += "&s=" + WkS }
		else {
			LocationString += "&s=" }
		
		document.location = LocationString ;
			
	}


	function QuickSearch(WkValue)
	{
		document.location = "productlist.asp?q=" + WkValue;
			
	}

	function SetMaxRecords    (WkFld,WkMk,WkC1,WkC2,WkC3,WkC4,WkC5,WkCol,WkPr,WkC0,WkRec,WkPg,WkSO,WkNO,WkCO,WkS)
	{
		document.location = "productlist.asp?C0=" + WkMk + "&C1=" + WkC1 + "&C2=" + WkC2 + "&C3=" + WkC3 +  "&C4=" + WkC4 +  "&C5=" + WkC5 + "&C6=" + WkCol + "&C7=" + WkPr + "&C8=" + WkC0 + "&rec=" + WkFld + "&pg=" + WkPg + "&so=" + WkSO + "&no=" + WkNO + "&co=" + WkCO + "&s=" + WkS ;
	}

	function SetOrder    (WkFld,WkMk,WkC1,WkC2,WkC3,WkC4,WkC5,WkCol,WkPr,WkC0,WkRec,WkPg,WkSO,WkNO,WkCO,WkS)
	{
		document.location = "productlist.asp?C0=" + WkMk + "&C1=" + WkC1 + "&C2=" + WkC2 + "&C3=" + WkC3 +  "&C4=" + WkC4 +  "&C5=" + WkC5 + "&C6=" + WkCol + "&C7=" + WkPr + "&C8=" + WkC0 + "&rec=" + WkRec + "&pg=" + WkPg + "&so=" + WkSO + "&no=" + WkNO + "&co=" + WkCO + "&s=" + WkFld ;
	}
	
	function SetFromTopForm()
	{
		var LocationString = "productlist.asp?" ;
		
		if(document.TopSearchForm.mk.options[document.TopSearchForm.mk.selectedIndex].value != "") {
			LocationString += "mk=" + document.TopSearchForm.mk.options[document.TopSearchForm.mk.selectedIndex].value; }
		else {
			LocationString += "mk="; }

		if(document.TopSearchForm.C1.options[document.TopSearchForm.C1.selectedIndex].value != "") {
			LocationString += "&C1=" + document.TopSearchForm.C1.options[document.TopSearchForm.C1.selectedIndex].value; }
		else {
			LocationString += "&C1="; }

		if(document.TopSearchForm.C2.options[document.TopSearchForm.C2.selectedIndex].value != "") {
			var tmpC2 = document.TopSearchForm.C2.options[document.TopSearchForm.C2.selectedIndex].value;
			var tmpC = tmpC2.split(";");
		
			if(tmpC[0] == "g1") {
				LocationString += "&C1=" + tmpC[1]; }
			else {
				LocationString += "&C2=" + tmpC[1]; } }
		else {
			LocationString += "&C2=" }

		document.location = LocationString;
	}

	function JumpToMake(WkEntry)

	{
		document.SearchForm.m.value = WkEntry;
		document.SearchForm.s.value = '<%= Request("s") %>';
		document.SearchForm.submit();	
	}

	function ChangeOrder(WkEntry)
	{
		document.SearchForm.s.value = WkEntry;
		document.SearchForm.m.value = '<%= Request("m") %>';
		document.SearchForm.submit();	
	}


function remove(index)
	{
		today = new Date();
		locstr = "add.asp?action=remove&time=" + today.getTime() + "&index="+index;
		document.location.replace(locstr);
	}

	function loadImages() {
		if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('hidepage').style.visibility = 'hidden';
		}
		else {
		if (document.layers) {  // Netscape 4
		document.hidepage.visibility = 'hidden';
		}
		else {  // IE 4
		document.all.hidepage.style.visibility = 'hidden';
		}
	   }
	}

function GetDetails(WkEntry1, WkEntry2)
	{
		document.SearchForm.rec.value = WkEntry1;
		document.SearchForm.action = 'productdetail.asp';
		document.SearchForm.submit();	
	}

function quickVal()
{
	if(document.quickSearch.searchFor.value == "")
	{
		alert("Please enter search criteria.")
		document.quickSearch.searchFor.focus();
		return false
	}
	
	return true
}

	function verify(f)
	{
		var msg;
		var empty_fields = "";
		
		if (document.ContactDetails.PostcodeLookup.value == "" && document.ContactDetails.HouseNo.value == "")
		{
			// Loop through the elements of the form, looking for all
			// text and textarea elements and if they are empty.
			for(var i = 0; i < f.length; i++)
			{
				var e = f.elements[i];
				{
					if (e.alt == "y")
	//				if ((e.name == "name") || (e.name == "position") || (e.name == "tradingname")
				//		  || (e.name == "productmaintaining") || (e.name == "workshop"))
					{
						if ((e.value == null) || (e.value == ""))
						{
							empty_fields += "\n          " + e.title;
						}
					}
				}
			}
	
			// Now, if there were errors, display a message, stating which fields are missing.
	
			if(!empty_fields)
			{
				return true;
				document.ContactDetails.submit();
			}
			
			msg = "____________________________________________\n\n"
			msg += "   The form was not submitted, because the following\n";
			msg += "   field(s) are required:\n";
			msg += "___________________________________________\n"
		
		
			if (empty_fields)
			{
				msg += empty_fields + "\n";
			}
			
			alert(msg);
			return false;
		}
	}
	
	function CheckEmail(e)
	{
		var noAt = e.indexOf("@");
		
		// Now, if there were errors, display a message, stating which fields are missing.

		if(noAt != -1) return true;
		
		alert('Please check your email: It must contain "@".');
		return false;
	}

	function CheckPostCode(e)
	{
		var gotSpace = e.indexOf(" ");
		
		// Now, if there were errors, display a message, stating which fields are missing.

		if(gotSpace != -1) return true;
		
		alert('Incorrect postcode. Please add a space.');
		return false;
	}

	function verifyCard(f)
	{
		var msg;
		var empty_fields = "";
		
		// Loop through the elements of the form, looking for all
		// text and textarea elements and if they are empty.
		for(var i = 0; i < f.length; i++)
		{
			var e = f.elements[i];
			{
				if ((e.name == "CardNumber") || (e.name == "CardSecurityCode"))
				{
					if ((e.value == null) || (e.value == ""))
					{
						empty_fields += "\n          " + e.title;
					}
				}
				else if (e.name == "CardEndMonth")
				{
					if (f.CardEndMonth.options[f.CardEndMonth.selectedIndex].value == '-')
					{
						empty_fields += "\n          " + e.title;
					}
				}
				else if  (e.name == "CardEndYear")
				{
					if (f.CardEndYear.options[f.CardEndYear.selectedIndex].value == '-')
					{
						empty_fields += "\n          " + e.title;
					}
				}
			}
		}

		// Now, if there were errors, display a message, stating which fields are missing.

		if(!empty_fields) return true;
		
		msg = "____________________________________________\n\n"
		msg += "   The form was not submitted, because the following\n";
		msg += "   field(s) are required:\n";
		msg += "___________________________________________\n"
	
	
		if (empty_fields)
		{
			msg += empty_fields + "\n";
		}
		
		alert(msg);
		return false;
	}

function ValidateOpenAccount(f)
{
	var errorFields = "";

	for(var i = 0; i < f.length; i++)
	{
		var e = f.elements[i];
		{
			if (e.alt == "y")
			{
				if ((e.value == null) || (e.value == "") || (e.value == 0))
				{
					errorFields += "\n          " + e.title;
				}
			}
		}
	}
	
	if((errorFields == null) || (errorFields == ""))
	{
			return true;
	}
	else
	{
			DisplayErrorMessage(errorFields,f);
			return false;
	}
}

function EmptyField()
	{
	if (document.KeywordSearch.C0.value == "Keyword search")
		document.KeywordSearch.C0.value = "";
	}

function FillField()
	{
	if (document.KeywordSearch.C0.value == "")
		document.KeywordSearch.C0.value = "Keyword search";
	}

	function DisplayErrorMessage(empty_fields,f)
	{
		var msg;
		
		// Now, if there were errors, display a message, stating which fields are missing.
	
		if(!empty_fields)
		{
			return true;
			document.f.submit();
		}
		
		msg = "____________________________________________\n\n"
		msg += "   The form was not submitted, because the following\n";
		msg += "   field(s) are required:\n";
		msg += "___________________________________________\n"
	
	
		if (empty_fields)
		{
			msg += empty_fields + "\n";
		}
		
		alert(msg);
		return false;
	
	}

function ValidateQuantity(field)
{
   if(IsEmpty(field)) 
   { 
      alert('Please enter a quantity.') 
      field.focus(); 
      return false; 
   } 
 
 
   if (!IsNumeric(field.value)) 
   { 
      alert('Only numbers are allowed for this field.') 
      field.focus(); 
      return false; 
      } 
 
return true;
 
} 

function IsEmpty(aTextField)
{
   if ((aTextField.value.length==0) || (aTextField.value==null))
   {
    	return true;
   }
   else
   {
   	return false;
	}
}	

function IsNumeric(TxtFld)
	{
		var ValidChars = "0123456789";
	   	var IsNumber=true;
   		var Char;

 		for (i = 0; i < TxtFld.length && IsNumber == true; i++) 
      	{ 
			Char = TxtFld.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
         	{
         		IsNumber = false;
         	}
      	}
		return IsNumber;
	}
	
