function getParam(key) {
	var value = undefined;
	var query = location.search;
	var pairs = query.substr(1).split('&');
	for (var index in pairs)
	{
		var pair = pairs[index].split('=');
		if (pair[0] == key)
			value = pair[1];
	}
	return value;
}
/*
function center(el)
{
	var screenWidth = document.body.clientWidth;
	//var screenHeight = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));

	var pr = el.css("padding-right");
	var pl = el.css("padding-left");
	//var pt = el.css("padding-top");
	//var pb = el.css("padding-bottom");

	var width = el.width() + parseInt(pl) + parseInt(pr);
	//var height = el.height() + parseInt(pt) + parseInt(pb);
	
	var left = Math.floor((screenWidth - width)/2);
	//var top = Math.floor((screenHeight - height)/2);
	el.css("left", left);		
	//el.css("top", top);
}
*/
/*
//������� ��������� ������ input �� 2 ������ �������.
//��� ���� ����� ����������� � col1_text � col2_text, ������� ���������
//� �������� col1 � col2 (colN_text ����� ���� ����� colN).
//testcol - ���������� ������� �������, �� �������� ����� ����������
//�� ������� ������ (�������� testcol = colN).
function splitTextToColumns(input, testcol, col1_text, col2_text, col1, col2)
{
	//������� ���� ����� � ����� �������.
	var t1 = input;
	var t2 = "";
	col1_text.html(t1);
	col2_text.html(t2);

	//��������, ��� ��� ���� ������ �����������.
	var maxHeight = testcol.height();
	
	//������� "��-������" ��������� ��������� ������� ��� "������", �� ������� ���������.
	var len = input.length;
	var n = 8;
	var lastPos = 0;
	var pos = 0;
	var height = 0;
	var lastHeight = null;
	var smartPos = 0;
	for (var i = 0; i <= n && smartPos == 0; i++ )
	{
		pos = Math.floor(4*len/(8+i));
		
		t1 = input.substring(0, pos);
		t2 = input.substring(pos + 1);
		col1_text.html(t1);
		col2_text.html(t2);
		height = testcol.height();
		
		//���� ��� ����� ��������� (�������) ������� ������ ������,
		//������ ������� ������� ������ ���������. ����� ��� ��� ��������.
		if ( lastHeight != null && height > lastHeight )
			smartPos = pos;

		lastHeight = height;
		lastPos = pos;
	}
	
	//������������� ��� "������" ���������.
	lastPos = 0;
	pos = smartPos;
	lastHeight = maxHeight;
	//���� ���� ���������� ������� ���������.
	while ( pos != -1 )
	{
		//���� ����������, ��� ������ ������� ����� ������ ������
		//��� ������� ���������.
		var lastFlag = col1.height() >= col2.height();

		//��������� ����� �� ��������� �������.
		t1 = input.substring(0, pos);
		t2 = input.substring(pos + 1);
		col1_text.html(t1);
		col2_text.html(t2);
		//��������� ������.
		height = testcol.height();

		//���� ��������� ������ ������ � ������ ������� ������ ������,
		//�� ���������� ������������� ������� - ���������!
		if ( height > lastHeight && lastFlag)
			break;

		//���������� �������� ������� �������� ��� ���������.
		lastHeight = height;
		lastPos = pos;
		
		//������� ��������� ���������� �������.
		var p = t2.search(/\s/);
		pos = ( p != -1 ) ? (pos + 1) + p : -1;
	}
	
	//��������, ���� �� ����� ���������� ������� � ��������� ����� � ������ �������.
	if ( lastPos == 0 )
	{
		col1_text.html(input);
		col2_text.empty();
		return false;
	}
	
	//��������� ����� �� ������� � �������� �� ������.
	col1_text.html(input.substring(0, lastPos));
	col2_text.html(input.substring(lastPos + 1));
	return true;
}
*/
function CheckLang(lang)
{
	var n = navigator;
	var systemLang = n.language ? n.language : n.browserLanguage ? n.browserLanguage : null; 
	var userLang = n.userLanguage ? n.userLanguage : n.systemLanguage ? systemLanguage : null;
	lang = lang.toLowerCase();
	if ( systemLang != null && systemLang.toLowerCase().indexOf(lang) != -1 )
		return true;
	if ( userLang != null && userLang.toLowerCase().indexOf(lang) != -1 )
		return true;
	return false;
}

function IsIE6OrLow() {
	if ($.browser.msie) {
		var version = jQuery.browser.version;
		var vers = version.split('.');
		if ( vers.length >= 1 && parseInt(vers[0]) <= 6 )
			return true;
	}
	return false;
}

function IsIE7() {
	if ($.browser.msie) {
		var version = jQuery.browser.version;
		var vers = version.split('.');
		if ( vers.length >= 1 && parseInt(vers[0]) == 7 )
			return true;
	}
	return false;
}

function WaitForObject(obj, handler, maxWait)
{
	if ( typeof(obj) == "string" )
		obj = $(obj);
	
	if ( maxWait == 0 ) {
		handler(obj);
		return;
	}
	
	var imgs = $('img', obj);
	var total = imgs.length;
	if ( total == 0 ) {
		handler(obj);
		return;
	}
	
	var onTimer = function() {
		imgs.unbind('load', onResult);
		handler(obj);
	};
	
	var onResult = function () {
		var count = parseInt(obj.attr('waiting'));
		if ( count == 1 ) {
			if ( timer != null )
				clearTimeout(timer);
			handler(obj);
		}
		else
			obj.attr('waiting', count-1);
	};
	
	var timer = ( maxWait > 0 ) ? window.setTimeout(onTimer, maxWait) : null;
	
	obj.attr('waiting', total);
	imgs.load(onResult);
	imgs.error(onResult);
}