function brw() {
	var b=navigator.appName;
	if (b.indexOf('Netscape')!=-1) this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) {this.b="invalid"; this.invalid=true;}
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ie=(this.version.indexOf('MSIE')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	return;
}

var is = new brw();
var image_off = false;

function show_obj(obj){
    var result = "";
    for (var i in obj) {
        result += 'obj' + "." + i + " = " + obj[i] + "<br />\n";
    }
    document.write(result);
    //alert(result);
}


function hide_id(layer)
{
	try {
		l = document.getElementById(layer);
		l.style.display = "none";
	} catch(e){
	}
	try {
		l = document.getElementById(layer);
		l.style.visibility = "hidden";
	} catch(e){
	}
	return true;
}

function show_id(layer)
{
	try {
		l = document.getElementById(layer);
		l.style.display = "block";
	} catch(e){
	}
	try {
		l = document.getElementById(layer);
		l.style.visibility = "visible";
	} catch(e){
	}
	return true;
}

var shiftStat = false;

function go(url, target)
{
	if (!isNaN(target) && target || true == shiftStat) {
		if (is.ie) {
			document.body.focus();
		}
		window.open(url);
	} else {
		if ('' != url) {
			try {
				location.href = url;
			} catch(e) {
				location.replace(url);
			}
		}
	}
	return false;
}

function onkeydn(e) {
	with(window.event) {
		if (event.shiftKey) {
			shiftStat = true;
			return true;
		}
	}
	shiftStat = false;
	return false;
}
/*document.onkeydown = onkeydn;*/

nd = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;

if (nd) {
	if (nd.addEventListener) {
		nd.addEventListener("load", win_load, false);
	} else {
		if (nd.attachEvent) {
			nd.attachEvent("onload", win_load);
		}
	}
}

function get_top(id)
{
	var y, obj;
	if (is.ns4) {
		if (id.container != null) {
			return id.container.pageY + img.y;
		} else {
			return id.y;
		}
	} else {
		y = 0;
		obj = id;
		while (obj.offsetParent != null) {
			y += obj.offsetTop;
			obj= obj.offsetParent;
		}
		y += obj.offsetTop;
		return y;
	}
	return -1;
}

function get_left(id)
{
	var x, obj;
	if (is.ns4) {
		if (id.container != null) {
			return id.container.pageX + img.x;
		} else {
			return id.x;
		}
	} else {
		x = 0;
		obj = id;
		while (obj.offsetParent != null) {
			x += obj.offsetLeft;
			obj= obj.offsetParent;
		}
		x += obj.offsetLeft;
		return x;
	}
	return -1;
}


var winLoad = null;
var dbcw = 0;
function win_load()
{
	if (!image_off) {
		disable_img();
	}

	try {
		//document.body.attachEvent(document.body, "onresize", function x(){alert('test')}, true);
		//document.body.attachEvent("onload", function x(){alert('test')});
	} catch(e) {
		//alert(e.description);
	}
	dbcw = document.body.offsetWidth;

	winLoad = true;
	win_resize();
	return true;
}


today_big = 'информационно-развлекательный<BR />портал Набережные Челны';
today_mini= 'наш город в интернете<BR />Набережные Челны';


dmTimer = 0;
curMenu = null;
dmTimeOut = 500;
myTT = 0;
function sm(el)
{
	if (null == curMenu) {
		curMenu = el;
	} else {
		hide_id('m'+curMenu);
		curMenu = el;
	}

	show_id('m'+curMenu);
	dmTimer = dmTimeOut;
	return;
}

function timer_over()
{
	dmTimer = 10000000;
	clearTimeout(myTT);
	return;
}
function timer_out()
{
	dmTimer = dmTimeOut;
	myTT = setTimeout("timer()", 1500);
	return;
}
function timer()
{
	if (0 < dmTimer) {
		dmTimer -= 500;
		timer();
	} else {
		if (null != curMenu) {
			hide_id('m'+curMenu);
			curMenu = null;
		}
	}

	return;
}


/*function m(td, n)
{
	try {
		td = eval(td);
		switch(n)
		{
			case 0:
		    	td.firstChild.style.color = '#DA0000';
				break;
			case 1:
		    	td.firstChild.style.color = '#000000';
				break;
		}
	} catch(e) {}
	return false;
}*/


icoL1 = new Image();
icoL1.src='tpl/nd/img/img/ico3-logon.gif';


function postView(w, h, img, txt)
{
	var scrnx = screen.width/2 - w/2;
	var scrny = screen.height/2 - h/2;

	if (!txt || !isNaN(txt) || '' == txt) {
		window.open('../../../../?openImage&img='+escape(img),'popUp','width='+(w+90)+',height='+(h+106)+',scrollbars=no,menubar=no,toolbar=no,status=no,left='+scrnx+',top='+scrny);
	} else {
		window.open('../../../../?openImage&img='+escape(img)+'&text='+txt,'popUp','width='+w+',height='+h+',scrollbars=no,menubar=no,toolbar=no,status=no,left='+scrnx+',top='+scrny);
	}
	return false;
}

function openIMG(img, txt)
{
	var scrnx = screen.width-40;
	var scrny = screen.height-80;

	if (!txt || !isNaN(txt) || '' == txt) {
		window.open('../../../../?openImage&img='+escape(img),'popUp','width='+scrnx+',height='+scrny+',scrollbars=auto,menubar=no,toolbar=no,status=no,left=0,top=10');
	} else {
		window.open('../../../../?openImage&img='+escape(img)+'&text='+txt,'popUp','width='+scrnx+',height='+scrny+',scrollbars=auto,menubar=no,toolbar=no,status=no,left=0,top=10');
	}

	return false;
}

function form_reset(n, time)
{
	if ('undefined' == (typeof time)) {
		time = 500;
	}

	try {
		setTimeout("document.forms['"+n+"'].reset()", time);
	} catch(e) {
		alert(e.description);
	}

	return true;
}

function limit_sym(f)
{

	if ((255 - f.value.length) < 2) {
		f.value = f.value.substring(f.value, 255);
		document.getElementById('limitsym').innerHTML = ' не осталось';
		return false;
	}

	sym = ((254 - f.value.length) < 100)?  (254 - f.value.length)+'&nbsp;' : 254 - f.value.length;
	document.getElementById('limitsym').innerHTML = 'осталось ' + sym;

	return true;
}

mchat = true;
function clear_one(obj)
{
	if (mchat) {
		obj.value = '';
		mchat = false;
	}
	return;
}

function simple_popup(url)
{
	var x = (document.body.offsetWidth / 2) - 300;
	var h = document.body.offsetHeight;

	winpopup= window.open('../../../../'+url, "SimplePopUp", "width=400,height="+(h-60)+",scrollbars,resizable,left="+x+",top=15");

	winpopup.focus();

	return;
}

function show_auth_form(id, w, h)
{
	var scrnx = screen.width/2 - w/2;
	var scrny = screen.height/2 - h/2;

	document.getElementById(id).style.top = scrny + 'px';
	document.getElementById(id).style.left= scrnx + 'px';

	show_id(id);
	return true;
}


function xclick(x,y)
{

$.ajax({
	type:"GET",
	url:"/tpl/b-cv.php",
	data: "x="+x+"&y="+y+"&baner_click=true",
	success: function(msg){}
});

return;
	if (is.ie) {
		try {req = new ActiveXObject('Msxml2.XMLHTTP');} catch (e) {}
		if (!req) try {	req = new ActiveXObject('Microsoft.XMLHTTP');} catch (e) {}
	} else {
		try {
			req = new XMLHttpRequest();
		} catch(e){}
	}

	if (req) {
		try {
			req.open("POST", "../../index.php", false, null, null);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send("x="+x+"&y="+y+"&baner_click=true");
		} catch(e){}
	}

	return false;
}

function trOv(tr)
{
	for (i=-1;++i<tr.childNodes.length;) {
		tr.childNodes[i].style.borderBottom = '#C4C4CB 1px solid';
	}
	return;
}

function trOu(tr)
{
	for (i=-1;++i<tr.childNodes.length;) {
		tr.childNodes[i].style.borderBottom = '#ffffff 1px solid';
	}
	return;
}


var miniChatU = false;
function updiframemch()
{
	try {
		if (document.getElementById('checkmchatu').checked) {
			document.getElementById('mini_chat').src = '/mini-chat/';
			miniChatU = setTimeout("updiframemch()", 15000);
		} else {
			if (false !== miniChatU) {
				clearTimeout(miniChatU);
				miniChatU = false;
			}
		}
	} catch(e){}
	return;
}
function setminiupd(c)
{
	try {
		if (c.checked) {
			miniChatU = setTimeout("updiframemch()", 500);
		} else {
			if (false !== miniChatU) {
				clearTimeout(miniChatU);
				miniChatU = false;
			}
		}
	}catch(e){}
	return;
}

/* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 * Version 2.1 Copyright Paul Johnston 2000 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; var b64pad = ""; var chrsz = 8; function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));} function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function str2binb(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); return bin; } function binb2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); } return str; } function sha1_kt(t) { return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514; } function sha1_ft(t, b, c, d) { if(t < 20) return (b & c) | ((~b) & d); if(t < 40) return b ^ c ^ d; if(t < 60) return (b & c) | (b & d) | (c & d); return b ^ c ^ d; } function core_sha1(x, len) { /* append padding */ x[len >> 5] |= 0x80 << (24 - len % 32); x[((len + 64 >> 9) << 4) + 15] = len; var w = Array(80); var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; var e = -1009589776; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; var olde = e; for(var j = 0; j < 80; j++) { if(j < 16) w[j] = x[i + j]; else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j))); e = d; d = c; c = rol(b, 30); b = a; a = t; } a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); e = safe_add(e, olde); } return Array(a, b, c, d, e); } function rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }

function goBan(url, m){return true;}


function dirAb(n)
{
	var x = parseInt(document.body.offsetWidth / 2) - 400;
	var h = parseInt(document.body.offsetHeight / 2);

	winpopup= window.open('/?directory='+n, "_dir", "width=700,height="+h+",scrollbars,resizable,left="+x+",top=15");

	winpopup.focus();

	return;
}

var winop = function(u, t)
{
	var scrnx = screen.width-40;
	var scrny = screen.height-80;
	window.open(u, '_'+t, 'width='+scrnx+',height='+scrny+',');
	return false;
}

var cssFix = function(){
  var u = navigator.userAgent.toLowerCase(),
  addClass = function(el,val){
    if(!el.className) {
      el.className = val;
    } else {
      var newCl = el.className;
      newCl+=(" "+val);
      el.className = newCl;
    }
  },
  is = function(t){return (u.indexOf(t)!=-1)};
  addClass(document.getElementsByTagName('html')[0],[
    (!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1) //'
      :is('firefox/2')?'gecko ff2'
      :is('firefox/3')?'gecko ff3'
      :is('gecko/')?'gecko'
      :is('chrome/')?'chrome'
      :is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1	 //'
      :is('konqueror')?'konqueror'
      :is('applewebkit/')?'webkit safari'
      :is('mozilla/')?'gecko':'',
    (is('x11')||is('linux'))?' linux'
      :is('mac')?' mac'
      :is('win')?' win':''
  ].join(" "));
}();


var $gorod3d = {
	tvnews: {
		active: false,
		index: 0,
		blog: [],
		count: 0
	}
};

document.write('<script type="text/javascript" src="http://www.gorod3d.ru/public/api/tvnews.js"><\/script>');
function gorod3d_tvnews()
{
	if (!$gorod3d.tvnews.active) {
		if ($('#gorod3dTVNews').length) {
			$gorod3d.tvnews.active = true;
		} else {
			return false;
		}
	}

	if (0 == $gorod3d.tvnews.count) {
		$gorod3d.tvnews.count = $gorod3d.tvnews.blog.length;
	}

	if ($gorod3d.tvnews.count == ++$gorod3d.tvnews.index) {
		$gorod3d.tvnews.index = 0;
	}

	$('img', '#gorod3dTVNews').attr('src', 'http://www.gorod3d.ru' + $gorod3d.tvnews.blog[$gorod3d.tvnews.index].post_thumb);
	$('a', '#gorod3dTVNews')
		.attr('title', $gorod3d.tvnews.blog[$gorod3d.tvnews.index].post_name)
		.attr('href', 'http://www.gorod3d.ru/tvnews/blog/our-city/'+$gorod3d.tvnews.blog[$gorod3d.tvnews.index].post_id);

	setTimeout("gorod3d_tvnews()", 3500);
	return;
}

