function getBrowser(){
	var ua=window.navigator.userAgent;var b='';
	if(ua.indexOf("Opera")>=0)b='Opera';else
	if(ua.indexOf("Safari")>=0)b='Safari';else
	if(ua.indexOf("Gecko")>=0)b='Mozilla';else
	if(ua.indexOf("MSIE")>=0)b='IE';
	return b;
}

function fieldObserve(f, focus, word) {
	if (focus && f.value == word) f.value = '';
	if (!focus && f.value == '')  f.value = word;
}

function windowopen() {
	newwin=window.open('/zakaz.php', 'newwin', 'width=400,height=480');
	newwin.focus();
}

function RightPhoto(id, table, photo){
	var top;
	var left;
	width=640;
	height=685;
	top=(screen.height-height-300)/2;
	left=(screen.width-width)/2;
	if (table != 'undefined' && table != '' && photo != 'undefined' && photo != '') {
		bigPic_r=window.open("/bigpic_r.php?id="+id+"&pt="+table+"&photo="+photo, id, "top="+top+",left="+left+",width="+width+", height="+height+", status=0, menubar=0, location=0 resizable=0 directories=0 toolbar=0");
	} else {
		bigPic_r=window.open("/bigpic_r.php?id="+id+"&pt=*&photo=1", id, "top="+top+",left="+left+",width="+width+", height="+height+", status=0, menubar=0, location=0 resizable=0 directories=0 toolbar=0");
	}

	bigPic_r.focus();
}

function cm(mail){
	if(mail!=""){
		var re = /^[\w._-]+@[\w._-]+[.]+[a-zA-Z]{2,4}$/i;
		return re.test(mail);
	}
	return false;
}

function write(fl){
	if(fl==1)
	{
		alert("Пользователь с таким E-mail уже существует");
	}
	elseif(fl==2)
	{
		alert("Произошла какая-то ошибка.nРегистрация не удалась");
	}
	elseif(fl==3)
	{
		alert("Вы подписались на рассылку.");
	}
}


function rassilka(){
	var email_ = document.getElementById('email_').value;
	if(email_ == ""){
		alert("ОШИБКА!\nЗаполните все поля");
	}else if(email_ == "" || !cm(email_)){
		alert("ОШИБКА!\nНе правильный E-mail");
	}else{
		document.getElementById('acti').value="rassilka";
		document.getElementById('subscribe_form').submit();
	}
}

function sendSearchQuery(){
	var f = document.getElementById('search_form');
	var q = document.getElementById('query');

	if(q.value.length == 0 || q.value == 'Поиск') {
		alert("Ошибка!\nПоисковый запрос не может быть пустым.");
	}else if(q.value.length < 3) {
		alert("Ошибка!\nПоисковый запрос не может быть короче 3-х символов.");
	}else{
		f.submit();
	}
}
