function expandadvice(thistag)
{
	closeadvice(26);
	document.getElementById("text"+thistag).style.display='';
}
function closeadvice(Counter)
{
	for(i=1;i<=Counter;i++)
	{
		document.getElementById("text"+i).style.display='none';
	}
}
function CloseupWindow(Item)
{
  window.open("/Store/DisplayCloseup.html?ID="+Item,"Sandbag","width=550,height=450,scrollbars")
}
function RemoveItem(PVID)
{
	window.location.replace("RemoveItemFromCart.html?ID="+PVID)
}
function ClearTrolley(PBA)
{
  window.location.replace("RemoveAllItemsFromCart.html")
}

function sizes()
{
	if(parseInt(navigator.appVersion)>3)
	{
		if(navigator.appName.indexOf("Microsoft")!=-1)
		{
 			winW = document.documentElement.clientWidth;
 			winH = (document.documentElement.clientHeight)+16;
		}
		else
		{
 			winW = window.innerWidth;
 			winH = window.innerHeight;
		}

	}

	divW = document.getElementById('contents').offsetWidth;
	divH = document.getElementById('contents').offsetHeight;

	if(divH > winH)
	{
		document.getElementById("bg_image1").height = divH;
		document.getElementById("Img1").height = divH;
	}
	else
	{
		document.getElementById("bg_image1").height = winH;
		document.getElementById("Img1").height = winH;
	}

	document.getElementById("bg_image1").width = winW;
	document.getElementById("Img1").width = winW;

	newHeight = (winH - divH) / 2;

	if (newHeight<0)
	{
		newHeight=0;
	}

	document.getElementById('contents').style.top = newHeight + "px";
}

function MMMPS2CheckForgottenFields()
{
	var themessage2 = "You must fill out the following field: ";
	if (document.form1.Email.value=="")
	{
		themessage2 = themessage2 + "\nYour email in the forgotten password section.";
	}
//alert if fields are empty and cancel form submit
	if (themessage2 == "You must fill out the following field: ")
	{
//		document.form1.Submit.disabled=true;
		document.form1.submit();
		return true;
	}
	else
	{
		alert(themessage2);
		return false;
	}
}

function ValidatePreRegisterForm()
{
	var themessage2 = "You must fill out the following fields: ";
	if (document.FrontPageForm.Email.value=="")
	{
		themessage2 = themessage2 + "\nYour email address";
	}
	if (document.FrontPageForm.Password.value=="")
	{
		themessage2 = themessage2 + "\nyour password";
	}
	if (themessage2 == "You must fill out the following fields: ")
	{
		document.FrontPageForm.submit();
		return true;
	}
	else
	{
		alert(themessage2);
		return false;
	}

}

function ValidateRegisterForm()
{
	var themessage3 = "You must fill out the following field: ";
	if (document.RegistrationForm.Email.value=="")
	{
		themessage3 = themessage3 + "\nYour email address";
	}
	if (themessage3 == "You must fill out the following field: ")
	{
		document.RegistrationForm.submit();
		return true;
	}
	else
	{
		alert(themessage3);
		return false;
	}

}

function VerifyRegistrationForm()
{
var themessage = "You are required to complete the following fields: ";
var x = document.SubmitMe.Email.value;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {}
	else 
	{
		themessage = themessage + " \nAn invalid e-mail address was entered.";
	}
	if (document.SubmitMe.LastName.value=="")
	{
		themessage = themessage + " \nLast name";
	}
	if (document.SubmitMe.Address1.value=="")
	{
	themessage = themessage + " \nAddress line 1";
	}
	if (document.SubmitMe.Town.value=="")
	{
		themessage = themessage + " \nTown";
	}
	if (document.SubmitMe.PostCode.value=="")
	{
		themessage = themessage + " \nPostcode / Zipcode";
	}
	if (document.SubmitMe.Password.value=="")
	{
		themessage = themessage + " \nPassword";
	}
	if (document.SubmitMe.CountryID[document.SubmitMe.CountryID.selectedIndex].value==0 )
	{
		themessage = themessage + " \nPlease select your Country.";
	}
	if ((document.SubmitMe.LandLineNumber.value=="")&&(document.SubmitMe.MobilePhoneNumber.value=="")) {
	themessage = themessage + " \nEither your home or mobile telephone number.";
	}
	if (themessage == "You are required to complete the following fields: ")
	{
		document.SubmitMe.Submit.disabled=true;
		document.SubmitMe.submit();
		return true;
	}
	else
	{
		alert(themessage);
		return false;
	}
}

function EnterState()
{
	document.SubmitMe.State.value=document.SubmitMe.USStates.options[document.SubmitMe.USStates.selectedIndex].value
}
