function trim(sStr) {
	i = 0;
	while( i<sStr.length ){
	   	if( sStr.charAt(i)!=' ' )
	      		break;
		i++;
	}
	return sStr.substring(i, sStr.length);
}
	
function check_email(email) {
	var email = trim(email);
	emailTest = "^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z_-]+\\.)+[a-z]{2,4}$";
	var regex = new RegExp(emailTest);
	if (!regex.test(email)) return 1; else return 0;
}

function subm(){
	with(document.forms.newfoto) {
		if (trim(name.value)=='') {alert("Вы не указали имя!"); name.focus; return;}
		if (trim(email.value)=='') {alert("Вы не указали e-mail!"); email.focus; return;}
		if (check_email(email.value)) {alert("Поле e-mail должно быть заполнено правильно!!!"); email.focus; return;}
		if (trim(telefon.value)=='') {alert("Вы не указали контактный телефон!"); telefon.focus; return;}
		if (trim(foto_name.value)=='') {alert("Вы не указали название работы!"); foto_name.focus; return;}
		if (trim(foto_file.value)=='') {alert("Вы не указали файл!"); foto_file.focus; return;}
		if (trim(user_key.value)=='') {alert("Вы не ввели цифры с картинки!"); user_key.focus; return;}
		submit();
	}
}