var	isIE = false,
	isNS = false,
	isFirefox = false,
	isOpera = false;
//isIE = navigator.appName == "Microsoft Internet Explorer";
//isNS = navigator.appName == "Netscape";
if (!(isOpera = navigator.userAgent.search(/opera/i) != -1))
	if(!(isFirefox = navigator.userAgent.search(/firefox/i) != -1))
		if(!(isNS = navigator.userAgent.search(/netscape/i) != -1))
			isIE = navigator.userAgent.search(/msie/i) != -1;
//if (document.all)
//	isIE = true;
if (document.layers)
	isNS = true;
appVers = navigator.appVersion;
if (isIE)
	ieVers = parseFloat(appVers.substr(appVers.indexOf("MSIE") + 4));
//if (!isIE || ieVers < 5)
//	alert("Данный сайт рекомендуется просматривать в \"Microsoft Internet Explorer\", версии 5.0 или новее."
//		+ "\nPlease use \"Microsoft Internet Explorer 5.0\" or later for properly looking this site.");
if (isIE)//
	scrVers = ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion();
isNT = (i = appVers.indexOf(str = "Windows NT")) > -1;
if (isNT)
	ntVers = parseFloat(appVers.substr(i + str.length));
if (appVers.indexOf("Windows 2000") > -1)
{
	isNT = true;
	ntVers = 5;
}
appVers = parseFloat(appVers);

tatCode=[0x496,0x497,0x4a2,0x4a3,0x4ae,0x4af,0x4ba,0x4bb,0x4d8,0x4d9,0x4e8,0x4e9];

function Chars(o)
{
	if (GetCookie("chars") == "latin")
	{
		o.document.title = CyrToLat(o.document.title);
		o.document.body.innerHTML = CyrToLat(o.document.body.innerHTML);
	}
}

function CyrToLat(str)
{
	for (var c=0x410; c<=0x44f; ++c)
		eval("str = str.replace(/" + String.fromCharCode(c) + "/g,'" +
			parent.latin[c - 0x410] + "')");
	for (var i=0; i<tatCode.length; ++i)
		eval("str = str.replace(/" + String.fromCharCode(tatCode[i]) + "/g,'" +
			parent.latin[64 + i] + "')");
	return str;
}

function SetBrwSsnCookie(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue);
}

function SetCookie(sName, sValue)
{
	var date = new Date(4000, 0, 0);
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
}

function GetCookie(sName)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
		{
			var ret = unescape(aCrumb[1]);
			switch (ret.toLowerCase())
			{
			case "undefined":
				return "";
			case "false":
				return false;
			case "true":
				return true;
			}
			return ret;
		}
	}
	return null;
}

function getClientHeight(w)
{
	if (isIE)
		return w.document.body.clientHeight;
	return w.window.innerHeight;
}

function getClientWidth(w)
{
	if (isIE)
		return w.document.body.clientWidth;
	return w.window.innerWidth;
}

function onResponse(doc, q)
{
	doc.getElementById("writeBtn").style.display = "none";
	var writeFrm = doc.getElementById("writeFrm");
	writeFrm.style.display = "block";
	writeFrm.src = "response.html?" + q;
	writeFrm.scrollIntoView(false);
}

