function openPictureWindow(imageName, sessionData, imageWidth, imageHeight, alt, posLeft, posTop) 
{  
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	
	newWindow.document.write('<img src=\"'+imageName+''+sessionData+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	

	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function Navigate(szURL)
{
    window.location.href = szURL;
}

function EnableDeliveryAddress(check, form)
{
	boChecked = check.checked;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 8) == "Delivery")
		{
			form.elements[i].disabled = boChecked;
			form.elements[i].style.backgroundColor="";
		}
	}
}

function ValidateForm_EditDetails(form)
{
	boErrorFound = false;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name == "submit")
		{
			submitButtonIndex = i;
		}

		if (form.elements[i].name.substring(0, 8) == "Password")
		{
			szFirstPassword = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 14) == "VerifyPassword")
		{
			szSecondPassword = form.elements[i].value;
		}

		if (form.elements[i].name.substring(0, 12) == "EmailAddress")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}
	else
	{
		form.elements[submitButtonIndex].disabled = true;
	}

	return (!boErrorFound);	
}

function copyMailingAddress(form)
{
	szCustomerFirstName = "";
	szCustomerLastName = "";
	szCustomerAddressLine1 = "";
	szCustomerAddressLine2 = "";
	szCustomerAddressLine3 = "";
	szCustomerAddressLine4 = "";
	szCustomerPostCode = "";
	szCustomerCity = "";
	szCustomerCountry = "";

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 8) == "Address1")
		{												
			szCustomerAddressLine1 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 8) == "Address2")
		{												
			szCustomerAddressLine2 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 8) == "Address3")
		{												
			szCustomerAddressLine3 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 8) == "Address4")
		{												
			szCustomerAddressLine4 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 8) == "PostCode")
		{												
			szCustomerPostCode = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 4) == "City")
		{												
			szCustomerCity = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 7) == "Country")
		{												
			szCustomerCountry = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 5) == "State")
		{												
			szCustomerState = form.elements[i].value;
		}
	}

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 15) == "BillingAddress1")
		{												
			form.elements[i].value = szCustomerAddressLine1;
		}
		if (form.elements[i].name.substring(0, 15) == "BillingAddress2")
		{												
			form.elements[i].value = szCustomerAddressLine2;
		}
		if (form.elements[i].name.substring(0, 15) == "BillingAddress3")
		{												
			form.elements[i].value = szCustomerAddressLine3;
		}
		if (form.elements[i].name.substring(0, 15) == "BillingAddress4")
		{												
			form.elements[i].value = szCustomerAddressLine4;
		}
		if (form.elements[i].name.substring(0, 15) == "BillingPostCode")
		{												
			form.elements[i].value = szCustomerPostCode;
		}
		if (form.elements[i].name.substring(0, 11) == "BillingCity")
		{												
			form.elements[i].value = szCustomerCity;
		}
		if (form.elements[i].name.substring(0, 14) == "BillingCountry")
		{												
			form.elements[i].value = szCustomerCountry;
		}
		if (form.elements[i].name.substring(0, 12) == "BillingState")
		{												
			form.elements[i].value = szCustomerState;
		}
	}
}

function ValidateForm_Renew(form)
{
	boErrorFound = false;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name == "submit")
		{
			submitButtonIndex = i;
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}
	else
	{
		form.elements[submitButtonIndex].disabled = true;
	}

	return (!boErrorFound);	
}


function ValidateForm_Subscribe(form)
{
	boErrorFound = false;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name == "submit")
		{
			submitButtonIndex = i;
		}

		if (form.elements[i].name.substring(0, 8) == "Password")
		{
			szFirstPassword = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 14) == "VerifyPassword")
		{
			szSecondPassword = form.elements[i].value;
		}

		if (form.elements[i].name.substring(0, 12) == "EmailAddress")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}
	else
	{
		form.elements[submitButtonIndex].disabled = true;
	}

	return (!boErrorFound);	
}


function CopyDeliveryAddress(form)
{
	szCustomerFirstName = "";
	szCustomerLastName = "";
	szCustomerAddressLine1 = "";
	szCustomerAddressLine2 = "";
	szCustomerAddressLine3 = "";
	szCustomerAddressLine4 = "";
	szCustomerPostCode = "";
	szCustomerCity = "";
	szCustomerCountry = "";

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 17) == "CustomerFirstName")
		{												
			szCustomerFirstName = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 16) == "CustomerLastName")
		{												
			szCustomerLastName = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 20) == "CustomerAddressLine1")
		{												
			szCustomerAddressLine1 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 20) == "CustomerAddressLine2")
		{												
			szCustomerAddressLine2 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 20) == "CustomerAddressLine3")
		{												
			szCustomerAddressLine3 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 20) == "CustomerAddressLine4")
		{												
			szCustomerAddressLine4 = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 16) == "CustomerPostCode")
		{												
			szCustomerPostCode = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 12) == "CustomerCity")
		{												
			szCustomerCity = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 15) == "CustomerCountry")
		{												
			szCustomerCountry = form.elements[i].value;
		}
	}

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 20) == "DeliveryAddressLine1")
		{												
			form.elements[i].value = szCustomerAddressLine1;
		}
		if (form.elements[i].name.substring(0, 20) == "DeliveryAddressLine2")
		{												
			form.elements[i].value = szCustomerAddressLine2;
		}
		if (form.elements[i].name.substring(0, 20) == "DeliveryAddressLine3")
		{												
			form.elements[i].value = szCustomerAddressLine3;
		}
		if (form.elements[i].name.substring(0, 20) == "DeliveryAddressLine4")
		{												
			form.elements[i].value = szCustomerAddressLine4;
		}
		if (form.elements[i].name.substring(0, 16) == "DeliveryPostCode")
		{												
			form.elements[i].value = szCustomerPostCode;
		}
		if (form.elements[i].name.substring(0, 12) == "DeliveryCity")
		{												
			form.elements[i].value = szCustomerCity;
		}
		if (form.elements[i].name.substring(0, 15) == "DeliveryCountry")
		{												
			form.elements[i].value = szCustomerCountry;
		}
	}
}

function IsEmailValid(szAddress) 
{
	boAddressIsValid = false;
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	
	if (re.test(szAddress))
	{
		boAddressIsValid = true;	
	}

	return(boAddressIsValid);
}

function ValidateForm(form)
{
	boErrorFound = false;
	boFirstEmailValid = false;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 16) == "CustomerPassword")
		{
			szFirstPassword = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 22) == "CustomerVerifyPassword")
		{
			szSecondPassword = form.elements[i].value;
		}
		
		if (form.elements[i].name.substring(0, 13) == "CustomerEmail")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}
		if (form.elements[i].name.substring(0, 19) == "CustomerVerifyEmail")
		{
			szSecondEmail = form.elements[i].value;
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	if (szFirstEmail != szSecondEmail)
	{
		alert("The email addresses you have entered do not match");
		boErrorFound = true;
	}

	return (!boErrorFound);	
}

function clickOnSize(szSizeCode)
{

	boFoundCurrentColour = false;
	boNeedToSelectAnotherColour = false;
	boFoundValidColour = false;

	for (nCount=0; nCount < document.addProduct.length && !boFoundCurrentColour; nCount++)
	{
		if (document.addProduct.elements[nCount].name == "productColour" &&
			document.addProduct.elements[nCount].checked == true)
		{
			szCurrentColour = document.addProduct.elements[nCount].value;
			nCurrentColourIndex = nCount;
			boFoundCurrentColour = true;
		}
	}

	if (!boFoundCurrentColour)
	{
		alert("DEBUG: couldn't find current colour");	
	}
	else
	{
		szWorkingString = szSizeCode; 

		nIndexOfSizeDelimiter = szWorkingString.indexOf("^");

		if (nIndexOfSizeDelimiter != -1)
		{
			szSizeString = szWorkingString.substring(0, nIndexOfSizeDelimiter);

			boStop = false;
			nCurrentIndex = nIndexOfSizeDelimiter + 1;

			while (!boStop)
			{
				boFoundFirst = false;
				boFoundSecond = false;

				nCurrentIndex2 = szWorkingString.indexOf("%", nCurrentIndex);
				
				if (nCurrentIndex2 != -1)
				{
					boFoundFirst = true;
					szColourString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
					nCurrentIndex = nCurrentIndex2 + 1;

					nCurrentIndex2 = szWorkingString.indexOf("^", nCurrentIndex);
					
					if (nCurrentIndex2 != -1)
					{
						boFoundSecond = true;
						szQuantityString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
						nCurrentIndex = nCurrentIndex2 + 1;
					}
				}
				if (!boFoundFirst ||
					!boFoundSecond)
				{
					boStop = true;
				}
				else
				{
					if (szQuantityString <= 0)
					{
						szTempstring = "COLOUR_" + szColourString;
						ColourControl = document.getElementById(szTempstring);
						ColourControl.style.display="none";

						if (szCurrentColour == szColourString)
						{
							document.addProduct.elements[nCurrentColourIndex].checked = false;
							boNeedToSelectAnotherColour = true;
						}
					}
					else
					{
						if (!boFoundValidColour)
						{
							szValidColour = szColourString;
							boFoundValidColour = true;
						}
						szTempstring = "COLOUR_" + szColourString;
						ColourControl = document.getElementById(szTempstring);
						ColourControl.style.display="";
					}	
				}
			}
			if (boNeedToSelectAnotherColour)
			{
				if (!boFoundValidColour)
				{
					alert("DEBUG: couldn't find another valid colour!");
				}
				else
				{
					boFoundCurrentColour = false;

					for (nCount=0; nCount < document.addProduct.length && !boFoundCurrentColour; nCount++)
					{
						if (document.addProduct.elements[nCount].name == "productColour" &&
							document.addProduct.elements[nCount].value == szValidColour)
						{
							document.addProduct.elements[nCount].checked = true;
							szCurrentColour = szValidColour;
							boFoundCurrentColour = true;
						}
					}
				}
			}
		}

		boStop = false;
		nCurrentIndex = nIndexOfSizeDelimiter + 1;

		while (!boStop)
		{
			boFoundFirst = false;
			boFoundSecond = false;
			nCurrentIndex2 = szWorkingString.indexOf("%", nCurrentIndex);
			
			if (nCurrentIndex2 != -1)
			{
				boFoundFirst = true;
				szColourString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
				nCurrentIndex = nCurrentIndex2 + 1;

				nCurrentIndex2 = szWorkingString.indexOf("^", nCurrentIndex);
				
				if (nCurrentIndex2 != -1)
				{
					boFoundSecond = true;
					szQuantityString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
					nCurrentIndex = nCurrentIndex2 + 1;
				}
			}
			if (!boFoundFirst ||
				!boFoundSecond)
			{
				boStop = true;
			}
			else
			{	
				if (szColourString == szCurrentColour)
				{
					boStop = true;
					UpdateQuantity(szQuantityString);
				}
			}
		}
	}
}

function clickOnColour(szColourCode)
{
	boFoundCurrentSize = false;
	boNeedToSelectAnotherSize = false;
	boFoundValidSize = false;

	for (nCount=0; nCount < document.addProduct.length && !boFoundCurrentSize; nCount++)
	{
		if (document.addProduct.elements[nCount].name == "productSize" &&
			document.addProduct.elements[nCount].checked == true)
		{
			szCurrentSize = document.addProduct.elements[nCount].value;
			nCurrentSizeIndex = nCount;
			boFoundCurrentSize = true;
		}
	}

	if (!boFoundCurrentSize)
	{
		alert("DEBUG: couldn't find current size");	
	}
	else
	{
		szWorkingString = szColourCode; 

		nIndexOfColourDelimiter = szWorkingString.indexOf("^");

		if (nIndexOfColourDelimiter != -1)
		{
			szColourString = szWorkingString.substring(0, nIndexOfColourDelimiter);

			boStop = false;
			nCurrentIndex = nIndexOfColourDelimiter + 1;

			while (!boStop)
			{
				boFoundFirst = false;
				boFoundSecond = false;

				nCurrentIndex2 = szWorkingString.indexOf("%", nCurrentIndex);
				
				if (nCurrentIndex2 != -1)
				{
					boFoundFirst = true;
					szSizeString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
					nCurrentIndex = nCurrentIndex2 + 1;

					nCurrentIndex2 = szWorkingString.indexOf("^", nCurrentIndex);
					
					if (nCurrentIndex2 != -1)
					{
						boFoundSecond = true;
						szQuantityString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
						nCurrentIndex = nCurrentIndex2 + 1;
					}
				}
				if (!boFoundFirst ||
					!boFoundSecond)
				{
					boStop = true;
				}
				else
				{
					if (szQuantityString <= 0)
					{
						szTempstring = "SIZE_" + szSizeString;
						SizeControl = document.getElementById(szTempstring);
						SizeControl.style.display="none";

						if (szCurrentSize == szSizeString)
						{
							document.addProduct.elements[nCurrentSizeIndex].checked = false;
							boNeedToSelectAnotherSize = true;
						}
					}
					else
					{
						if (!boFoundValidSize)
						{
							szValidSize = szSizeString;
							boFoundValidSize = true;
						}
						szTempstring = "SIZE_" + szSizeString;
						SizeControl = document.getElementById(szTempstring);
						SizeControl.style.display="";
					}	
				}
			}
			if (boNeedToSelectAnotherSize)
			{
				if (!boFoundValidSize)
				{
					alert("DEBUG: couldn't find another valid size!");
				}
				else
				{
					boFoundCurrentSize = false;

					for (nCount=0; nCount < document.addProduct.length && !boFoundCurrentSize; nCount++)
					{
						if (document.addProduct.elements[nCount].name == "productSize" &&
							document.addProduct.elements[nCount].value == szValidSize)
						{
							document.addProduct.elements[nCount].checked = true;
							boFoundCurrentSize = true;
						}
					}
				}
			}
		}
		
		boStop = false;
		nCurrentIndex = nIndexOfColourDelimiter + 1;

		while (!boStop)
		{
			boFoundFirst = false;
			boFoundSecond = false;

			nCurrentIndex2 = szWorkingString.indexOf("%", nCurrentIndex);
			
			if (nCurrentIndex2 != -1)
			{
				boFoundFirst = true;
				szSizeString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
				nCurrentIndex = nCurrentIndex2 + 1;

				nCurrentIndex2 = szWorkingString.indexOf("^", nCurrentIndex);
				
				if (nCurrentIndex2 != -1)
				{
					boFoundSecond = true;
					szQuantityString = szWorkingString.substring(nCurrentIndex, nCurrentIndex2);
					nCurrentIndex = nCurrentIndex2 + 1;
				}
			}
			if (!boFoundFirst ||
				!boFoundSecond)
			{
				boStop = true;
			}
			else
			{
				if (szSizeString == szCurrentSize)
				{
					boStop = true;
					UpdateQuantity(szQuantityString);
				}
			}
		}
	}
}

function UpdateQuantity(szQuantityString)
{
	QuantityElement = document.getElementById("QuantityAvailable");
	QuantityElement.innerHTML = szQuantityString;
}

function changePromoSource()
{
	SelectControl = document.getElementById("whereGetPromo");
	OtherControl = document.getElementById("whereGetPromoOther");

	if (SelectControl.value == "Other (please specify)")
	{
		OtherControl.disabled=false;
	}
	else
	{
		OtherControl.disabled=true;
	}
}

function ValidateForm_Login(form)
{
	boErrorFound = false;
	boFirstEmailValid = true;
	szFirstPassword ="";
	szFirstEmail="";

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 16) == "CustomerPassword")
		{
			szFirstPassword = form.elements[i].value;
		}
		
		if (form.elements[i].name.substring(0, 13) == "CustomerEmail")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}


	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}


	return (!boErrorFound);	
}

function ValidateForm_ChangeEmail()
{
	OldPassword	= document.getElementById("oldPassword");
	NewEmail	= document.getElementById("NewEmail");
	NewEmailVerify	= document.getElementById("newEmailVerify");


	boErrorFound = false;
	szOldPassword = OldPassword.value;
	szNewEmail = NewEmail.value;
	szNewEmailVerify= NewEmailVerify.value;

	boFirstEmailValid = IsEmailValid(szNewEmail);


	if (szOldPassword == "")
	{
		OldPassword.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		OldPassword.style.backgroundColor="";
	}
	if (szNewEmail == "")
	{
		NewEmail.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		NewEmail.style.backgroundColor="";
	}

	if (szNewEmailVerify == "")
	{
		NewEmailVerify.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		NewEmailVerify.style.backgroundColor="";
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (szNewEmail != szNewEmailVerify)
	{
		alert("The email addresses you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	return (!boErrorFound);	
}

function ValidateForm_ChangePassword()
{
	OldPassword	= document.getElementById("oldPassword");
	NewPassword	= document.getElementById("NewPassword");
	NewPasswordVerify	= document.getElementById("newPasswordVerify");


	boErrorFound = false;
	szOldPassword = OldPassword.value;
	szFirstPassword = NewPassword.value;
	szSecondPassword= NewPasswordVerify.value;

	if (szOldPassword == "")
	{
		OldPassword.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		OldPassword.style.backgroundColor="";
	}
	if (szFirstPassword == "")
	{
		NewPassword.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		NewPassword.style.backgroundColor="";
	}

	if (szSecondPassword == "")
	{
		NewPasswordVerify.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		NewPasswordVerify.style.backgroundColor="";
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	return (!boErrorFound);	
}

function ValidateForm_ForgotLogin(form)
{
	boErrorFound = false;

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name == "submit")
		{
			submitButtonIndex = i;
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}
	else
	{
		form.elements[submitButtonIndex].disabled = true;
	}

	return (!boErrorFound);	
}


function ValidateForm_ForgotPassword()
{
	NewEmail	= document.getElementById("NewEmail");


	boErrorFound = false;
	szNewEmail = NewEmail.value;

	boFirstEmailValid = IsEmailValid(szNewEmail);

	if (szNewEmail == "")
	{
		NewEmail.style.backgroundColor="ffaaaa";
		boErrorFound = true;	
	}
	else
	{
		NewEmail.style.backgroundColor="";
	}


	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	return (!boErrorFound);	
}


function ValidateForm_EditCustomerDetails(form)
{
	boErrorFound = false;
	boFirstEmailValid = true;
	szFirstPassword ="";
	szSecondPassword="";
	szFirstEmail="";
	szSecondEmail=""

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name.substring(0, 16) == "CustomerPassword")
		{
			szFirstPassword = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 22) == "CustomerVerifyPassword")
		{
			szSecondPassword = form.elements[i].value;
		}
		
		if (form.elements[i].name.substring(0, 13) == "CustomerEmail")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}
		if (form.elements[i].name.substring(0, 19) == "CustomerVerifyEmail")
		{
			szSecondEmail = form.elements[i].value;
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;
			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	if (szFirstEmail != szSecondEmail)
	{
		alert("The email addresses you have entered do not match");
		boErrorFound = true;
	}

	return (!boErrorFound);	
}

function ValidateForm_ProcessOrder(form)
{
	boErrorFound = false;
	boFirstEmailValid = true;
	szFirstPassword ="";
	szSecondPassword="";
	szFirstEmail="";
	szSecondEmail=""

	for (i = 0; i < form.length; i++)
	{
		if (form.elements[i].name == "submit")
		{
			submitButtonIndex = i;
		}

		if (form.elements[i].name.substring(0, 16) == "CustomerPassword")
		{
			szFirstPassword = form.elements[i].value;
		}
		if (form.elements[i].name.substring(0, 22) == "CustomerVerifyPassword")
		{
			szSecondPassword = form.elements[i].value;
		}
		
		if (form.elements[i].name.substring(0, 13) == "CustomerEmail")
		{
			szFirstEmail = form.elements[i].value;
			boFirstEmailValid = IsEmailValid(szFirstEmail);
		}
		if (form.elements[i].name.substring(0, 19) == "CustomerVerifyEmail")
		{
			szSecondEmail = form.elements[i].value;
		}

		if (form.elements[i].name.length > 4)
		{
			nPosition = form.elements[i].name.length - 4;

			if (form.elements[i].name.substring(nPosition, form.elements[i].name.length) == "_REQ")
			{
				if (form.elements[i].disabled == false)
				{
					if (form.elements[i].type == "checkbox")
					{
						if (!form.elements[i].checked)
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
					else
					{
						if (form.elements[i].value == "")
						{
							form.elements[i].style.backgroundColor="ffaaaa";
							boErrorFound = true;	
						}
						else
						{
							form.elements[i].style.backgroundColor="";
						}
					}
				}
			}
		}
	}

	if (boErrorFound)
	{
		alert("Some required fields were not filled in - please fill in the fields shaded red");
	}

	if (szFirstPassword != szSecondPassword)
	{
		alert("The passwords you have entered do not match");
		boErrorFound = true;
	}

	if (!boFirstEmailValid)
	{
		alert("The email address you have entered is not a valid address");
		boErrorFound = true;
	}

	if (szFirstEmail != szSecondEmail)
	{
		alert("The email addresses you have entered do not match");
		boErrorFound = true;
	}

	if (!boErrorFound)
	{
		form.elements[submitButtonIndex].disabled = true;
	}

	return (!boErrorFound);	
}



function getElm(id)
	{ 
		if(document.getElementById) 
		return document.getElementById(id); 
		else if(document.all) return document.all[id]; 
		else return null; 
	} 

function showLevel(textLevel)
	{ 
		var thisLevel = getElm(textLevel); 
		if ( thisLevel.style.display == "none") { 
		thisLevel.style.display = "block"; 
		} 
		else { 
		hideLevel( textLevel, bulId); 
		} 
	} 

function hideLevel(textLevel)
	{ 
		var thisLevel = getElm(textLevel); 
		thisLevel.style.display = "none"; 
	}
	
function Browser() {

  var ua, s, i;

  this.isIE    = false;  /* Internet Explorer */
  this.isNS    = false;  /* Netscape		  */
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  /* Treat any other "Gecko" browser as NS 6.1.	*/

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

/*----------------------------------------------------------------------------
   Code for handling the menu bar and active button.
  ----------------------------------------------------------------------------*/

var activeButton = null;

function buttonClick(event, menuId) 
{

  var button;

  /* Get the target button element.*/

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  /* Blur focus from the link to remove that annoying outline.*/

  button.blur();

  /* Associate the named menu to this button if not already done.
     Additionally, initialize menu display.*/

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.initialized == null)
      menuInit(button.menu);
  }

  /* [MODIFIED] Added for activate/deactivate on mouseover.*/

  /* Set mouseout event handler for the button, if not already done.*/

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;

  /* Exit if this button is the currently active one.*/

  if (button == activeButton)
    return false;

  /* Reset the currently active button, if any.*/

  	if (activeButton != null)
  	{
    	resetButton(activeButton);
	}

  /* Activate this button, unless it was the currently active one.*/

  	if (button != activeButton) 
  	{
    	depressButton(button);
    	activeButton = button;
  	}
  	else
  	{
    	activeButton = null;
	}

  return false;
}

function buttonMouseover(event, menuId, elementName, imageName, reserved, number) 
{
  	var button;

  	/* Activates this button's menu if no other is currently active.*/

  	if (activeButton == null) 
  	{
		/* highlight the button */
		MM_nbGroup('over', elementName, imageName, reserved, number); 
    	buttonClick(event, menuId);
    	return;
  	}
								    
  	/* Find the target button element.*/

  	if (browser.isIE)
    	button = window.event.srcElement;
  	else
    	button = event.currentTarget;

  	/* If any other button menu is active, make this one active instead. */

  	if (activeButton != null && activeButton != button)
  	{
		/* highlight the button */
		MM_nbGroup('over', elementName, imageName, reserved, number); 
    	buttonClick(event, menuId);
	}
}


function depressButton(button) {

  var x, y;

  /* Update the button's style class to make it look like it's
     depressed.	*/

  button.className += " menuButtonActive";


  /* Set mouseout event handler for the button, if not already done. */

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout;

  /* Position the associated drop down menu under the button and
     show it. */

  x = getPageOffsetLeft(button);
  y = getPageOffsetTop(button) + button.offsetHeight;

  /* For IE, adjust position. */

  if (browser.isIE) {
    x += button.offsetParent.clientLeft;
    y += button.offsetParent.clientTop;
  }

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";
  button.menu.style.visibility = "visible";
}

function resetButton(button) {

  /* Restore the button's style class.*/

  removeClassName(button, "menuButtonActive");

  /* Hide the button's menu, first closing any sub menus.*/

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
  }
}

/*----------------------------------------------------------------------------
  Code to handle the menus and sub menus.
  ----------------------------------------------------------------------------*/

function menuMouseover(event) {

  var menu;

  /* Find the target menu element.*/

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  /* Close any active sub menu.*/

  if (menu.activeItem != null)
    closeSubMenu(menu);
}


function menuItemMouseover(event, menuId) {

  var item, menu, x, y;

  /* Find the target item element and its parent menu element.*/

  if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");

  /* Close any active sub menu and mark this one as active.*/

  if (menu.activeItem != null)
    closeSubMenu(menu);
  menu.activeItem = item;

  /* Highlight the item element.*/

  item.className += " menuItemHighlight";

  /* Initialize the sub menu, if not already done.*/

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.initialized == null)
      menuInit(item.subMenu);
  }


  /* Set mouseout event handler for the sub menu, if not already done. */

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout;

  /* Get position for submenu based on the menu item.*/

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  /* Adjust position to fit in view.*/

  var maxX, maxY;

  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  if (browser.isIE && browser.version < 6) {
    maxX = document.body.scrollLeft + document.body.clientWidth;
    maxY = document.body.scrollTop  + document.body.clientHeight;
  }
  if (browser.isIE && browser.version >= 6) {
    maxX = document.documentElement.scrollLeft + document.documentElement.clientWidth;
    maxY = document.documentElement.scrollTop  + document.documentElement.clientHeight;
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  /* Position and show the sub menu.*/

  item.subMenu.style.left = x + "px";
  item.subMenu.style.top  = y + "px";
  item.subMenu.style.visibility = "visible";

  /* Stop the event from bubbling.*/

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

			


function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  /* Recursively close any sub menus.*/

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
    menu.activeItem.subMenu = null;
  }
  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
}


function buttonOrMenuMouseout(event) {

  var el;

	
  /* If there is no active button, exit.*/

  if (activeButton == null)
    return;

  /* Find the element the mouse is moving to.*/

  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  /* If the element is not part of a menu, reset the active button.*/

  if (getContainerWith(el, "DIV", "menu") == null) 
  {
    resetButton(activeButton);
    activeButton = null;
  	MM_nbGroup('out');
  }
}


/*----------------------------------------------------------------------------
   Code to initialize menus.
  ----------------------------------------------------------------------------*/

function menuInit(menu) {

  var itemList, spanList
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  /* For IE, replace arrow characters. */

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  /* Find the width of a menu item.	*/

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  /* For items with arrows, add padding to item text to make the
     arrows flush right. */

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN")
    textEl  = null
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null)
      textEl.style.paddingRight = (itemWidth
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
  }

  /* Fix IE hover problem by setting an explicit width on first item of
    the menu. */

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  /* Mark menu as initialized. */

  menu.initialized = true;
}

/*----------------------------------------------------------------------------
   General utility functions.
  ----------------------------------------------------------------------------*/


function getContainerWith(node, tagName, className) {

  /* Starting with the given node, find the nearest containing element
   with the specified tag name and style class.*/

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}


function hasClassName(el, name) {

  var i, list;

  /* Return true if the given element currently has the given class
   name.*/

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}



function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  /* Remove the given class name from the element's className property.*/

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  /* Return the x coordinate of an element relative to the page.*/

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  /* Return the x coordinate of an element relative to the page.*/

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

function MM_findObj(n, d) 
{ 
	var p,i,x;  
	
	if(!d)
	{ 
		d=document; 
	}	
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
    	d=parent.frames[n.substring(p+1)].document; 
    	n=n.substring(0,p);
    }
  	if(!(x=d[n])&&d.all)
  	{
  		x=d.all[n];
  	} 
  	for (i=0;!x&&i<d.forms.length;i++)
  	{ 
  		x=d.forms[i][n];
	}
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  	{
  		x=MM_findObj(n,d.layers[i].document);
	}
  	if(!x && d.getElementById)
  	{
  		x=d.getElementById(n);
  	} 
  	return x;
}

function MM_nbGroup(event, grpName) 
{ 
  	var i,img,nbArr,args=MM_nbGroup.arguments;
  
  	if (event == "init" && args.length > 2) 
  	{
    	if ((img = MM_findObj(args[2])) != null && !img.MM_init) 
    	{
      		img.MM_init = true; 
      		img.MM_up = args[3]; 
      		img.MM_dn = img.src;

      		if ((nbArr = document[grpName]) == null) 
      		{
      			nbArr = document[grpName] = new Array();
			}
      		nbArr[nbArr.length] = img;
      		for (i=4; i < args.length-1; i+=2)
      		{ 
	      		if ((img = MM_findObj(args[i])) != null) 
	      		{
	        		if (!img.MM_up)
	        		{	
	        			img.MM_up = img.src;
					}
	        		img.src = img.MM_dn = args[i+1];
	        		nbArr[nbArr.length] = img;
	    		}
	    	} 
    	}
  	} 
  	else if (event == "over") 
  	{
    	document.MM_nbOver = nbArr = new Array();
	    for (i=1; i < args.length-1; i+=3)
	    { 
		    if ((img = MM_findObj(args[i])) != null) 
		    {
		      	if (!img.MM_up)
		      	{
		      		img.MM_up = img.src;
				}
		      	img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
		      	nbArr[nbArr.length] = img;
		    }
		}
  	} 
  	else if (event == "out" ) 
  	{
    	for (i=0; i < document.MM_nbOver.length; i++) 
    	{
      		img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; 
      	}
  	} 
	else if (event == "down") 
	{
    	nbArr = document[grpName];
    	
    	if (nbArr)
		{
      		for (i=0; i < nbArr.length; i++) 
      		{ 
      			img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; 
      		}
		}
   		document[grpName] = nbArr = new Array();
    	
    	for (i=2; i < args.length-1; i+=2)
    	{ 
	    	if ((img = MM_findObj(args[i])) != null) 
	    	{
		      	if (!img.MM_up)
		      	{	
		      		img.MM_up = img.src;
			  	}
	      		img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
	      		nbArr[nbArr.length] = img;
	  		}
	  	} 	
  	}
}


/*function MM_preloadImages() 
{ 
	var d=document; 
  	
  	if(d.images)
  	{ 
  		if(!d.MM_p) 
  		{
  			d.MM_p=new Array();
		}
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
    	
    	for(i=0; i<a.length; i++)
		{
		    if (a[i].indexOf("#")!=0)
		    { 
		    	d.MM_p[j]=new Image; 
		    	d.MM_p[j++].src=a[i];
		    }
		}
	}
}*/
