if (window.addEventListener)
	window.addEventListener("load", init_form, false);
else if (window.attachEvent)
	window.attachEvent("onload", init_form);
	
function init_form ()
{
	var Oform=document.getElementById('my_form');
	var my_antispam=document.getElementById('antispam');
	if(my_antispam)
	{
		my_antispam.value='kahsdkf' + 'jhsadf9997' + 'sadfgsd09909';
	}
	if(Oform)
	{
		Oform.onsubmit=function()
		{
			var errors="";
			var my_topic=document.getElementById('topic');
			if(my_topic.selectedIndex==0)
			{
				errors+="Field Topic is empty.\n";
			}
			
			var my_name=document.getElementById('name');
			if(my_name)
			{
				if(my_name.value.replace(/[\s,\n,\f,\r,\t,\v]*/,'').length==0)
				{
					errors+="Field Name is empty.\n";
				}
			}
			
			var my_company=document.getElementById('company');
			if(my_company)
			{
				if(my_company.value.replace(/[\s,\n,\f,\r,\t,\v]*/,'').length==0)
				{
					errors+="Field Company is empty.\n";
				}
			}
			
			var my_phone_1=document.getElementById('phone_1');
			var my_phone_2=document.getElementById('phone_2');
			var my_phone_3=document.getElementById('phone_3');
			if(my_phone_1.value.length!=3||my_phone_2.value.length!=3||my_phone_3.value.length!=4)
			{
				errors+="Incorrect Phone.\n";
			}
			var my_email=document.getElementById('email');
			if(my_email)
			{
				if(my_email.value.replace(/[\s,\n,\f,\r,\t,\v]*/,'').length==0)
				{
					errors+="Field Email is empty.\n";
				}
				else if(!my_email.value.match(new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$')))
				{
					errors += "Incorrect Email address.\n";
				}
			}
			var my_comments=document.getElementById('comments');
			if(my_comments)
			{
				if(my_comments.value.replace(/[\s,\n,\f,\r,\t,\v]*/,'').length==0)
				{
					errors+="Field comments is empty.\n";
				}
			}
			
			if(errors.length>0)
			{
				alert(errors);
				return false;
			}
		}
	}
}