function getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		 / THIRD FUNCTION
		 * getPageScroll() by quirksmode.com
		 *
		 * @return Array Return an array with x,y page scroll values.
		 */
		function getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:window.innerHeight;
}


function BodySize()
{
var width = document.body.clientWidth; // ширина 
var height = document.body.clientHeight; // высота

return {"width":width, "height":height};
}




function show_popup_window(title,href,height)
{	
    top.$_js('popup_frame').height=height;
	top.$_js('popup_frame').src = href;
		
	top.$_js('popup_window_title').innerHTML = title;
	
	
//    top.alert(getClientHeight());
    top.$_js('popup_window').style.top=(getClientHeight()/2+getPageScroll()[1]-240) + 'px';
    
    top.$_js('popup_window').style.display = 'block';
	top.$_js('popup_window_back').style.display = 'block';
//	
	
	top.$_js('popup_window_back').style.height = getPageSize()[1] + 'px';
	top.$_js('popup_window_back').style.width = document.body.clientWidth + 'px';
	
    
//	$_js('popup_window').style.height = Math.round(BodySize().height*0.7) + 'px';
}
function hide_popup_window()
{
	top.$_js('popup_window_back').style.display = 'none';
	top.$_js('popup_window').style.display = 'none';
}


function is_array( mixed_var ) {
  return ( mixed_var instanceof Array );  
}

function remove_input_value(obj,text)
{
	if(obj.value==text)
	{
		obj.value='';
	}
}
function add_input_value(obj,text)
{
	if(obj.value=='')
	{
		obj.value=text;
	}
}

// ИСПОЛЬЗОВАТЬ ВМЕСТО getElementById() ФУНКЦИЮ $() (может отдать массив элементов, если передать несколько id)
function $_js() 
{
	var elements, i;

	if(arguments.length == 1)
		return document.getElementById(arguments[0]);

	elements = new Array();
	for(i=0; i<arguments.length; i++) 
		elements.push(document.getElementById(arguments[i]));

	return elements;
}

// ПОКАЗАТЬ/СКРЫТЬ АНИМАШКУ "ЗАГРУЗКА"
function showLoad(visible)
{
	if(visible==null)
		visible = true;
	try {
		var _img = top.document.getElementById("imgLoad");
		_img.style.visibility = visible ? "visible" : "hidden";
	}
	catch(e) {}  
}
// ВЫЗОВ ФУНКЦИИ history.back() ПОСЛЕ РАБОТЫ ФРЕЙМА
function topBack(post) // post - страница дергалась формой (иначе - ссылкой)
{
//	showLoad(false);
	switch(userNavigator())
	{
		case "isChrome":
			if(post)
				history.back();
			break;
		
		default:
			history.back();
			break;
	}
}

// ПЕРЕДАЕМ URL ВО ФРЕЙМ
function toajax(url)
{
	//frames["ajax"].document.location.href = url;
	showLoad(true);
	top.$("#ajax").attr('src',url);
}

// ОТКРЫВАЕТ СТРАНИЦУ В ОТДЕЛЬНОМ ОКНЕ
function openWindow(width,height,url,target)
{
/*
	width	размер в пикселах	ширина нового окна
	height	размер в пикселах	высота нового окна
	left	размер в пикселах	абсцисса левого верхнего угла нового окна
	top	размер в пикселах	ордината левого верхнего угла нового окна
	toolbar	1 / 0 / yes / no	вывод панели инструменов
	location	1 / 0 / yes / no	вывод адресной строки
	directories	1 / 0 / yes / no	вывод панели ссылок
	menubar	1 / 0 / yes / no	вывод строки меню
	scrollbars	1 / 0 / yes / no	вывод полос прокрутки
	resizable	1 / 0 / yes / no	возможность изменения размеров окна
	status	1 / 0 / yes / no	вывод строки статуса
	fullscreen	1 / 0 / yes / no	вывод на полный экран
*/ 
	if(!target) target = 'my';
	var left = Math.round((screen.width-width)/2);
	var top = Math.round((screen.height-height)/2)-40;
	var win = window.open(url, target, 'resizable=yes,width='+width+',height='+height+',scrollbars=1,top='+top+',left='+left);
	win.focus();
	// Пример:
	// <a href="page.htm" target="my" onClick="openWindow(570,700)">открыть</a>
}

// ПЕРЕЗАГРУЗИТЬ СТРАНИЦУ ПОСЛЕ РАБОТЫ ФРЕЙМА
function topReload()
{
	switch(userNavigator())
	{
		case "isOpera":
		case "isChrome":
			history.go(0);
			break;
		
		case "isGecko":
			history.back();
			setTimeout("top.location.reload(true)",500);
			break;
		
		default:
			history.back();
			history.go(0);
			break;
	}
}
// ОПРЕДЕЛЕНИЕ ТИПА БРАУЗЕРА
function userNavigator()
{
	// Получим userAgent браузера и переведем его в нижний регистр 
	var ua = navigator.userAgent.toLowerCase(); 
	// Определим Internet Explorer 
	if( (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) )
		return "isIE";
	// Opera 
	if( (ua.indexOf("opera") != -1) )
		return "isOpera";
	// Chrome
	if( (ua.indexOf("chrome") != -1) ) 
		return "isChrome";
	// Gecko = Mozilla + Firefox + Netscape 
	if( (ua.indexOf("gecko") != -1) ) 
		return "isGecko";
	// Safari, используется в MAC OS 
	if( (ua.indexOf("safari") != -1) ) 
		return "isSafari";
	// Konqueror, используется в UNIX-системах 
	if( (ua.indexOf("konqueror") != -1) ) 
		return "isKonqueror";

	return false;
}
// ВЫДЕЛЕНИЕ ЧЕКБОКСОВ "ГЛАВНЫМ" ЧЕКБОКСОМ В ТАБЛИЦЕ
function setCbTable(obj) // checkbox
{

	var table, tr, td, j, i, input;
	td = obj.parentNode;
	i = td.cellIndex; // индекс td в которой checkbox
	table = td.parentNode.parentNode;
	tr = childNodes(table);
	for(j=1; j<tr.length; j++)
	{
		try {
			td = childNodes(tr[j]);
			input = td[i].getElementsByTagName("INPUT");
			input[0].checked = obj.checked;
		}
		catch(e) {}
	}
}

// ПОЛУЧЕНИЕ ПОТОМКОВ (childNodes) ОПРЕДЕЛННОГО ЭЛЕМЕНТА, БЕЗ МУСОРА
function childNodes(obj)
{
	var i, j, childNodes, _childNodes = new Array();
	childNodes = obj.childNodes;
	j = 0;
	for(i in childNodes)
		if(childNodes[i].nodeType == 1)
			_childNodes[j++] = childNodes[i];
	return _childNodes;
}

function toggleDiv()
{
	var el;
	var args=toggleDiv.arguments;
	for(var i=0;i<args.length;i++)
	{
		el=document.getElementById(args[i]);
		if(el) el.style['display']=el.style['display']=='block'?'none':'block';
	}
}
