function popup(url, width, height)
{
	var Win = window.open(url,"" ,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=auto,menubar=no');
	
	Win.focus();
}

function showWyevale()
{
	var x = document.getElementById("wyevaleList");
	var y = document.getElementById("wLink");
	
	if (x.style.display != "block")
	{
		x.style.display = "block";
		y.innerHTML = "Click here to hide all of Wyevale Resellers";
	}
	else
	{
		x.style.display = "none";
		y.innerHTML = "Click here to list all of Wyevale Resellers";
	}
}

function validateCompetitionForm()
{
	var myform = document.forms.contact_details;

	if (myform.answer.value == "")
	{
		alert ("You must enter your Answer before submitting this form.");
		myform.title.focus();
		return false;
	}

	if (myform.title.value == "")
	{
		alert ("You must enter your Title before submitting this form.");
		myform.title.focus();
		return false;
	}

	if (myform.forename.value == "")
	{
		alert ("You must enter your Forename(s) before submitting this form.");
		myform.forename.focus();
		return false;
	}

	if (myform.surname.value == "")
	{
		alert ("You must enter your Surname before submitting this form.");
		myform.surname.focus();
		return false;
	}

	if (myform.address1.value == "")
	{
		alert ("You must enter your Address before submitting this form.");
		myform.address1.focus();
		return false;
	}

	if (myform.town.value == "")
	{
		alert ("You must enter your Town before submitting this form.");
		myform.town.focus();
		return false;
	}

	if (myform.county.value == "")
	{
		alert ("You must enter your County before submitting this form.");
		myform.county.focus();
		return false;
	}

	if (myform.postcode.value == "")
	{
		alert ("You must enter your Postcode before submitting this form.");
		myform.postcode.focus();
		return false;
	}

	if (myform.tel.value == "")
	{
		alert ("You must enter your Telephone Number before submitting this form.");
		myform.tel.focus();
		return false;
	}

	if (myform.email.value > "")
	{
		if (myform.email.value.search(/^[\w\.-]+@{1}([\w-]+\.{1})+[a-z]{2,3}(a-z)?$/i) == -1)
		{
			alert ("Your Email address does not appear to be valid. \nPlease correct it before submitting this form.");
			myform.email.focus();
			return false;
		}
	}

	myform.submit;
}

function validateFeedbackForm()
{
	var myform = document.forms.feedback;

	if (myform.title.value == "")
	{
		alert ("You must enter your Title before submitting this form.");
		myform.title.focus();
		return false;
	}

	if (myform.forename.value == "")
	{
		alert ("You must enter your Forename(s) before submitting this form.");
		myform.forename.focus();
		return false;
	}

	if (myform.surname.value == "")
	{
		alert ("You must enter your Surname before submitting this form.");
		myform.surname.focus();
		return false;
	}

	if (myform.email.value == "")
	{
		alert ("You must enter your E-mail before submitting this form.");
		myform.email.focus();
		return false;
	}

	if (myform.email.value > "")
	{
		if (myform.email.value.search(/^[\w\.-]+@{1}([\w-]+\.{1})+[a-z]{2,3}(a-z)?$/i) == -1)
		{
			alert ("Your E-mail address does not appear to be valid. \nPlease correct it before submitting this form.");
			myform.email.focus();
			return false;
		}
	}

	myform.submit;
}


function validateCompetitionForm()
{
	var myform = document.forms.contact_details;

	if (myform.answer.value == "")
	{
		alert ("You must enter your Answer before submitting this form.");
		myform.title.focus();
		return false;
	}

	if (myform.title.value == "")
	{
		alert ("You must enter your Title before submitting this form.");
		myform.title.focus();
		return false;
	}

	if (myform.forename.value == "")
	{
		alert ("You must enter your Forename(s) before submitting this form.");
		myform.forename.focus();
		return false;
	}

	if (myform.surname.value == "")
	{
		alert ("You must enter your Surname before submitting this form.");
		myform.surname.focus();
		return false;
	}

	if (myform.address1.value == "")
	{
		alert ("You must enter your Address before submitting this form.");
		myform.address1.focus();
		return false;
	}

	if (myform.town.value == "")
	{
		alert ("You must enter your Town before submitting this form.");
		myform.town.focus();
		return false;
	}

	if (myform.county.value == "")
	{
		alert ("You must enter your County before submitting this form.");
		myform.county.focus();
		return false;
	}

	if (myform.postcode.value == "")
	{
		alert ("You must enter your Postcode before submitting this form.");
		myform.postcode.focus();
		return false;
	}

	if (myform.tel.value == "")
	{
		alert ("You must enter your Telephone Number before submitting this form.");
		myform.tel.focus();
		return false;
	}

	if (myform.email.value > "")
	{
		if (myform.email.value.search(/^[\w\.-]+@{1}([\w-]+\.{1})+[a-z]{2,3}(a-z)?$/i) == -1)
		{
			alert ("Your Email address does not appear to be valid. \nPlease correct it before submitting this form.");
			myform.email.focus();
			return false;
		}
	}

	myform.submit;
}

function validateADForm()
{
	var myform = document.forms.amenddetails;

	if (myform.pplTitle.value == "")
	{
		alert ("You must enter your Title before submitting this form.");
		myform.pplTitle.focus();
		return false;
	}

	if (myform.pplForeName.value == "")
	{
		alert ("You must enter your Forename(s) before submitting this form.");
		myform.pplForeName.focus();
		return false;
	}

	if (myform.pplSurName.value == "")
	{
		alert ("You must enter your Surname before submitting this form.");
		myform.pplSurName.focus();
		return false;
	}

	if (myform.pplAddress1.value == "")
	{
		alert ("You must enter your Address before submitting this form.");
		myform.pplAddress1.focus();
		return false;
	}

	if (myform.pplTown.value == "")
	{
		alert ("You must enter your Town before submitting this form.");
		myform.pplTown.focus();
		return false;
	}

	if (myform.pplCounty.value == "")
	{
		alert ("You must enter your County before submitting this form.");
		myform.pplCounty.focus();
		return false;
	}

	if (myform.pplPostcode.value == "")
	{
		alert ("You must enter your Postcode before submitting this form.");
		myform.pplpostcode.focus();
		return false;
	}

	if (myform.pplTelephone.value == "")
	{
		alert ("You must enter your Telephone Number before submitting this form.");
		myform.pplTelephone.focus();
		return false;
	}

	if (myform.pplEmail.value > "")
	{
		if (myform.email.value.search(/^[\w\.-]+@{1}([\w-]+\.{1})+[a-z]{2,3}(a-z)?$/i) == -1)
		{
			alert ("Your Email address does not appear to be valid. \nPlease correct it before submitting this form.");
			myform.ppl_Email.focus();
			return false;
		}
	}

	myform.submit;
}

function validateOrderFlyers()
{
	var myform = document.forms.order_flyers;

	if (myform.how_many.value == "")
	{
		alert ("You must selet how many flyers you would like");
		myform.how_many.focus();
		return false;
	}
	
	if (myform.how_many.value == 0)
	{
		if (myform.how_many_other.value == "" || myform.how_many_other.value == 0)
		{
			alert ("You have selected 'Other' but not said how many you would like.");
			myform.how_many_other.focus();
			return false;
		}
	}
	
	if (myform.how_many_other.value > 500)
	{
		alert ("I'm sorry but a maximum of 500 flyers can be ordered.");
		myform.how_many_other.focus();
		return false;
	}

	myform.submit;
}

function validateOrderCB()
{
	var myform = document.forms.order_cb;

	if (myform.how_many.value == "")
	{
		alert ("You must selet how many brochures you would like");
		myform.how_many.focus();
		return false;
	}
	
	if (myform.how_many.value == 0)
	{
		if (myform.how_many_other.value == "" || myform.how_many_other.value == 0)
		{
			alert ("You have selected 'Other' but not said how many you would like.");
			myform.how_many_other.focus();
			return false;
		}
	}
	
	if (myform.how_many_other.value > 500)
	{
		alert ("I'm sorry but a maximum of 500 flyers can be ordered.");
		myform.how_many_other.focus();
		return false;
	}

	myform.submit;
}

function validateBookTasting()
{
	var myform = document.forms.reseller_book_tasting;

	if (myform.rbt_Date.value == "")
	{
		alert ("You must enter the date of the tasting.");
		myform.rbt_Date.focus();
		return false;
	}
	
	if (myform.rbt_From.value == "")
	{
		alert ("You must enter the start time of the tasting.");
		myform.rbt_From.focus();
		return false;
	}

	if (myform.rbt_To.value == "")
	{
		alert ("You must enter the end time of the tasting.");
		myform.rbt_To.focus();
		return false;
	}

	myform.submit;
}

function ViewCart(nProduct, nCat)
{
	var sUrl = 'AddToCart.asp?';
	
	if (nProduct > 0)
		sUrl += 'ProductId=' + nProduct + '&';
	
	sUrl += 'cat=' + nCat;
	
	var newwindow = window.open(sUrl, 'theCart', 'scrollbars,titlebar,resizable,statusbar,height=875,width=750');
	newwindow.focus();
}

function ProcessFunctionATC(sFunction)
{
if (sFunction == 'Shop')
	{
	close();
	}
else
	{
	document.frmCart.Function.value = sFunction
	document.frmCart.submit();
	}
}

function ProcessFunctionCC(sFunction)
{
	document.frmCartCheck.Function.value = sFunction
	document.frmCartCheck.submit();
}

function ProcessFunctionL(sFunction)
{
	document.frmLogin.Function.value = sFunction
	document.frmLogin.submit();
}

function ProcessFunctionNC(sFunction)
{
	document.frmNameCheck.Function.value = sFunction
	document.frmNameCheck.submit();
}

function ProcessFunctionR(sFunction)
{
	document.frmRegister.Function.value = sFunction
	document.frmRegister.submit();
}

function ProcessFunctionFP(sFunction)
{
	document.frmForgot.Function.value = sFunction
	alert('You have been sent an email with your password details.');
}

function setupsize()
{
	window.moveTo(100,50);
	//window.resizeTo(675, 750);
}

function changeImage(imgname,changeto)
{
	document.getElementById(imgname).src = "images/" + changeto + ".jpg";
}