var curSub = false;
var curTimer = false;
var curIdx = 5;
var curCat = false;

function msel_popup(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		//temp.className = "mis";
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			temp.className = "ms_popup";
			temp.style.zIndex = curIdx;
			curIdx++;
			if (id == curSub) if (curTimer) window.clearTimeout(curTimer);
		}
	}
}
function msel(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp.className = "mis";
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			temp.className = "ms";
			temp.style.zIndex = curIdx;
			curIdx++;
			if (id == curSub) if (curTimer) window.clearTimeout(curTimer);
		}
	}
}
function msell(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp.className = "mis";
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			temp.className = "mms";
			temp.style.zIndex = curIdx;
			curIdx++;
			if (id == curSub) if (curTimer) window.clearTimeout(curTimer);
		}
	}
}

function munsel(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			curSub = id;
			curTimer = window.setTimeout("mhide(\"" + id + "\")",300);
			return true;
		}
		document.getElementById(id).className = "mi";
	}
}
function munsel_popup(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			curSub = id;
			curTimer = window.setTimeout("mhide_popup(\"" + id + "\")",300);
			return true;
		}
		document.getElementById(id).className = "mi";
	}
}
function mhide_popup(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		//temp.className = "mi";
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			temp.className = "hi";
		}
	}
}

function mhide(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp.className = "mi";
		temp = document.getElementById(id + "c");
		if (temp) if (temp.innerHTML)
		{
			temp.className = "hi";
		}
	}
}

function mstay()
{
	if (curTimer)
	{
		window.clearTimeout(curTimer);
	}
}

function mitem(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp.className = "msis";
	}
}

function munitem(id)
{
	var temp = document.getElementById(id);
	if (temp)
	{
		temp.className = "msi";
	}
}

function toggleCat(elem,lv,pid)
{
	if (elem.src == document.images["op"].src)
	{
		elem.src = document.images["cl"].src;
		var id = elem.id.substr(1);
		var temp = document.getElementById("c" + id);
		if (temp.innerHTML) temp.className = "hi";
		if (lv == 1) curCat = false;
	}
	else
	{
		elem.src = document.images["op"].src;
		var id = elem.id.substr(1);
		var temp = document.getElementById("c" + id);
		if (temp.innerHTML) temp.className = "l" + lv + "c";
		if (lv == 1)
		{
			if (curCat && curCat != pid) toggleCat(document.getElementById(curCat),1);
			curCat = elem.id;
		}
	}
}

function votefor(id)
{
	if (id != document.forms["vote"].elements["curvote"].value)
	{
		var temp = document.images["p" + id].src;
		document.images["p" + id].src = document.images["p" + document.forms["vote"].elements["curvote"].value].src;
		document.images["p" + document.forms["vote"].elements["curvote"].value].src = temp;
		document.forms["vote"].elements["curvote"].value = id;
	}
}

function autores(elem)
{
	if (elem.value == elem.defaultValue) elem.value = "";
}

function checkSub(form)
{
	var temp = /^([a-z]|[0-9])([a-z]|[0-9]|_|-|\.)*([a-z]|[0-9]|_|-)@(([a-z]|[0-9])([a-z]|[0-9]|_|-)*\.)+[a-z]{2,4}$/i;
	if (!temp.test(form.elements["mail"].value))
	{
		alert("Пожалуйста, правильно введите свой e-mail");
		return false;
	}
	return true;
}

function checkSearch(event)
{
	if (event.clientX > 810 && event.clientY > 80 && event.clientY < 100) document.forms["se"].elements["word"].focus();
}

function checkOrd(form)
{
	var temp = /^([a-z]|[0-9])([a-z]|[0-9]|_|-|\.)*([a-z]|[0-9]|_|-)@(([a-z]|[0-9])([a-z]|[0-9]|_|-)*\.)+[a-z]{2,4}$/i;
	if (!temp.test(form.elements["email"].value))
	{
		alert("Пожалуйста, правильно введите свой e-mail");
		return false;
	}
	if (!form.elements["phone"].value)
	{
		alert("Пожалуйста, введите свой телефон");
		return false;
	}
	return true;
}

function checkFeed(form)
{
	if (!form.elements["asker"].value)
	{
		alert("Пожалуйста, представьтесь");
		return false;
	}
	if (!form.elements["quest"].value)
	{
		alert("Пожалуйста, введите свой отзыв");
		return false;
	}
	if ((form.elements["quest"].value.toUpperCase().indexOf("HREF") < 0) || (form.elements["quest"].value.indexOf("<") == form.elements["quest"].value.indexOf(">")))
	{
		alert("Извините, вставлять в отзыв ссылки и тэги HTML запрещено!");
		return false;
	}
	return true;
}

function checkEml(form)
{
	var temp = /^([a-z]|[0-9])([a-z]|[0-9]|_|-|\.)*([a-z]|[0-9]|_|-)@(([a-z]|[0-9])([a-z]|[0-9]|_|-)*\.)+[a-z]{2,4}$/i;
	if (!temp.test(form.elements["email"].value))
	{
		alert("Пожалуйста, правильно введите свой e-mail");
		return false;
	}
	if (!form.elements["cont"].value)
	{
		alert("Пожалуйста, введите текст письма");
		return false;
	}
	return true;
}
function openw(res) {
   window.open(path + "/lib/show_pic.php?src="+res, null, "top=20, left=40, width=50, height=50, channelmode=no, toolbar=no, location=no, status=no, directories=no, menubar=no, resizable=yes");
}