// General
function DeleteItem(id)
{
   if (confirm("Are you sure you want to remove this item from your cart?"))
   {
      location.href = page_name + "?action=deleteitem&id=" + id;
   }
}

function CheckCheckout()
{
   var name = document.getElementById("name").value;
   var email = document.getElementById("email").value;
   var username = document.getElementById("usernamecart").value;
   var password = document.getElementById("passwordcart").value;

   if (name != "" && email != "")
      document.getElementById("submit").disabled = false;
   else if (username != "" && password != "")
      document.getElementById("submit").disabled = false;
   else
      document.getElementById("submit").disabled = true;
   
}

function vf()
{
   var name = document.getElementById("name").value;
   var email = document.getElementById("email").value;
   var username = document.getElementById("usernamecart").value;
   var password = document.getElementById("passwordcart").value;
   
   if ((name != "" && (username != "" || password != "")) ||
      (email != "" && (username != "" || password != "")))
   {
      alert("Please enter EITHER your name and email address\nOR your username and password!");
      return false;
   }
	if (email != "" && !validEmail(email))
	{
		document.getElementById("email").focus();
		alert("Please ensure your email address is valid!");
		return false;
	}
   return true;
}

function validEmail(field)
{
	invalidChars = " /:,;\\!#$%^&*()+='\"{}[]|?";
	for (i=0; i<invalidChars.length; i++)
	{
		badChar = invalidChars.charAt(i);
		if (field.indexOf(badChar,0)>-1) // checks if any of invalidChars in the email address
			return false;
	}
	atPos = field.indexOf("@",1);
	if (atPos == -1 || field.indexOf("@", atPos+1)>-1) // checks if there is one and only one @ in email address
		return false;
	periodPos = field.indexOf(".", atPos+2);
	if (periodPos == -1 || periodPos+3 > field.length) // checks if there is a . at least 2 characters after the @ and at least 2 chars before end
		return false;
	return true;
}
//-->
