//////////////////////////////////////////////////////////////////////////
// Закодированный редирект                                              //
//////////////////////////////////////////////////////////////////////////

function encoded_redirect( base64_encoded_url )
{
	eval(Base64.decode("ZG9jdW1lbnQubG9jYXRpb249") + "'" + Base64.decode(base64_encoded_url) + "'");
}






function on_input( input )
{
	var old_value = input.getAttribute("old_value");
	var new_value = input.value;
	
	input.setAttribute("old_value", new_value);
	
	//alert(old_value);
	
	if ( new_value.length > old_value.length + 1 ) input.setSelectionRange(0, 0);
}

function get_browser_name() {
	 var ua = navigator.userAgent.toLowerCase();
	 // Определим Internet Explorer
	 if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
	   return "msie"
	 }
	 // Opera
	 if (ua.indexOf("opera") != -1) {
	   return "opera"
	 }
	 // Gecko = Mozilla + Firefox + Netscape
	 if (ua.indexOf("gecko") != -1) {
	   return "gecko";
	 }
	 // Safari, используется в MAC OS
	 if (ua.indexOf("safari") != -1) {
	   return "safari";
	 }
	 // Konqueror, используется в UNIX-системах
	 if (ua.indexOf("konqueror") != -1) {
	   return "konqueror";
	 }
	 return "unknown";
	}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

var oldW = null;
var oldH = null;

function checkPos()
{
	var W = f_clientWidth();
	var H = f_clientHeight();
	
	if ( W != oldW || H != oldH )
	{
		var bgL = Math.round((W - 1446) / 2);
		var bgT = Math.round((H - 1166 - 70) / 2) + 70;
		
		document.body.style.backgroundPosition = bgL + 'px ' + bgT + 'px';

		
		if ( oldW === null )
		{
			document.body.style.backgroundImage = 'url(/layouts/public/main/bg.jpg)';
			document.body.style.backgroundRepeat = 'no-repeat';
		}
	
		oldW = W;
		oldH = H;
	}
	
	setTimeout('checkPos()', 100);	
}
