function showStates(countryid) {
	if(countryid == 226) {
		document.getElementById("state").style.display = "block";
	}
	else {
		document.getElementById("state").style.display = "none";
		document.getElementById("state").selectedIndex = 0;
	}
}
function showAltStates(countryid) {
	if(countryid == 226) {
		document.getElementById("altstate").style.display = "block";
	}
	else {
		document.getElementById("altstate").style.display = "none";
		document.getElementById("altstate").selectedIndex = 0;
	}
}

function validate(checkpassword) {
	var form = document.getElementById('registrationform');
	if(form.email.value.search(/^[\w-_\.]*[\w-_\.]\@[\w\.]*\.+[\w]{2,4}$/gi)) {
		alert(popup_email);
		form.email.focus();
	}
	else if(checkpassword && form.pwd.value != form.pwd2.value) {
		alert(popup_pwd2);
		form.pwd.focus();
	}
	else if(checkpassword && form.pwd.value.length < 6) {
		alert(popup_pwd);
		form.pwd.focus();
	}
	else if(form.fname && form.fname.value.length == 0) {
		alert(popup_fname);
		form.fname.focus();
	}
	else if(form.lname && form.lname.value.length == 0) {
		alert(popup_lname);
		form.lname.focus();
	}
	else if(form.name && form.name.value.length == 0) {
		alert(popup_name);
		form.name.focus();
	}
	else if(form.phone && form.phone.value.length == 0) {
		alert(popup_phone);
		form.phone.focus();
	}
	else if(form.address.value.length == 0) {
		alert(popup_address);
		form.address.focus();
	}
	else if(form.zipcode.value.length == 0) {
		alert(popup_zipcode);
		form.zipcode.focus();
	}
	else if(form.city.value.length == 0) {
		alert(popup_city);
		form.city.focus();
	}
	else if(form.country_id.selectedIndex == 0) {
		alert(popup_country);
		form.country_id.focus();
	}
	else if(form.country_id.value == 226 && form.state_id.selectedIndex == 0) {
		alert(popup_state);
		form.state_id.focus();
	}
	else {
		form.submit();
	}
}


/* Old functions */
function old_toggle(obj) {
	if(obj.style.display!='block')
		obj.style.display='block';
	else
		obj.style.display='none';
}
function old_validate() {
	f = document.form;
	/*if(!f.tbl_customertypes_id[0].checked && !f.tbl_customertypes_id[1].checked) {
		alert("Du måste välja kundtyp!");
		f.tbl_customertypes_id[0].focus();
	}
	else */
	if(!f.name.value.length > 0) {
		alert("Du måste ange ditt namn!");
		f.name.focus();
	}
	else if(!f.ssn.value.length > 0) {
		alert("Du måste ange persnr/orgnr!");
		f.ssn.focus();
	}
	else if(f.email.value.search(/^[\w-_\.]*[\w-_\.]\@[\w\.]*\.+[\w]{2,4}$/gi)) {
		alert("Du måste ange en giltig e-postadress!");
		f.email.focus();
	}
	else
		document.form.submit();
}

