// ---------Browser determination-----------
dom = (document.getElementById);
IE4x = (document.all && !dom);
NN4x = (document.layers);
br4x = (IE4x || NN4x);
IE5x = (IE4x && navigator.appVersion.indexOf("5.") >= 0);

function inp() {
if (document.frm.txt13.value.length == 0) {
alert("Нет сообщения.");
document.frm.txt13.focus();
return false;
}
if (document.frm.txt13.value.length > 512) {
alert("Сообщение не должно содержать более 255 символов.");
document.frm.txt13.focus();
return false;
}
if (document.frm.fio.value.length == 0) {
alert("Имя не указано.");
document.frm.fio.focus();
return false;
}
tst=document.frm.mil.value.toString();
t=tst.indexOf("@");
if((tst.indexOf(".")==-1) || (t==-1) || (t<1) || (t>tst.length-5) || (tst.charAt(t-1) == '.') || (tst.charAt(t+1)=='.')) {
alert("Некорректный E-mail.");
document.frm.mil.focus();
return false;
}
if (confirm("Высылаю?")) return true;
else return false;
}


function formValid(form) {
	f1 = document.forms[form].elements['field[title]'].value;
	f2 = document.forms[form].elements['field[email]'].value;
	f3 = document.forms[form].elements['field[text]'].value;
	
	if ((f1 == "") || (f1 == "Ваше имя")) {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if ((f2 == "") || (f2 == "Ваш e-Mail") || (f2.indexOf('@')<0) || (f2.indexOf('.')<0)) {
		alert("Введите, пожалуйста, корректный e-Mail");
		return false;
	}
	else if (f3 == "") {
		alert("Введите, пожалуйста, Ваше сообщение");
		return false;
	}
	else return true;
}

function createPictureWindow(_file,Width,Height)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no";
	w = window.open(_file,windowName,WinFeatures);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function createDescriptionWindow(URL,Width,Height)
{
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+(Width*p)+(Height*q);
	this.window.name='pw';
	WinFeatures = "top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",width="+Width+",height="+Height+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes";
	t = window.open(URL,windowName,WinFeatures);

}


function ExpandNode(num,url){
	if(IE4x){
		objName=document.all['submenu'+num].style;
		objName.display=((objName.display=="block")?"none":"block");
	}

	if(NN4x){
		location.href=url;
	}

	if(dom){
		objName=document.getElementById('submenu'+num).style;
		objName.display=((objName.display=="block")?"none":"block");
	}

}
function CloseNode(num,url){
	if(IE4x){
		objName=document.all['submenu'+num].style;
		objName.display="none";
	}

	if(NN4x){
		location.href=url;
	}

	if(dom){
		objName=document.getElementById('submenu'+num).style;
		objName.display="none";
	}
}

function checkZaps(form)
{
	_name = document.forms[form].elements['name'].value;
	_phone= document.forms[form].elements['tel'].value;

	if (_name == "")
	{
		alert('Введите Ваши фамилию, имя и отчество!');
		document.forms[form].elements['name'].focus();
		return false;
	}
 	else if (_phone == "")
	{
		alert('Введите номер контактного телефона!');
		document.forms[form].elements['tel'].focus();
		return false;
	}

	else return true;
}

// ---------Layer visibility-----------

function hideLayer(layer) {
	if (NN4x) document.layers[layer].visibility = "hide";
	if (IE4x || dom) document.all[layer].style.visibility = "hidden";}

function showLayer(layer) {
	if (NN4x) document.layers[layer].visibility = "show";
	if (IE4x || dom) document.all[layer].style.visibility = "visible";}