function CheckForm(form_id)
{
	//messages=['название компании пусто', 'контактное лицо пусто', 'номер телефона пуст', 'время пусто', 'эл. адрес пуст', 'неправильный формат эл. почты', 'код пуст',  'код должен состоять из чисел', 'телефонный номер должен состоять из чисел', 'телефонный номер должен состоять из чисел'];
	messages=['Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению', 'Поля, отмеченные *, обязательны к заполнению	'];
	//return true;
	//alert(document.order.company.value);
	//document.order.company.value	= trim(document.order.company.value);
	//document.order.contact_person.value		= trim(document.order.contact_person.value);


	if(document.order.company.value == ""){
		alert(messages[0]);
		document.order.company.focus();
		return false;
	}
	if(document.order.contact_person.value == ""){
		alert(messages[1]);
		document.order.contact_person.focus();
		return false;
	}
	if(document.order.phone.value == ""){
		alert(messages[2]);
		document.order.phone.focus();
		return false;
	}


	/*
	if (!is_num(document.order.phone.value))
	{
		alert(messages[9]);
		document.order.phone.focus();
		return false;
	}

	if(document.order.time.value == ""){
		alert(messages[3]);
		document.order.time.focus();
		return false;
	}
	*/

	if (form_id != 1)
	{
		if(document.order.mail.value == "")
		{
			alert(messages[4]);
			document.order.mail.focus();
			return false;
		}
		if (!is_mail(document.order.mail.value))
		{
			alert(messages[5]);
			document.order.mail.focus();
			return false;
		};
	}



	if(document.order.secrete_code.value == "")
	{
		alert(messages[6]);
		document.order.secrete_code.focus();
		return false;
	}

	if (!is_num(document.order.secrete_code.value))
	{
		alert(messages[7]);
		document.order.secrete_code.focus();
		return false;
	}


	flag=1;
	return true;
}

function is_num(code){
	var reg= new RegExp("[1-9]+", 'i')
	return reg.test(code);
}

function is_mail(mail){
	var reg= new RegExp("[0-9a-z_]+@[0-9a-z_^.]+\\.[a-z]{2,3}", 'i');
	return reg.test(mail);
}
