
function switchview()
{
var listview = document.getElementById('listview');
var iconview = document.getElementById('iconview');
if (listview.style.visibility == "hidden")
	{ iconview.style.visibility = "hidden"; listview.style.visibility = "visible";}
else
	{ iconview.style.visibility = "visible"; listview.style.visibility = "hidden";}
}

function swapimage( elem, url )
{
    document.getElementById(elem).style.backgroundImage = 'url(' + url + ')';
}

function confirmremoveitem()
{
return confirm("Are you sure you wish to remove this item?");
}

function confirmclearcart()
{
return confirm("Are you sure you wish to clear the shopping cart?");
}

function custaccountpass()
{
if (document.customerform.passwordfs.style.visibility != "visible")
{ document.customerform.passwordfs.style.visibility = "visible"; }
else
{ document.customerform.passwordfs.style.visibility = "hidden"; }
}

function returningcustomer()
{
document.loginform.style.visibility = "visible";
document.newcustform.style.visibility = "hidden";
}

function newcustomer()
{
document.loginform.style.visibility = "hidden";
document.newcustform.style.visibility = "visible";
}

function validatenewcust()
{
valid = true;
message = "";
if (document.customerform.fname.value.length == 0)
	{
	message += "First Name";
	valid = false;
	}	
if (document.customerform.lname.value.length == 0)
	{
	message += ", Last Name";
	valid = false;
	}

if (document.customerform.street.value.length == 0)
	{
	message += ", Street";
	valid = false;
	}

if (document.customerform.city.value.length == 0)
	{
	message += ", City";
	valid = false;
	}

if (document.customerform.country.value.length == 0)
	{
	message += ", Country";
	valid = false;
	}

if (document.customerform.postcode.value.length == 0)
	{
	message += ", Post Code";
	valid = false;
	}

if (document.customerform.email.value.length == 0)
	{
	message += ", Email Address";
	valid = false;
	}

if (valid == false)
	{
	alert(message + " cannot be blank!");
	}

return valid;
}

function validatenewcustaccount()
{
valid = true;
message = "";
if (document.customerform.fname.value.length == 0)
	{
	message += "First Name";
	valid = false;
	}	
if (document.customerform.lname.value.length == 0)
	{
	message += ", Last Name";
	valid = false;
	}

if (document.customerform.street.value.length == 0)
	{
	message += ", Street";
	valid = false;
	}

if (document.customerform.city.value.length == 0)
	{
	message += ", City";
	valid = false;
	}

if (document.customerform.country.value.length == 0)
	{
	message += ", Country";
	valid = false;
	}

if (document.customerform.postcode.value.length == 0)
	{
	message += ", Post Code";
	valid = false;
	}

if (document.customerform.email.value.length == 0)
	{
	message += ", Email Address";
	valid = false;
	}
if (document.customerform.password.value.length == 0)
	{
	message += ", Password";
	valid = false;
	}
else
	{
	if (document.customerform.password.value != document.customerform.confirm.value)
		{ 
		alert("New password does not confirm!");
		valid = false; 
		}
	}

if (valid == false)
	{
	alert(message + " cannot be blank!");
	}

return valid;
}

function confirmDelete()
{
var deleteaccount = confirm("Are you sure you want to remove your customer account (this can not be un-done)?");
return deleteaccount;
}



function checksetpasswd()
{
valid = true;

var passwdfield = document.getElementById('new');
var confirmfield = document.getElementById('confirm');
if (passwdfield.value.length == 0)
	{
	alert("Password cannot be blank");
	valid = false;
	}
else
	{
	if (passwdfield.value != confirmfield.value)
		{ 
		alert("New password does not confirm!");
		valid = false; 
		}
	}
return valid;
}

function checkupdatecustomer()
{
valid = true;
message = "";
if (document.customerform.fname.value.length == 0)
	{
	message += "First Name";
	valid = false;
	}	
if (document.customerform.lname.value.length == 0)
	{
	message += ", Last Name";
	valid = false;
	}

if (document.customerform.street.value.length == 0)
	{
	message += ", Street";
	valid = false;
	}

if (document.customerform.city.value.length == 0)
	{
	message += ", City";
	valid = false;
	}

if (document.customerform.country.value.length == 0)
	{
	message += ", Country";
	valid = false;
	}

if (document.customerform.postcode.value.length == 0)
	{
	message += ", Post Code";
	valid = false;
	}

if (document.customerform.email.value.length == 0)
	{
	message += ", Email Address";
	valid = false;
	}

if (document.customerform.password.value.length == 0)
	{
	message += ", Password";
	valid = false;
	}
else
	{
	if (document.customerform.password.value != document.customerform.confirm.value)
		{ 
		alert("New password does not confirm!");
		valid = false; 
		}
	}

if (valid == false)
	{
	alert(message + " cannot be blank!");
	}

return valid;
}


