function browseIt()
{
	this.ver = navigator.appVersion.toLowerCase();
	this.agent = navigator.userAgent.toLowerCase();
	this.dom = document.getElementById ? 1 : 0;
	this.opera = (navigator.userAgent.indexOf("opera")>-1 && document.getElementById) ? 1 : 0;
	this.opera7 = (this.opera && parseInt(navigator.appVersion) >= 7);
	this.ie = (this.ver.indexOf("msie") > -1 && this.dom && !this.opera) ? 1 : 0;
	this.macOS = this.agent.indexOf("mac") > -1;
	this.mac = (this.macOS && parseInt(this.ver) >= 7) ? 1 : 0;
	this.moz = (this.agent.indexOf("gecko")>-1)
	this.ns6 = (this.dom && this.agent.indexOf("netscape")>-1 && parseInt(this.ver) >= 5) ? 1 : 0;
	this.b = (this.ie || this.ns6 || this.opera7 || this.mac || this.moz || this.dom);
	return this;
}

function makeObj(obj)
{
	this.elem = document.getElementById(obj);
   	this.css = this.elem ? this.elem.style : null;
	return this;
}

var px = window.opera ? "" : "px";
var b = new browseIt();

function previewIt(href, wW, wH)
{
	var wW = (!wW)? 100 : wW;
	var wH = (!wH)? 100 : wH;
	var winl = (screen.width - wW) / 2;
	var wint = (screen.height - wH) / 2;
	var winprops = navigator.appName == "Netscape" ? 'height='+wH+',width='+wW+',top='+wint+',left='+winl+',toolbar=no,'+'location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes' : 'height='+wH+',width='+wW+',top='+wint+',left='+winl+',toolbar=no,'+'location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes';
	var win = window.open(sp, 'popup', winprops);
	if (parseInt(navigator.appVersion) >= 4)
		win.window.focus();
}

function showFloatForm(act, formAct)
{
	var oTmp = new makeObj("mainFloatForm");
	var oTmp1 = new makeObj("floatForm");
	if (!oTmp.elem || !oTmp1.elem)
		return true;
	var oTmpW = 400;
	var sW = (!b.ie) ? self.innerWidth : self.document.body.offsetWidth;
	oTmp.css.width = oTmp1.css.width = oTmpW + px;
	oTmp.css.left = (sW - oTmpW)/2 + px;
	oTmp.css.top = document.body.scrollTop + parseInt(sW * 0.07);
	if (act) {
		oTmp.css.display = 'none';
		toggleDisplay('SELECT', 'visible');
		toggleDisplay('OBJECT', 'visible');
		toggleDisplay('EMBED', 'visible');
	} else {
		if(b.ns6 && !b.opera) return true;
		oTmp.css.display = 'block';
		toggleDisplay('SELECT', 'hidden');
		toggleDisplay('OBJECT', 'hidden');
		toggleDisplay('EMBED', 'hidden');
			document.forms.login.url.value = formAct ? formAct : '';
			setTimeout("document.forms.login.login.focus();", 100);
	}

	return false;
}

function toggleDisplay(tag, value)
{
	var sel = document.getElementsByTagName(tag);
	for (var i = 0; i < sel.length; i++)
		sel[i].style.visibility = value;
}

function echoLoginForm(dom, img, auth) {
	var el = new makeObj('mainFloatForm');
	if (!el.elem)
		return;
	el.elem.innerHTML = '<table cellspacing="0" cellpadding="0" id="floatForm" onkeyup="if(event.keyCode==27)showFloatForm(1)">' +
	'<tr><td colspan="2" class="floatFormHeader"><span>Ваш паспорт</span><img src="' + img + 'img/close_.gif" width="16" height="14" border="0" onclick="showFloatForm(1);" class="close"></td></tr>' +
	'<tr><td class="tdRight">Логин</td><td><input type="hidden" name="rnd"/><input type="hidden" name="url"/><input type="text" name="login" size="13" class="width100pc" onchange="this.form.rnd.value=Math.random();"/></td></tr>' +
	'<tr><td class="tdRight">Пароль</td><td><input type="password" name="pass" size="13" maxlength="32" class="width100pc" onchange="this.form.rnd.value=Math.random();"/><br>Пароль есть, но Вы его <a href="http://passport' + dom + '/remind/">забыли?</a><hr noshade size="1"><!-- если будет фича "чужого компьютера" - разремить строку --><input id="auth_type" type="checkbox" name="auth_type" value="1">&nbsp;<label for="auth_type" class="fixed11px">Запомнить меня на две недели.</label><hr noshade size="1"><br><input type="submit" name="subm" value="Войти">&nbsp;<input type="button" value="Закрыть" onclick="showFloatForm(1);" id="darkgrey">' +
	(auth ? '' : '<br><br><hr noshade size="1">Пройдите авторизацию. Впервые на сайте &mdash; <a href="http://passport' + dom + '/registration/">зарегистрируйтесь</a>!') +
	'<div class="spacer" style="height:0.5em"><spacer></div></td></tr></table>';
}

function titleMe(src)
{
	src.title = t ? 'Спрятать все разделы' : 'Показать все разделы';
}

function trim(s, p)
{
	if (typeof s != 'string')
		return s;
	return s.replace(p ? p : /^\s*|\s*$/g, '');
}

function stripTags(str)
{
	return str.replace(/(<([^>]*)>)/g, '');
}

function checkAll(val, p)
{
	if (!p)
		p = document.body;

	var arr = p.getElementsByTagName('INPUT');
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].type == 'checkbox')
			arr[i].checked = val;
	}
}

function _fp()
{
	if (parent && parent != window)
		parent.location.href = window.location.href;
}

function my_confirm() 
{
	if (confirm("Are you sure?")) 
	{
		return true;
	}

	return false;
}
	   
function show_alert_message_box(message)
{
	alert(message)
}
