
function PopUp(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function ToggleItem(myItem) {
	if (myItem.style.visibility != 'hidden') {
		HideItem(myItem);
	} else {
		ShowItem(myItem);
	}
	return false;
}
function ShowItem(myItem) {
	myItem.style.visibility = 'visible';
	myItem.style.display = '';
}
function HideItem(myItem) {
	myItem.style.visibility = 'hidden';
	myItem.style.display = 'none';
}

function CheckPostCode(MyForm)
{
if(MyForm.PostCode.value=='')
	{
	alert("Please enter a Post Code");
	MyForm.PostCode.focus();
	return false;
	}
if(MyForm.PostCode.value.length<2)
	{
	alert("Please enter at least the first 2 characters of your Post Code");
	MyForm.PostCode.focus();
	return false;
	}	
}

function CheckMailing(MyForm)
{
if(MyForm.ProductNews.checked == false && MyForm.CompanyNews.checked == false && MyForm.SpecialOffers.checked == false)
	{
		alert("Please select at least one mailing list you are interesting in joining");
		return false;
	}
	
if(MyForm.MailingName.value=="")
	{
		alert("Please enter your Name");
		MyForm.MailingName.focus();
		return false;
	}
if(MyForm.MailingEmail.value=="")	
	{
		alert("Please enter your Email Address");
		MyForm.MailingEmail.focus();
		return false;		
	}

return checkEmail(MyForm.MailingEmail.value)
	
}

function CheckFindEmail(MyForm)
{
return checkEmail(MyForm.FindEmailAddress.value)
}


function checkEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
      alert('Please enter a valid email address');
      return false;
   }
}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function CheckSearchForm(MyForm)
{
	if(MyForm.strKeywords.value=="")
		{
			alert("Please enter a search term");
			MyForm.strKeywords.focus();
			return false;
		}
}


function ProcessContact(theForm) 
{
	Name=theForm.strContactName.value
	Address1=theForm.strContactAddress1.value
	Address2=theForm.strContactAddress2.value
	Postcode=theForm.strContactPostcode.value
	Email=theForm.strContactEmail.value
	//** Check the form
	if(Name=="")
	{
		alert("Please enter your Name");
		theForm.strContactName.focus();
		return false;
	}
	if(Name.length<5)
	{
		alert("Please enter at least 5 characters in the Name field");
		theForm.strContactName.focus();
		return false;
	}
	if(Email=="")
	{
		alert("Please enter your Email Address");
		theForm.strContactEmail.focus();
		return false;
	}
	return checkEmail(Email)
	if(Address1=="")
	{
		alert("Please enter the first line of your address");
		theForm.strContactAddress1.focus();
		return false;
	}
	if(Address1.length<5)
	{
		alert("Please at least 5 characters in the first line of your address");
		theForm.strContactAddress1.focus();
		return false;
	}	
	if(Address2=="")
	{
		alert("Please enter the second line of your address");
		theForm.strContactAddress2.focus();
		return false;
	}
	if(Address2.length<5)
	{
		alert("Please at least 5 characters in the second line of your address");
		theForm.strContactAddress2.focus();
		return false;
	}
		if(Postcode=="")
	{
		alert("Please enter your post code");
		theForm.strContactPotcode.focus();
		return false;
	}
	if(Address2.length<3)
	{
		alert("Please at least 3 characters in your post code");
		theForm.strContactPotcode.focus();
		return false;
	}
	
}

function CheckSpeedOrder(LineCount)
{
	for (var x = 1; x <= LineCount; x++)
	{
		GetProdCode=document.forms['speedorder'].elements['strCode'+x].value;
		GetQuant=document.forms['speedorder'].elements['numQuant'+x].value;
		if(GetProdCode!="" && GetQuant=="")
		{
			alert("Please enter a quantity for Product Code "+GetProdCode);

			document.forms['speedorder'].elements['numQuant'+x].focus()	
			return false
		}
		if(GetQuant!="" && GetProdCode=="")
		{
			alert("Please enter a Product Code on line " + x);
			document.forms['speedorder'].elements['strCode'+x].focus();
			return false
		}
	}
	// Now check to see if they've put anything in any of the fields - if not
	// don't submit the form
	blankCount = 0
	for (var x = 1; x <= LineCount; x++)
	{
		GetProdCode=document.forms['speedorder'].elements['strCode'+x].value;
		if(GetProdCode=="")
			{
				blankCount++
			}
	}		

		if(blankCount == LineCount)
		{
			alert("Please enter at least one product code");
			document.forms['speedorder'].elements['strCode1'].focus();
			return false;
		}
}

function CheckSpeedCSV(MyForm)
{
	if(MyForm.SpeedCSVFile.value=="")
		{
		alert("Please select a file to upload");
		return false;
		}
}
