var xmlhttp;
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject){
// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else{
	alert("Your browser does not support XMLHTTP!");
}

function submit_form()
{
	var filter = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+$/;
	var email = document.reg_form.email_f;
	if (document.reg_form.firstname_f.value == "")
	{
		alert("First Name field is mandatory");
		document.reg_form.firstname_f.focus();
	}
	else if (document.reg_form.lastname_f.value == "")
	{
		alert("Last Name field is mandatory");
		document.reg_form.lastname_f.focus();
	}
	else if (!filter.test(email.value))
	{
		alert("Please provide a valid email address");
		document.reg_form.email_f.focus();
	}
	else if (document.reg_form.frm_company_name.value == "")
	{
		alert("Company field is mandatory");
		document.reg_form.frm_company_name.focus();
	}
	else if (document.reg_form.frm_company_phone.value == "")
	{
		alert("Phone number field is mandatory");
		document.reg_form.frm_company_phone.focus();
	}
	else if (document.reg_form.frm_company_city.value == "")
	{
		alert("City field is mandatory");
		document.reg_form.frm_company_city.focus();
	}
	else if (document.reg_form.frm_company_state.selectedIndex == 0)
	{
		alert("State field is mandatory");
		document.reg_form.frm_company_state.focus();
	}
	else if (document.reg_form.frm_company_country.selectedIndex == 0)
	{
		alert("Country field is mandatory");
		document.reg_form.frm_company_country.focus();
	}
	else if (document.getElementById("frm_news_info_yes").checked == false && document.getElementById("frm_news_info_no").checked == false) 
	{
		alert("You have to indicate if you want to receive information from Vizimax in the future. You can always unsubscribe at any moment.");
		document.getElementById("frm_news_info_yes").focus();
	}
	else
	{
		document.reg_form.submit();
	}
	
}

function submit_optin()
{
	var filter = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+$/;
	var email = document.msg_form.email_f;
	if (document.msg_form.firstname_f.value == "")
	{
		alert("First Name field is mandatory");
		document.msg_form.firstname_f.focus();
	}
	else if (document.msg_form.lastname_f.value == "")
	{
		alert("Last Name field is mandatory");
		document.msg_form.lastname_f.focus();
	}
	else if (!filter.test(email.value))
	{
		alert("Please provide a valid email address");
		document.msg_form.email_f.focus();
	}
	else
	{
		document.msg_form.submit();
	}
	
}


function form_focus(id, val)
{	
	if(document.getElementById(id).value==val) 
	{ 
		document.getElementById(id).value='';
		document.getElementById(id).style.backgroundColor = "#fff";
	} 
}

function form_blur(id, val)
{                 
	if(document.getElementById(id).value=='') 
	{
		document.getElementById(id).value=val;
	}
}
