	function VerifyColour(f)
	{
		
		if(f.colour.options[f.colour.selectedIndex].value == "")
		{
			alert("Please select a colour.")
			f.colour.focus();
			return false
		}
		
	}

	

	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('Incorrect email format. Please add "@".');
		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 RefineTopSearch(WkTS,WkUrl)
	{
		var LocationString = WkUrl + "?mk=" + escape(WkTS);

		document.location = LocationString ;
			
	}

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 ValidatePriceField(field)
{

   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;
	}
	
function UpdateDelivery(CostValue)
{
	location = 'https://www.westenddj.co.uk/basket/basket.asp?del=' + CostValue;
}

function SendOffProductPage(WhichForm,WhichPage)
	{
		if(WhichForm == '1')
		{
			document.ProductPageForm1.rec.value = document.ProductPageForm1.recNumber.value;
			document.ProductPageForm1.s.value = document.ProductPageForm1.SortOrder.value;
			document.ProductPageForm1.pg.value = WhichPage;
			
			document.ProductPageForm1.submit();
		}
		else
		{
			document.ProductPageForm2.rec.value = document.ProductPageForm2.recNumber.value;
			document.ProductPageForm2.s.value = document.ProductPageForm2.SortOrder.value;
			document.ProductPageForm2.pg.value = WhichPage;
			
			document.ProductPageForm2.submit();
		}
	}

function SendMultiple(WkDesc,WkQty,WkPrice)
{
		
		document.orderitem.MultipleDescription.value = WkDesc;
		document.orderitem.Multiple.value = WkQty;
		document.orderitem.price.value = WkPrice;
		document.orderitem.submit();	
		
}

	function openWindowCentered(mypage,myname,w,h,features) 
	{
		if(screen.width)
		{
			var winl = (screen.width-w)/2;
			var wint = (screen.height-h)/2;
		}
		else
		{	winl = 0;wint =0;	}
		
		if (winl < 0) winl = 0;
		if (wint < 0) wint = 0;
		var settings = 'height=' + h + ',';
		settings += 'width=' + w + ',';
		settings += 'top=' + wint + ',';
		settings += 'left=' + winl + ',';
		settings += features;
		win = window.open(mypage,myname,settings);
		win.window.focus();
}


function SwapImage(WkItem,WkImage) {

document.getElementById(WkItem).src = WkImage;

}


function validateMultiBuy(f) {

	var msg;
	var empty_fields = "";

	for(var i = 0; i < f.length; i++)
	{
		var e = f.elements[i];
		{
			if (e.alt == "y"){
				if ((e.value == null) || (e.value == ""))
				{
					empty_fields += "\n          " + e.title;
				}
				else if(e.name == "Multi_email")
				{
					var noAt = e.value.indexOf("@");

					if(noAt == -1) {
						empty_fields += '\n          Incorrect email format. "@" missing.';
					}
				}
				else
				{
					if(e.name == "Multi_postcode")
					{
						var noAt = e.value.indexOf(" ");

						if(noAt == -1) {
							empty_fields += '\n          Postcode requires a space, e.g. PE19 8ER.';
						}
					}
				}
			}
		}
		// Now, if there were errors, display a message, stating which fields are missing.
	}
	
	if(!empty_fields)
	{
		return true;
		f.submit();
	}
	
	msg = "____________________________________________\n\n"
	msg += "   Sorry, the following field(s) are required\n";
	msg += "   so we can contact you about our multi-buy\n";
	msg += "   offer:\n";
	msg += "___________________________________________\n"


	if (empty_fields)
	{
		msg += empty_fields + "\n";
	}
	
	alert(msg);
	return false;
}
