// form validation
function f_subm(){
	var Nx = document.getElementById("full_name");
	var Ex = document.getElementById("mail");
	var valNx = Nx.value;
	var valEx = Ex.value;
	switch(true){
		case valNx == "" || valEx == "":
			alert("Please enter your name and email address"); return false; break;
		case valEx.match(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/) != null:
			alert("Thank you for your registering. \n\nIf you would like to know more about the Smartfix products, please go to the contacts page.\n");
			return true; break;
		default:
			alert("Email address is incorrect"); return false;
	}
}
// form submit
function email_form_submit() {
	if(f_subm()) {
		var form = document.getElementById('email_form');
		if(form)
			form.submit();
	}
}

function f_subm_contact() {
	var nick = document.getElementById("nick");
	var company = document.getElementById("company");
	var address = document.getElementById("address");
	var city = document.getElementById("city");
	var postcode = document.getElementById("postcode");
	var state = document.getElementById("state");
	var country = document.getElementById("country");
	var phone = document.getElementById("phone");
	var email = document.getElementById("email");
	var comments = document.getElementById("comments");
	
	var val_nick = nick.value;
	var val_company = company.value;
	var val_address = address.value;
	var val_city = city.value;
	var val_postcode = postcode.value;
	var val_state = state.value;
	var val_country = country.selectedIndex;
	var val_phone = phone.value;
	var val_email = email.value;
	var val_comments = comments.value;
	
	if(val_nick == "" || val_company == "" || val_address == "" || val_city == "" || 
			val_postcode == "" || val_state == "" || val_country == "" ||
			val_phone == "" || val_email == "" || val_comments == "") {
		alert("Please fill up all mandatory fields marked with an asterisk (*)");
		return false;
	} else if(val_email.match(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/) == null) {
		alert("Email address is incorrect"); 
		return false;
	} else {
		alert("Thank you for your registering.");
		return true;
	}
}

function contact_form_submit() {
	if(f_subm_contact()) {
		var form = document.getElementById('contact_form');
		if(form)
			form.submit();
	}
}