function popupWindow(url)
{
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=10,height=10,screenX=50,screenY=50,top=150,left=150')
}
function gtSetImg(id, src, idcapto, idcapfrom, iddescrto, iddescrfrom)
{
	var el;
	if (document.getElementById(id))
	{
		pic = new Image();
		pic.src = src;
		document.getElementById(id).src = src;
	}
	document.getElementById(idcapto).innerHTML = document.getElementById(idcapfrom).innerHTML;
	document.getElementById(iddescrto).innerHTML = document.getElementById(iddescrfrom).innerHTML;
}
function gtSetImgFirst(iddescrto, iddescrfrom)
{
	if (document.getElementById(iddescrto) && document.getElementById(iddescrfrom))
	document.getElementById(iddescrto).innerHTML = document.getElementById(iddescrfrom).innerHTML;
}
function gtSend(id)
{
	if (gtCheckForm(id, "author question", "address"))
	document.getElementById(id).submit();
	return false;
}
function gtCheckEmail(str)
{
	var pos1, pos2;
	if (str!="")
	{
		pos1 = str.indexOf("@");
		pos2 = str.indexOf(".", pos1+1);
		if (pos1!=-1 && pos1!=-1 && pos1>0 && pos2 - pos1>2 && str.length - pos2>2)
		return true;
	}
	return false;
}
function gtCheckForm(id, notnull, asemail)
{
	// вызывается при отправке формы
	var form, arr, len, el, lab, i, k;
	if (form = document.getElementById(id)) {
		errormsg = "";
		notnull = " "+notnull+" ";
		asemail = " "+asemail+" ";
		len = form.elements.length;
		for (i = 0; i<len; i++) {
			el = form.elements[i];
			if (el.name && notnull.indexOf(" "+el.name+" ")!=-1) { // проверка на пустые значения
				if (el.value=="")
				{
					lab = document.getElementById("idlabel"+el.name);
					if (lab)
					{
						lab.style.color="#F00";
						errormsg += "Необходимо заполнить поле <"+lab.innerHTML+">. \n";
					}
					else
					errormsg += "Не заполнено обязательное поле. ";
					if (errormsg=="")
					el.fio.focus();
				}
				else
				{
					lab = document.getElementById("idlabel"+el.name);
					lab.style.color="#898989";
				}
			}
			if (el.name && asemail.indexOf(" "+el.name+" ")!=-1)
			{
				// проверка на e-mail
				if (!gtCheckEmail(el.value))
				{
					// если строка не пустая и не e-mail
					lab = document.getElementById("idlabel"+el.name);
					if (lab)
					{
						lab.style.color="#F00";
						errormsg += "Поле <"+lab.innerHTML+"> должно содержать e-mail. \n";
					}
					else
					errormsg += "Неверно указан e-mail. ";
					if (errormsg=="")
					el.fio.focus();
				}
				else
				{
					lab = document.getElementById("idlabel"+el.name);
					lab.style.color="#898989";
				}
			}
		}
		if (errormsg!="")
		{
			// ошибка в вводимых данных
			alert(errormsg);
			return false;
		}
		else
		return true;
	}
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
