//var email_pattern=/\w+@\w+\.\w{2,}/;
var email_pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

function $(id){
	return document.getElementById(id);
}
function shedule_form_prevalidate(){
	form_prevalidate();
	setTimeout('shedule_form_prevalidate()',100);
}

function form_prevalidate(){
	if(form){
		$('firstname_caption').className=(form.firstname.value.length==0)?'required':'';
		$('firstname_field').className=(form.firstname.value.length==0)?'required':'';
		$('lastname_caption').className=(form.lastname.value.length==0)?'required':'';
		$('lastname_field').className=(form.lastname.value.length==0)?'required':'';
		$('email_caption').className=(form.email.value.length==0 || !email_pattern.test(form.email.value))?'required':'';
		$('email_field').className=(form.email.value.length==0 || !email_pattern.test(form.email.value))?'required':'';
		$('phone_caption').className=(form.phone_code.value.length==0 || form.phone_country_code.value.length==0 || form.phone.value.length==0)?'required':'';
		$('phone_country_code_field').className=(form.phone_country_code.value.length==0 || form.phone_country_code.value.length==0)?'required':'';
		$('phone_code_field').className=(form.phone_code.value.length==0 || form.phone_code.value.length==0)?'required':'';
		$('phone_field').className=(form.phone_code.value.length==0 || form.phone.value.length==0)?'required':'';
		$('company_caption').className=(form.company.value.length==0)?'required':'';
		$('company_field').className=(form.company.value.length==0)?'required':'';
	}
	
		form.submit.disabled = (form.firstname.value.length==0 || form.lastname.value.length==0 || form.email.value.length==0 || !email_pattern.test(form.email.value) || form.phone_code.value.length==0 || form.phone.value.length==0 || form.company.value.length==0)?true:false;
}

function assign_get_demo_events(){
	form.business_type[form.business_type.length-1].onclick	=	function(){ if(this.checked){form.custom_business.focus();}}
	form.printer_type[form.printer_type.length-1].onclick	=	function(){ if(this.checked){form.custom_printer.focus();}}
	form.printer_type[form.printer_type.length-1].onclick	=	function(){ if(this.checked){form.custom_printer.focus();}}
	form.custom_printer.onfocus								=	function(){ form.printer_type[form.printer_type.length-1].checked=true;}
	form.custom_business.onfocus							=	function(){ form.business_type[form.business_type.length-1].checked=true;}
}