
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';
}

//#### PINDAR : KW : Validate Catalogue Request

function CatalogueRequest(theForm)
{
if ((theForm.Ckbox_Other.checked==true)&&(theForm.strOtherCat.value == ""))
{
 alert("You have selected 'Other' for your Catalogue choice.\n Please enter the title of your choice in the text box provided");
 theForm.strOtherCat.focus();
 return (false);
}
if ((theForm.Ckbox_ProductRange.checked ==false)&&(theForm.Ckbox_BestSellers.checked ==false)&&(theForm.Ckbox_Scales.checked ==false)&&(theForm.Ckbox_Education.checked ==false)&&(theForm.Ckbox_Other.checked ==false))
{
 alert("You have not selected a Catalogue, please select a Catalogue(s) from the list.");
 theForm.Ckbox_ProductRange.focus();
 return (false);
}

  // Validation script for field 'strContactName' (Name)
  if (theForm.strContactName.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.strContactName.focus();
    return (false);
  }

  if (theForm.strContactName.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Name\" field.");
    theForm.strContactName.focus();
    return (false);
  }

  if (theForm.strContactName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Name\" field.");
    theForm.strContactName.focus();
    return (false);
  }

  // Validation script for field 'strContactAddress1' (Address1)
  if (theForm.strContactAddress1.value == "")
  {
    alert("Please enter a value for the \"Address1\" field.");
    theForm.strContactAddress1.focus();
    return (false);
  }

  if (theForm.strContactAddress1.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Address1\" field.");
    theForm.strContactAddress1.focus();
    return (false);
  }

  if (theForm.strContactAddress1.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Address1\" field.");
    theForm.strContactAddress1.focus();
    return (false);
  }

  // Validation script for field 'strContactAddress2' (Address2)
  if (theForm.strContactAddress2.value == "")
  {
    alert("Please enter a value for the \"Address2\" field.");
    theForm.strContactAddress2.focus();
    return (false);
  }

  if (theForm.strContactAddress2.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Address2\" field.");
    theForm.strContactAddress2.focus();
    return (false);
  }

  if (theForm.strContactAddress2.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Address2\" field.");
    theForm.strContactAddress2.focus();
    return (false);
  }

  // Validation script for field 'strContactAddress3' (Address3)
  if (theForm.strContactAddress3.value == "")
  {
    alert("Please enter a value for the \"Address3\" field.");
    theForm.strContactAddress3.focus();
    return (false);
  }

  if (theForm.strContactAddress3.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Address3\" field.");
    theForm.strContactAddress3.focus();
    return (false);
  }

  if (theForm.strContactAddress3.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Address3\" field.");
    theForm.strContactAddress3.focus();
    return (false);
  }

  // Validation script for field 'strContactPostcode' (Postcode)
  if (theForm.strContactPostcode.value == "")
  {
    alert("Please enter a value for the \"Postcode\" field.");
    theForm.strContactPostcode.focus();
    return (false);
  }

  if (theForm.strContactPostcode.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Postcode\" field.");
    theForm.strContactPostcode.focus();
    return (false);
  }

  if (theForm.strContactPostcode.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Postcode\" field.");
    theForm.strContactPostcode.focus();
    return (false);
  }

  return (true);

}

function CheckPurchaseorder(TheForm)
{
	if (TheForm.O_PurchaseOrderNo.value=="")
	{
		alert("Please enter a Purchase Order Number");
		TheForm.O_PurchaseOrderNo.focus();
		return false;
	}
	return true;
}

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;
		}
return true;
}



/*************************************************
'#### PINDAR : KW : Added function to show
'#### PINDAR : KW : Hidden Messages on the
'#### PINDAR : KW : Checkout Page
*************************************************/

function ShowHiddenMessage(MessageDiv, TheForm)
{
	if(TheForm.C_ShippingCountry.value==4)
	{
		document.getElementById(MessageDiv).style.display = "";
	}
	else
	{
		document.getElementById(MessageDiv).style.display = "none";
	}
	
}