/*	браузер */

var clientWidth = 0;
var clientHeight =0;
var scrollLeft = 0;
var scrollTop = 0;

var vistime = 0;
var timestart = new Date();
var screenw = screen.availWidth;
var screenh = screen.availHeight;
var offset = (navigator.userAgent.indexOf("Mac") != -1 || navigator.userAgent.indexOf("Gecko") != -1 ||navigator.appName.indexOf("Netscape") != -1) ? 0 : 4;

_dom = document.all?3:(document.getElementById?1:(document.layers?2:0));

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}


function getScreen(){
	var dim = new Array();
	if(_dom == 0)
	{
		dim["w"] = parseInt(window.innerWidth);
		dim["h"] = parseInt(window.innerHeight);
		scrollLeft = parseInt(window.pageXOffset)-44;
		scrollTop = parseInt(window.pageYOffset);
	} else {
		if(_dom == 1)
		{
			dim["w"] = parseInt(window.innerWidth);
			dim["h"] = parseInt(window.innerHeight);
			scrollLeft = parseInt(window.pageXOffset)-14;
			scrollTop = parseInt(window.pageYOffset);
		} else {
			dim["w"] = iecompattest().clientWidth;
			dim["h"] = iecompattest().clientHeight;
			scrollLeft = iecompattest().scrollLeft;
			scrollTop = iecompattest().scrollTop;
		}
	}
 /*
		if(navigator.userAgent.indexOf('Opera') > 0){
			dim["w"] = parseInt(window.innerWidth);
			dim["h"] = parseInt(window.innerHeight);
			scrollLeft = parseInt(window.pageXOffset)-44;
			scrollTop = parseInt(window.pageYOffset);	
		}*/
	return dim;
}


function getMouse( evt ){
	var mouse = new Array();
	evt = (evt) ? evt : ((window.event) ? event : null );

	if( evt.x || evt.y )
	{
		mouse["x"] = evt.x;
		mouse["y"] =  evt.y;
	} else {
		mouse["x"] = evt.clientX + document.body.scrollLeft; 
		mouse["y"] =  evt.clientY + document.body.scrollTop;
	}
	return mouse;
}


var info =	{
					'appname':navigator.appName,
					'appversion':navigator.appVersion,
					'lang':navigator.language,
					'cook':navigator.cookieEnabled,
					'platform':navigator.platform,	
					'java':navigator.javaEnabled(),
					'sw':screen.width,
					'sh':screen.height
				};




/*  корреляции */
if(_dom == 3 && navigator.userAgent.indexOf('Opera') ==-1){
	info['lang'] = window.clientInformation.userLanguage;
}
if(_dom == 0){
	info['appname'] = 'Netscape';
}
if(_dom == 1){
	info['appname'] = 'Mozilla';
	if(navigator.userAgent.indexOf('Firefox') > 0)	 	info['appname'] = 'Mozilla Firefox';
}
if(navigator.userAgent.indexOf('Opera') > 0){
	info['appname'] = 'Opera';	
}


/*	иницилизация */
function init(evt){
		evt = (evt) ? evt : ((window.event) ? event : null );
		var dim_xy = getScreen();
		if(document.getElementById("statusBar")) {
			document.getElementById("statusBar").style.top = dim_xy['h']/2 - 100;
			document.getElementById("statusBar").style.left = dim_xy['w']/2 - 100;
			document.getElementById("LightBox").style.top = dim_xy['h']/2 - 250;
			document.getElementById("LightBox").style.left = dim_xy['w']/2 - 250;
			//document.getElementById("statusBar").style.visibility = "visible";
		}

       var ajax = new sack();
		for(key in info){
			ajax.setVar(key, info[key]);
		}
        ajax.requestFile = "/admin/service/_init.php"; 
		ajax.element = "statusBar"; 
        ajax.method = "GET"; 
		ajax.onCompletion = whenInit;	
        ajax.runAJAX();
}

function whenInit(evt){ 
	evt = (evt) ? evt : ((window.event) ? event : null );
	resize();
	if(document.getElementById("statusBar")) {
		//id = setTimeout("alphaObject(100)", 2000);
	}
}

function resize(evt) {
	evt = (evt) ? evt : ((window.event) ? event : null );
	var dim_xy = getScreen();
} 


function alphaObject(alp) {
	obj = document.getElementById("statusBar");
	if(_dom == 3) {
		obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+alp+")";
		alp -= 5;
			if(alp >= 5) {
				id = setTimeout("alphaObject(" + alp + ")", 100);
			} else {
				obj.style.visibility = "hidden";
				obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
			}
	} else {
		obj.style.opacity = alp;
		alp -= 5;
			if(alp >= 5) {
				id = setTimeout("alphaObject(" + alp + ")", 100);
			} else {
				obj.style.visibility = "hidden";
				obj.style.opacity = 100;
			}
	}
}


var migtime = 0;
function miganie(period, cnt) {
	if(document.getElementById("ar1")) {
		migtime ++;
		if(Math.floor( migtime/2 ) == migtime/2) {
			document.getElementById("ar1").style.display = "block";
			document.getElementById("ar2").style.display = "block";
		} else {
			document.getElementById("ar1").style.display = "none";
			document.getElementById("ar2").style.display = "none";
		}

		if( migtime < cnt)	 {
			mig = setTimeout("miganie(" + period + ", " + cnt + ")", period);
		} else {
			migtime = 0;
		}
	}
}


function Clear(){
		var ajax = new sack();
        ajax.requestFile = "/user/clear.php"; 
        ajax.method = "GET"; 
        ajax.runAJAX();
		ajax.onCompletion = whenCompletedClear();	
}

function whenCompletedClear(){
	window.location.href = "/";
}



// Инициализируем таблицу перевода
var trans = [];
for (var i = 0x410; i <= 0x44F; i++)
  trans[i] = i - 0x350; // А-Яа-я
trans[0x401] = 0xA8;    // Ё
trans[0x451] = 0xB8;    // ё

// Сохраняем стандартную функцию escape()
var escapeOrig = window.escape;

// Переопределяем функцию escape()
window.escape = function(str)
{
  var ret = [];
  // Составляем массив кодов символов, попутно переводим кириллицу
  for (var i = 0; i < str.length; i++)
  {
    var n = str.charCodeAt(i);
    if (typeof trans[n] != 'undefined')
      n = trans[n];
    if (n <= 0xFF)
      ret.push(n);
  }
  return escapeOrig(String.fromCharCode.apply(null, ret));
}


function searchKeypress(evt)
{
  e = evt || window.event;
  if (e.keyCode == 13)
      return search();
}

function ModTree( image, id ) {
		/*var ajax = new sack();
       /ajax.requestFile = "/admin/service/_ajax.php";
		ajax.setVar("action", "modtree");	
		ajax.setVar("id", id);	
		ajax.setVar("act", act);	
        ajax.method = "GET"; 
		ajax.onCompletion = whenCompletedModTree;	
        ajax.element = "xxx"; 
        ajax.runAJAX();*/

		ShowHide("tree" + id);
		//var imgsrc = document.getElementById("folder"+id).src.toString();
		if( folder = document.getElementById("folder"+id) ) {
			folder.src = (folder.src.indexOf('close')==-1) ? "/_img/catalog/tree_close.gif" : "/_img/catalog/tree_open.gif";
		}
		image.src = (image.src.indexOf('plus')==-1) ? "/_img/catalog/plus.gif " : "/_img/catalog/min.gif ";
}

function whenCompletedModTree(){
	//window.location.reload();
}


function URLDecode(str){
    str2 = "";
    for(k=0;k<str.length;k++){
        str2 += '%' + chr[str.charAt(k)];
    }
    return str2;
}


function setCatIntoLink( ){
	var str = "";
	var ids = "";
	var inputs = document.forms["f"].elements;
	for ( var i = 0; i < inputs.length; i++ ) {
		if( inputs[i].type == "checkbox" && inputs[i].checked ) {
			str += inputs[i].value + "\r\n";
			ids += inputs[i].name + ",";
		}
	}
    document.getElementById('allcatlinks').value = str ;
    document.getElementById('allcatlinksid').value = ids ;
}




function popform(id, type, select ) {

        var ajax = new sack();
		ajax.setVar("id", id);
		ajax.setVar("type", type);

		if(type == "content") {
			ajax.setVar("tbl", "objects");
			ajax.setVar("field", "content");
			ajax.setVar("showfield", "name");
			ajax.setVar("filter", "arch=0");
			ajax.setVar("ord", "name");
		}

		if(type == "pattern") {
			ajax.setVar("tbl", "tblpagepatterns");
			ajax.setVar("field", "pattern");
			ajax.setVar("showfield", "name");
			ajax.setVar("filter", "1");
			ajax.setVar("ord", "name");
		}	

		if(type == "user") {
			ajax.setVar("tbl", "tblroles");
			ajax.setVar("field", "role");
			ajax.setVar("showfield", "name");
			ajax.setVar("filter", "id>1");
			ajax.setVar("ord", "id");
		}	
		
		ajax.setVar("select", select);
        ajax.requestFile = "/admin/service/_showlist.php"; 
        ajax.element = "popform"; 
        ajax.method = "GET"; 
        ajax.runAJAX();
		ajax.onCompletion = whenCompleted;
}


function whenCompleted(){
	document.getElementById("popform").style.display = "block";
}



function ok(id, type, status) {
		if(!status || !id) document.getElementById("popform").style.display = "none";	

       var ajax = new sack();
		ajax.setVar("id", id);


		if(type == "content") {
			ajax.setVar("tbl", "catalog");
			ajax.setVar("field", "content");
			ajax.setVar("content", document.getElementById("return").value);
			ajax.element = "td_c_" + id; 
		}
		if(type == "pattern") {
			ajax.setVar("tbl", "catalog");
			ajax.setVar("field", "pattern");
			ajax.setVar("pattern", document.getElementById("return").value);
			ajax.element = "td_p_" + id; 
		}	
		if(type == "user") {
			ajax.setVar("tbl", "tblusers");
			ajax.setVar("field", "role");
			ajax.setVar("role", document.getElementById("return").value);
			ajax.element = "td_u_" + id; 
		}	
        ajax.requestFile = "/admin/service/_incobj.php"; 

        ajax.method = "GET"; 
        ajax.runAJAX();
}


function ShowLightBox(data, id){
	document.getElementById("LightBox").style.visibility="visible";
	var ajax = new sack();
	ajax.setVar("id", document.getElementById(id).value);
	ajax.setVar("data", data);
	ajax.setVar("action", "getdata");
    ajax.requestFile = "/admin/service/_ajax.php";
    ajax.element = "LightBox";
    ajax.method = "GET";
    ajax.runAJAX();
}
function CloseData(){
	document.getElementById("LightBox").style.visibility="hidden";
	document.getElementById("LightBox").innerText = "";
}



/*	выпадающее окно - помощь */
function popHelp(id, pg){
	document.getElementById("helpwin").style.top = window.event.y;
	document.getElementById("helpwin").style.left = window.event.x;
	document.getElementById("helpwin").style.visibility="";

	var ajax = new sack();
	ajax.setVar("id", id);
	ajax.setVar("pg", pg);
    ajax.requestFile = "/admin/service/showhelp.php";
    ajax.element = "helpwin"; // куда возвращать ответ
    ajax.method = "POST"; // метод которым отправлять инфу POST/GET
    ajax.runAJAX(); // запускаем
}


function CloseHelp() {
	document.getElementById("helpwin").style.visibility="hidden";
	document.getElementById("helpwin").innerHTML = "";	
}

function browserInfo()
{
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns6 = (agent.indexOf('netscape6')!=-1);
	this.ie = (agent.indexOf("msie") != -1);
	this.dom = ((agent.indexOf("msie") != -1) || (agent.indexOf("gecko")!=-1));
	this.win = (agent.indexOf("win")!=-1);
	this.nowin = (agent.indexOf("linux")!=-1 || agent.indexOf("sun")!=-1 || agent.indexOf("aix")!=-1);
}

/*	выпадающее окно - помощь 
/*function popHelp(body){

	var oPopup = window.createPopup();
	var oBody = oPopup.document.body;
	oBody.style.backgroundColor = "lightyellow";
	oBody.style.border = "solid black 1px";
	oBody.innerHTML = body;
	oPopup.show(window.event.x, window.event.y, 300, 25, document.body);
}*/


var timer=0;
var curObject = 'txt';

var question = new Array(
							'Текущая категория перейдет вверх по иерархии. Продолжить?',
							'Произойдет удаление текущей таблицы данных. Продолжить?',
							'Удаление таблицы данных. Данная операция необратима. Продолжить?',
							'Произойдет удаление представления, включая соответствующие таблицы данные. Продолжить?',
							'Произойдет каскадное удаление объектов стуктуры. Продолжить?',
							'Удалить тему, всключая все сообщения?',
							'Удалить информационный блок?'
						);

var request = new Array();
request['delcat'] = 'Произойдет каскадное удаление объектов стуктуры. Продолжить?';
request['publishall'] = 'Установить флаг публикации на все категории?';
request['multipattern'] = 'Установить одинаковый шаблон?';
request['delfilter'] = 'Удалить фильтр?';
request['delsort'] = 'Удалить сортировку?';
request['delviewtype'] = 'Удалить данный тип представления? (не рекомендуется)';
request['userstatus'] = 'Вы уверены, что хотите поменять статус пользователя. дающий право доступа к персонализированным данным?';
request['deluser'] = 'Произойдет удаление пользователя и всех данных из профайла..';
request['delpro'] = 'При удалении профайла категория привязки сохраняется. Продолжить?';
request['delview'] = 'Произойдет удаление представления, включая соответствующие таблицы данные. Продолжить?';
request['deltbl'] = 'Удаление таблицы данных. Данная операция необратима. Продолжить?';
request['publish'] = 'Изменить статус публикации страницы?';

/*  подтверждение действий*/
function Request(obj, action, num, needconfirm)
{
	var classname = (num == "deltbl" || num == 'userstatus' || num == 'publish') ? "atact" : "del";
	document.getElementById('statusBar').style.visibility = "visible";
	document.getElementById('statusBar').innerHTML = '<img src="/_img/act/progress.gif">&nbsp;ожидание подтверждения...';
	if(needconfirm=='0' || confirm(request[num]))
	{
		document.getElementById('statusBar').innerHTML = '<img src="/_img/act/progress.gif">&nbsp;обработка...';
	    var ajax = new sack();
        ajax.requestFile = action;
        ajax.element = "statusBar";
        ajax.method = "POST";
        ajax.runAJAX();
		ajax.onCompletion = finishRequest;
		if(document.getElementById("start_" + obj)) {
			document.getElementById("start_" + obj).className = classname;
			document.getElementById("end_" + obj).className = classname;
		} else {
			document.getElementById(obj).className = classname;
		}
	}
	else
	{
	  	alert('Действие отменено');
		finishRequest();
	}
  }

	function finishRequest() {
		if(document.getElementById("statusBar")) {
			id = setTimeout("alphaObject(100)", 2000);
		}
	}


/* end */

function GenProfile(img, id){
		document.getElementById('statusBar').style.visibility = "visible";
		document.getElementById('statusBar').innerHTML = '<img src="/_img/act/progress.gif">&nbsp;обработка...';
		img.src = "/_img/act/gener.gif";
	    var ajax = new sack();
		ajax.setVar("id", id);
        ajax.requestFile = "/admin/service/_classgen.php";
        ajax.element = "statusBar";
        ajax.method = "GET";
		ajax.onCompletion = finishGenProfile;
        ajax.runAJAX();
}

	function finishGenProfile() {
		if(document.getElementById("statusBar")) {
			id = setTimeout("alphaObject(100)", 2000);
		}
	}


function FilterLetter(letter, id)
{
	    var ajax = new sack();
		ajax.setVar("id", id);
		ajax.setVar("letter", letter);
		ajax.setVar("isprofile", 1);

        ajax.requestFile = "/admin/service/_filter.php";
        ajax.element = "menucomponent"; 
        ajax.method = "GET"; 
		//ajax.onCompletion = whenCompleted;
        ajax.runAJAX(); 
}


function ShowSettings(){
		display = (document.getElementById("settings").style.display == "block" ) ? 0 : 1;
		document.getElementById("settings").style.display = (display) ? "block" : "none";
		document.getElementById("setimg").src = (display) ? "/_img/act/settings_hide.gif" : "/_img/act/settings_show.gif";
	    var ajax = new sack();
		ajax.setVar("action", "showsettings");
        ajax.requestFile = "/admin/service/_ajax.php";
        ajax.method = "GET";
        ajax.runAJAX();
}

function ShowFavorites(){
		display = (document.getElementById("fav").style.display == "block" ) ? 0 : 1;
		document.getElementById("fav").style.display = (display) ? "block" : "none";
		document.getElementById("setfavimg").src = (display) ? "/_img/act/fav_hide.gif" : "/_img/act/fav_show.gif";
	    var ajax = new sack();
		ajax.setVar("action", "showfavorites");
        ajax.requestFile = "/admin/service/_ajax.php";
        ajax.method = "GET";
        ajax.runAJAX();
}


function selectList(selObj, field) {
    document.getElementById(field).value = selObj.options[selObj.selectedIndex].value;
	var ajax = new sack();
    ajax.setVar("action", "makeFldList");
    ajax.setVar("idView", selObj.options[selObj.selectedIndex].value);
    ajax.requestFile = "/admin/service/_ajax.php";
    ajax.method = "GET";
    ajax.element = "generate"; 
    ajax.runAJAX();
}

function checkForTrueFldValues( field, divId ) {
	if( document.getElementById(divId) ) {
		var ajax = new sack();
		ajax.setVar("action", "makeTrueFldValue");
		ajax.setVar("fld", document.getElementById(field).value);
		ajax.requestFile = "/admin/service/_ajax.php";
		ajax.method = "GET";
		document.getElementById("calendar_value").style.display = "none";
		document.getElementById("clock_value").style.display = "none";
		ajax.element = divId; 
		ajax.runAJAX();
	}
}


function delBM(pg)
{
	if(confirm("Удалить страницу из закладок?"))
	{
		page = "/admin/service/_delanonym.php?t=bm&pg=" + pg;
		document.location.href = page;
	}
	else
	{
		alert("Действие отменено");
	}	
}

function QuestWin(action, num)
{
	if(confirm(question[num]))
	{
		window.location.href = action;
	}
	else
	{
		alert("Действие отменено");
	}
}



function chgUse()
{
 if(document.addForm.new_use.value=="1") document.addForm.new_use.value=="0"
 else document.addForm.new_use.value=="1"
}

function selOrder(x,y)
{
		link='_actions.php?id=' + y + '&act=order&new_ord=' + x;
		document.location.href = link;
}

function IoType(obj, type)
{
		link = "_actions.php?act=type&id=" + obj + '&type=' + type;
		document.location.href = link;
}

function Sure(action,name)
{

	if(confirm("Вы уверены, что хотите удалить '" + name + "'?"))
	{
		page="/admin/service/_delete.php?"+action;
		document.location.href = page;
	}
	else
	{
		alert("Действие отменено");
	}

}





function Disable()
{
	alert("У Вас недостаточно прав для выполнения операции!")
}

function Over(obj)
{
	obj.className="rmenuover"
}
function Out(obj)
{
	obj.className="rmenu"
}

function BackDoc(action)
{

	if(confirm("Данные обновятся в соответствии с данным документом. Продолжить?"))
	{
		page="_doc.php?a=bu&"+action;
		document.location.href = page;
	}

}

function StartVideo(obj, videofile)
{
	obj.outerHTML = "<img dynsrc=" + videofile + ">";
}


function DelDoc(action)
{

	if(confirm("Будет удален файл back-up'а и все данные, связанные с этим файлом. Продолжить?"))
	{
		page="_doc.php?a=del&"+action;
		document.location.href = page;
	}

}

function SetStatusToDB(x)
{

		page="/admin/service/_chgstatus.php?"+x;
		document.location.href = page;
}




function GP(x)
{
	if(x)	document.location.href = x;
	else	alert("страница отсутствует!");
}





function ShowHide(idname)
{
 if (document.getElementById(idname).style.display == "none")
 {
  document.getElementById(idname).style.display = "block";
 }
 else
 {
  document.getElementById(idname).style.display = "none";
 }
}


function ShowInfo(idname)
{
document.all[idname].style.top = window.event.y;
document.all[idname].style.left = window.event.x;

 if (document.all[idname].style.display == "none")
 {
  document.all[idname].style.display = "block";
 }
 else
 {
  document.all[idname].style.display = "none";
 }
}


function SetDateTime(value,field,block)
{
	document.getElementById(field).value=value;
	document.getElementById(block).style.display = "none";
}

function SetForm(field,value)
{
	document.all[field].value=value;
}


function OpenDoc(id)
{
	if(confirm("Для скачивания документа нажмите [Да], для открытия в отдельном окне нажмите [Отмена]"))
	{
		location.replace("/admin/objects/_opendoc.php?id="+id+"&act=load")
	}
	else
	{
		window.open("/admin/objects/_opendoc.php?id="+id+"&act=show")
	}
}

function SetText()
{
	document.addBlock.content.value=document.addBlock.txt.value;
}

function SetAlign(alg)
{
	document.addBlock.alig.value=alg;
}

function tagAround(x,y)
{
if(x==1) {x="<b>"; y="</b>";}
if(x==2) {x="<i>"; y="</i>";}
if(x==3) {x="<sup>"; y="</sup>";}


with(document.selection.createRange())
{
 if (text)
 {
  var b_content = text;
 }
 else
 {
  var b_content = prompt ("??????? ??????", "");
  if (!b_content) return false;
 }
 var b_string = x+b_content+y;
 text = b_string;
}
}


function tagOne(x)
{
document.getElementById(curObject).focus();
if(x==1) x="<br>";
 with(document.selection.createRange())
 {
  text=x;
 }
}


function newlnk()
{
with(document.selection.createRange())
{
 var a_href = prompt ("Введите адрес", "");
 if (!a_href) return false;
 if (text)
 {
  var a_content = text;
 }
 else
 {
  var a_content = prompt ("????? ???????", "");
  if (!a_content) return false;
 }
 var a_string = "<a href='"+a_href+"'>"+a_content+"</a>";
 text = a_string;
}
}


function newanch()
{
with(document.selection.createRange())
{
 var a_anch = prompt ("Введите ссылку", "");
 if (!a_anch) return false;
 if (text)
 {
  var a_content = text;
 }
 else
 {
  var a_content = prompt ("?? ??? ??????? ??????", "");
  if (!a_content) return false;
 }
 var a_string = "<a name="+a_anch+">"+a_content+"</a>";
 text = a_string;
}
}




function SetFont(x)
{
with(document.selection.createRange())
{
 if (text)
 {
  var b_content = text;
 }
 else
 {
  var b_content = prompt ("??????? ??????", "");
  if (!b_content) return false;
 }
col=10+x;
var b_string = "<font style='font-size:" + col + "'>" + b_content + "</font>";
text = b_string;
}
}



function SetSpecial(x)
{
	allspecials=new Array(
	'&quot;',
	'&amp;',
	'&lt;',
	'&gt;',
	'&sect;',
	'&copy;',
	'&reg;',
	'&plusmn;',
	'&mdash;',
	'&bull;',
	'&trade;',
	'&rarr;',
	'&#8364;',
	'&shy;'
					);
	document.getElementById(curObject).focus();
	with(document.selection.createRange())
	{
		text=allspecials[x];
	}
}

function PopMenu(obj, pop, vis)
{
	//--	объекты
		popid="pop"+pop;
		menu="m"+pop;

	//--	обработка главного меню
	if(obj.className=="topmenu" || obj.className=="topmenuact")
	{
		if(vis==1)
		{
			obj.className="topmenuact";
			document.getElementById(popid).style.left=popupPos[pop-1];

			//	скрыть остальные выпдающие меню
			for(i=1;i<MenuList;i++)
			{
				if(i!=pop)
				{
					hideid="pop"+i;
					menuid="m"+i;
					document.getElementById(hideid).style.display="none";
					document.getElementById(menuid).className="topmenu";
				}
			}
			document.getElementById(popid).style.display="block";

		}
		else
		{

			//	проверка границ
			if(window.event.x<popupPos[pop-1] || window.event.x>popupPos[pop] || window.event.y<TopPosition)
			{
				obj.className="topmenu";
				document.all[popid].style.display="none";
			}
		}
	}

	//--	обработка всплывающего меню
	if(obj.className=="submenu" || obj.className=="submenuact")
	{
		if (vis==1)
		{
			obj.className="submenuact";
			document.getElementById(popid).style.display="block";
			document.getElementById(menu).className="topmenuact";
		}
		else
		{
			obj.className="submenu";
			document.getElementById(popid).style.display="none";
			document.getElementById(menu).className="topmenu";
		}
	}
}


	function AddList(type)
	{
		with(document.selection.createRange())
		{
			if (text)
			{
				var content = text;
			}

			x=content.split("\n");
			var i=0;
			content=(type==1) ? "<ul>" : "<ol>";

			while(x[i] && x[i]!="")
			{
				content+="<li>"+x[i];
				i++;
			}
			content+=(type==1) ? "</ul>" : "</ol>";
			text=content;
		}
	}

function chgStatus(el)
{
	if(document.all[el].value=="1")
	{
		document.all[el].value="0";
	}
	else
	{
		document.all[el].value="1";
	}
}

function chgStatusTxt(el, field, txtOn, txtOff)
{
	if(document.all[el].value=="1")
	{
		document.all[field].innerText=txtOn;
	}
	else
	{
		document.all[field].innerText=txtOff;
	}
}


function jumpSelect(selObj,restore)
{
	eval("self.parent.location.href='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function chgSelect(selObj, field)
{
	document.getElementById(field).value = selObj.options[selObj.selectedIndex].value;
}




var x=0;
function AddField()
{
	x++;
	document.all['fields'].outerHTML =
		  "<select onchange=document.all['type["+x+"]'].value=this.options[this.selectedIndex].value>"
		+ "<option>- - - - - - - - -"
		+ "<option value='varc'>текст (до 100)"
		+ "<option value='txt'>текст"
		+ "<option value=''>документ"
		+ "<option>изображение"
		+ "<option>иконка"
		+ "<option>ссылка"
		+ "<option>статус"
		+ "<option>переключатели"
		+ "<option>список"
		+ "</select>"
		+ "<input type='hidden' name='type["+x+"]' value=''>"
		+ "<input name='field["+x+"]' value=\"\"><input type=button value='-'>"
		+ "<br><div id=\"fields\"></div>";
}
/*
function document.oncontextmenu()
{
	window.event.returnValue = false
}*/

function ShowPict(image)
{
	page = "/admin/service/showpict.php?src="+image;
	window.open(page,'img','width=100,height=100,top=10,left=100,scrollbars=no,toolbar=no, menu=no');
}
/*
function document.onclick()
{
		if(document.all['contexFilter']) document.all['contexFilter'].style.visibility="hidden";
		tn = window.event.srcElement.tagName;
		if(tn == 'INPUT' || tn == 'TEXTAREA')
		{
			curObject = window.event.srcElement.name;
		}
}*/
function ToBuffer(pg)
{
	window.clipboardData.setData("Text", pg)
}

function 	SelectRow( row ){
	document.getElementById(row).className = "rowover";
}

function DeselectRow( row , classname){
	document.getElementById(row).className = classname;
}


function switchMainBookmark(a, num, group) {
	try {
		var td, tr = a, div;
		var node, i, remJ = [], curTD = 0;
		var rbArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
		if (div = document.getElementById(group + num)) {
			div.style.display = "";
			for (i = 0; i < rbArray.length; i++) if (rbArray[i] != num) {
				if( tempdiv = document.getElementById(group + rbArray[i]) ) { tempdiv.style.display = "none"; }
			}
		} else return false;
		if (!num) return false;
		while (tr.parentNode && tr.nodeName.toLowerCase() != "tr") {
			if (tr.nodeName.toLowerCase() == "td") td = tr;
			tr = tr.parentNode;
		}
		for (i = 0; i < tr.childNodes.length; i++) {
			node = tr.childNodes[i];
			if (node.nodeType != 1) continue;
			if (node.nodeName.toLowerCase() != "td") continue;
	                if (node.firstChild.className != "lft" && node.firstChild.className != "lft first" && node.firstChild.className != "lst") continue;
			if (node == td) {node.className = "act"; curTD = 1;} 
			else {node.className = curTD ? "aftact" : "pas"; curTD = 0;}
		}
		return false;
	} catch(e) {
		return false;
	}
}
