
function goType()
{

	var typeid = document.forms.type.typeid[document.forms.type.typeid.selectedIndex].value;

	if(typeid > 0 )
		location.href='shop.asp?typeid=' + typeid;
}
function goArtist()
{

	var artistid = document.forms.artist.artistid[document.forms.artist.artistid.selectedIndex].value;

	if(artistid > 0)
		location.href='shop.asp?artistid=' + artistid;
}

function goOrder( iType )
{
	var formValid = checkAddress();
	if( formValid )
	{
		if( iType == 4) // Postförskott
		{
			
			if( confirm("Beställningar via postförskott är bindande. Om du inte hämtar ut din beställning kommer du att få betala porto och postförskottsavgift i efterhand och vakna upp med ett hästhuvud i din säng." ) )
			{
				document.forms.checkout.nextAction.value='confirmed';
				document.forms.checkout.submit();
			}
		}
		else if( iType == 2 )
		{
			document.forms.checkout.nextAction.value='worldpay';
			document.forms.checkout.submit();	
		}
	}
}

function checkAddress()
{
	var email = document.getElementById("email");
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(email.value)) 
	{
		alert("Email is invalid.");
		email.focus();
		email.select();
		return false;
	}
	var firstname = document.getElementById("firstname");
	if( !firstname.value )
	{
		alert("First name is missing.");
		firstname.focus();
		firstname.select();
		return false;		
	}
	var lastname = document.getElementById("lastname");
	if( !lastname.value )
	{
		alert("Last name is missing.");
		lastname.focus();
		lastname.select();
		return false;		
	}
	var address = document.getElementById("address");
	if( !address.value )
	{
		alert("Address is missing.");
		address.focus();
		address.select();
		return false;		
	}
	var zip = document.getElementById("zip");
	if( !zip.value )
	{
		alert("Zip code is missing.");
		zip.focus();
		zip.select();
		return false;		
	}
		
	var city = document.getElementById("city");
	if( !city.value )
	{
		alert("City is missing.");
		city.focus();
		city.select();
		return false;		
	}
	return true;
	
}

