var un='undefined';
var fn='function';
var DL=false;

var bdb=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body?document.body:null;
var bn=navigator.userAgent.toLowerCase();
var bnv=navigator.appVersion;
var bop=!!(document.getElementById&&window.opera);
var bop6=bop&&!document.defaultView;
var bop7=bop&&!bop6;
var bie=(bn.indexOf("msie")!=-1)&&document.all&&bdb&&!bop;
var bie6=bie&&(parseFloat(bnv.substring(bnv.indexOf("MSIE")+5))>=5.5);
var bn4=(document.layers&&(typeof(document.classes)!=un));
var bn6=(!bop&&document.defaultView&&(typeof(document.defaultView.getComputedStyle)!=un));
var bw3c=!bie&&!bn6&&!bop&&document.getElementById;

var docHeight=0;
function pageHeight(){
if(typeof(document.height)!=un){docHeight=document.height;}
else if((document.compatMode)&&(document.compatMode!='BackCompat')){docHeight=document.documentElement.scrollHeight;}
else if(document.body&&(typeof(document.body.scrollHeight)!=un)){docHeight=document.body.scrollHeight;}}
function intval(i){var n;return isNaN(n=parseInt(i))?0:n;}
var loginSWimg=new Array();loginSWimg[0]=new Image();loginSWimg[0].src='/img/chk0.gif';loginSWimg[1]=new Image();loginSWimg[1].src='/img/chk1.gif';
function pwdfield(obj,e,txt){if(e.type=='focus'){if(obj.value==txt){obj.value='';}}else{if(e.type=='blur'){if(!obj.value.length){obj.value=txt;}}}}
function loginSaveSw(obj,e){var frm=document.getElementById('loginForm');if(intval(frm['save'].value)){frm.save.value=0;obj.src=loginSWimg[0].src;}else{frm.save.value=1;obj.src=loginSWimg[1].src;}}
function poppic(id,x,y){if (!id||!x||!y){return(false);};x=intval(x)+40;y=intval(y)+60;window.open('picture.php?id='+id,'picture'+id,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+x+',height='+y+',top=100,left=100');return(true);}
function filePickCh(obj,ft){var chk=false;switch(ft){default:if(!/\.gif|\.png|\.jpeg|\.jpg$/i.test(obj.value)){chk=true;}break;};if(chk){var inp=document.createElement("INPUT");inp.type=obj.type;inp.name=obj.name;inp.size=obj.size;inp.className=obj.className;inp.id=obj.id;inp.onchange=obj.onchange;obj.parentNode.replaceChild(inp,obj);}}
function in_arr(obj,arr){if(arr&&arr.length){for(var i=0;i<arr.length;i++){if(arr[i]==obj){return(true);}}};return(false);}
function rm_arr(obj,arr){if(arr&&arr.length){var tmp=arr;arr=new Array();for(var i=0;i<tmp.length;i++){if(tmp[i]!=obj){arr[arr.length]=tmp[i];};};};return(arr);}
function to_arr(obj,arr){if(!arr){arr=new Array();};arr[arr.length]=obj;return(arr);}
function swd(obj){obj.style.display='none';obj.style.display='';}
function shsw(sh){sh=parseInt(sh)?true:false;return(sh);}
function to(v){return(((typeof(v)!=un)&&v)?true:false);}

var gx;var gy;function getXY(e){gx=(window.Event)?e.pageX:event.clientX;gy=(window.Event)?e.pageY:event.clientY;}

function createHttpRequest(){
  var httpRequest;var browser=navigator.appName;
  if(window.XMLHttpRequest){try{httpRequest=new XMLHttpRequest();}catch(e){return(false);}}
  else{if(window.ActiveXObject){try{httpRequest=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){return false;}try{httpRequest=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){return false;}}}
  return(httpRequest);
}
var ajaxLDR=createHttpRequest();var ajaxLDRBusy=false;var ajaxHTMLid=false;var ajaxFunc=false;
function ajaxGetReq(){if(ajaxLDR.readyState==4){
  var f=false;var trg=false;
  if(ajaxHTMLid){trg=document.getElementById(ajaxHTMLid);}
  if((typeof(ajaxFunc)==fn)&&ajaxFunc){f=ajaxFunc(ajaxLDR,trg);};
  if(f!==true){if(trg){trg.innerHTML=ajaxLDR.responseText;};ajax0();}}
}
function ajaxget(q,htmlid,rprc,caption,func){
  if(!ajaxLDR){return(0);};if(ajaxLDRBusy){return(0);};ajaxHTMLid=((typeof(htmlid)&&htmlid)?htmlid:false);ajaxLDRBusy=true;
  if(ajaxHTMLid){document.getElementById(ajaxHTMLid).innerHTML='<table cellpadding="8" cellspacing="0" border="0" align="center"><tr><td><img src="img/ajax.gif" width="13" height="13" border="0"></td><td>'+(caption?caption:'Загружаю...')+'</td></tr></table>';}
  if(ajaxHTMLid){document.getElementById(ajaxHTMLid).style.display='';};
  ajaxFunc=(((typeof(func)==fn)&&func)?func:false);
  if((typeof(sid)!=un)&&sid){q.concat('&sid='+sid);}
  ajaxLDR.open('GET',q.concat('&random='+Math.random()));
  ajaxLDR.onreadystatechange=(((typeof(rprc)==fn)&&rprc)?rprc:ajaxGetReq);
  ajaxLDR.send(null);return(1);
}
function ajaxpost(q,param,htmlid,rprc,caption,func){
  if(!ajaxLDR){return(0);};if(ajaxLDRBusy){return(0);};ajaxHTMLid=((typeof(htmlid)&&htmlid)?htmlid:false);ajaxLDRBusy=true;
  if(ajaxHTMLid){document.getElementById(ajaxHTMLid).innerHTML='<table cellpadding="8" cellspacing="0" border="0" align="center"><tr><td><img src="img/ajax.gif" width="13" height="13" border="0"></td><td>'+(caption?caption:'Загружаю...')+'</td></tr></table>';}
  if(ajaxHTMLid){document.getElementById(ajaxHTMLid).style.display='';}
  if((typeof(sid)!=un)&&sid){param.concat('&sid='+sid);}
  ajaxFunc=(((typeof(func)==fn)&&func)?func:false);
  ajaxLDR.open('POST',q,true);
  ajaxLDR.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  ajaxLDR.setRequestHeader("Content-length",param.length);ajaxLDR.setRequestHeader("Connection","close");
  ajaxLDR.onreadystatechange=(((typeof(rprc)==fn)&&rprc)?rprc:ajaxGetReq);
  ajaxLDR.send(param);return(1);
}
function ajax0(){ajaxLDR.abort();ajaxLDRBusy=false;return(true);}

var zndx=999;var wndList=new Array();var wndObj=new Array();var lastWnd=false;
JSWND=function(id,wnd,wndCnt,trgTitle,wndHTML,trgHTML,shade){
  this.id=id;this.wnd=wnd;this.wndCnt=wndCnt;this.wndHTML=wndHTML;
  this.trgTitle=trgTitle;this.trgHTML=trgHTML;this.shade=shade;
  this.html=function(cnt){this.trgHTML.innerHTML=cnt;}
  this.ttl=function(ttl){this.trgTitle.innerHTML=ttl;}
}
function createWnd(wndY,wndW,wndTitle,wndText,noShade,askClose,wndH){
  if(!wndY){wndY=200;};if(!wndW){wndW=400;};if(!wndText){wndText='Загрузка...';};var n=Math.round(Math.random()*9999)+Math.round(Math.random()*9999);
  var shade=false;if(!noShade){shade=document.createElement('DIV');shade.id='wndShade'+n;shade.className='wndShade';shade.style.zIndex=++zndx;document.body.appendChild(shade);}
  var wnd=document.createElement('DIV');wnd.id='wnd'+n;wnd.style.position='absolute';wnd.style.minWidth='500px';wnd.style.textAlign='center';
  wnd.style.left='0px';wnd.style.width='100%';wnd.style.display='none';wnd.style.top=wndY+'px';wnd.style.zIndex=++zndx;document.body.appendChild(wnd);
  var wndCnt=document.createElement('DIV');wndCnt.id='wndCnt'+n;wndCnt.style.position='relative';wndCnt.style.textAlign='left';
  wndCnt.style.marginLeft='auto';wndCnt.style.marginRight='auto';wndCnt.style.width=wndW+'px';wndCnt.style.zIndex=++zndx;
  wndCnt.style.border='2px #666666 solid';wndCnt.style.backgroundColor='#4E4E4E';wndCnt.style.padding='0px';wnd.appendChild(wndCnt);
  var wndHTML=document.createElement('DIV');wndHTML.style.position='relative';wndHTML.style.zIndex=++zndx;wndHTML.style.height='100%';
  wndHTML.style.fontFamily='verdana,tahoma,arial,sans-serif';wndHTML.style.border='1px #000000 solid';wndHTML.style.fontSize='8pt';
  wndHTML.innerHTML='<table cellpadding="0" cellspacing="0" border="0" width="100%" height="'+(wndH?'height="'+wndH+'"':'')+'" style="border:1px #666666 solid;width:100%;'+(wndH?'height:'+wndH+'px;':'')+'"><tr>'+
  '<td style="padding:4px 8px;background-color:#333333;border-bottom:1px #4E4E4E solid;font-weight:bold;height:20px;" width="98%"><div id="wndTitle'+n+'">'+wndTitle+'</td>'+
  '<td style="padding:4px;background-color:#333333;border-bottom:1px #4E4E4E solid;font-weight:bold;cursor:pointer;" valign="top" align="right"><nobr><span onClick="reloadWnd(\''+n+'\')">&#151;</span>&nbsp;&nbsp;&nbsp;<span onClick="killWnd(\''+n+'\''+(((typeof(askClose)!=un)&&askClose)?',1':'')+');" title="закрыть">&nbsp;x&nbsp;</span></nobr></td>'+
  '</tr><tr><td colspan="3" valign="top" height="99%"><div id="wndHTML'+n+'" style="border-top:2px #333333 solid;padding:8px;">'+wndText+'</div></td></tr></table>';
  wndCnt.appendChild(wndHTML);document.body.appendChild(wnd);wnd.style.display='';wndList[wndList.length]=n;
  var trgHTML=document.getElementById('wndHTML'+n);var trgTitle=document.getElementById('wndTitle'+n);
  wndObj[n]=new JSWND(n,wnd,wndCnt,trgTitle,wndHTML,trgHTML,shade);
  shsw(1);return(wndObj[n]);
}
function getWnd(id){if(!id){id=lastWnd;}else{id=parseInt(id);};var wo=wndObj[id];return((typeof(wo)&&wo)?wo:false);}
function setWndTitle(id,ttl){var wo;if(wo=getWnd(id)){wo.ttl(ttl);}}
function setWndHTML(id,cnt){var wo;if(wo=getWnd(id)){return(wo.html(cnt));}}
function reloadWnd(id){var wo;
  if(wo=getWnd(id)){wo.trgHTML.style.display=(wo.trgHTML.style.display=='none')?'':'none';wo.wndHTML.firstChild.style.height='';}
}
function killWnd(id,ask){if(!id){id=lastWnd;}else{id=parseInt(id);};var wnd=document.getElementById('wnd'+id);if(typeof(ask)==un){var ask=false;};
  if(wnd){if(ask){ask=confirm('Закрыть?');}else{ask=true;};var f=0;
    if(ask){if((typeof(wndObj[id].kill)!=un)&&wndObj[id].kill){f=wndObj[id].kill();};if(f!==true){ajaxLDR.abort();ajaxLDRBusy=false;}
      wnd.parentNode.removeChild(wnd);var tmp=wndList;wndList=new Array();for(var i=0;i<tmp.length;i++){if(id!=tmp[i]){wndList[wndList.length]=tmp[i];};};
      if(wndObj[id].shade){var shade=wndObj[id].shade;shade.parentNode.removeChild(shade);};wndObj[id]=null;if(!wndList.length){shsw(0);}}}return;}
function addsid(){if((typeof(sid)!=un)&&sid){return('&sid='+sid);}}



var accords=new Array('ACCsec1','ACCsec2');var tabCur,tabOp,tabAcc,collprc;var tabHeight=424;var accDelayId=false;var accDelay=false;
function accord(acc,cancel){if((acc==accordOpen)||collprc){return;};if(cancel){clearTimeout(accDelayId);accDelayId=false;accDelay=false;}else{accDelay=acc;accDelayId=setTimeout('accord_delay();',300);}}
function accord_delay(){var cur=document.getElementById(accordOpen);var op=document.getElementById(accDelay);if(cur&&op){tabCur=cur;tabOp=op;tabAcc=accDelay;collprc=true;collapse();}}
function collapse(){
  if(tabCur&&tabOp){var ch=parseInt(tabCur.style.height);var oh=parseInt(tabOp.style.height);
    if(ch>=33){ch=ch-15;oh=oh+15;tabCur.style.height=ch+'px';tabOp.style.height=oh+'px';setTimeout('collapse();',10);}
    else{tabCur.style.height='18px';tabOp.style.height=tabHeight+'px';accordOpen=tabAcc;tabCur=tabOp=tabAcc=collprc=false;}}}
function ovrNews(obj,p){obj.style.backgroundColor=parseInt(p)?'#615e5b':'';}
var scrMove=0;var scrObj=false;var scrWndH=238;var scrWndT=false;var scrLim=false;var scrStep=14;
function cScr(dir){if(scrMove==0){scrMove=dir;if(scrObj=document.getElementById('content')){
    if(scrLim=parseInt(scrObj.clientHeight)){}else if(scrLim=parseInt(scrObj.firstChild.clientHeight)){};
    if(scrLim>scrWndH){scrLim=-1*(scrLim-scrWndH);scrc();}}}}
function mScr(){if(scrObj=document.getElementById('catplate')){}else if(scrObj=document.getElementById('content')){};
  if(scrObj){if(scrLim=parseInt(scrObj.clientHeight)){}else if(scrLim=parseInt(scrObj.firstChild.clientHeight)){};  
    if(scrLim>scrWndH){var mScroller=document.getElementById('mScroller');
      if(mScroller){mScroller.innerHTML='<table cellpadding="0" cellspacing="0" border="0" height="'+scrWndH+'">'+"\n"+'<tr><td valign="top"><img src="img/arru.gif" width="8" height="8" border="0" onMouseOver="cScr(true);" onMouseOut="scrStop();" style="cursor:pointer;"></td></tr>'+"\n"+
        '<tr><td valign="bottom"><img src="img/arrd.gif" width="8" height="8" border="0" onMouseOver="cScr(false);" onMouseOut="scrStop();" style="cursor:pointer;"></td></tr>'+"\n"+'</table>'+"\n";};return(scrObj);}}}
function scrc(){if(scrObj){var pos=parseInt(scrObj.style.top);
    if(scrMove===false){if((pos-scrStep)<=scrLim){pos=scrLim;}else{pos-=scrStep;};scrObj.style.top=pos+'px';setTimeout('scrc();',50);}
    else if(scrMove===true){if((pos+scrStep)>=0){pos=0;}else{pos+=scrStep;};scrObj.style.top=pos+'px';setTimeout('scrc();',50);}}}
function scrStop(){scrMove=0;}
function tmsw(obj,id,act){if(act=='u'){var tma=document.getElementById('top_menu_active');tma.src=topMenuImg[tma.name].src;topMenuImg[id].src=topMenuImg[id+act].src;}
  obj.src=topMenuImg[id+(parseInt(act)?'u':'')].src;var light=document.getElementById('light'+id);if(light){light.style.display=((act!=0)?'block':'none');}}
function mmsw(obj,id,act){if(act=='d'){var sma=document.getElementById('site_menu_active');sma.src=mainMenuImg[sma.name].src;mainMenuImg[id].src=mainMenuImg[id+act].src;};obj.src=mainMenuImg[id+act].src;}
function nasw(obj,sw){switch(parseInt(sw)){case 1:obj.style.backgroundColor='#696763';obj.style.color='#C9C8C7';break;default:obj.style.backgroundColor='';obj.style.color='';break;}}
function movr(obj,hint,img_src){if(typeof(obj)!=un){if(img_src&&(obj.tagName=='IMG')){obj.src=img_src;}
    if(hint){var hinter=document.getElementById('hinter');hinter.style.visibility='visible';hinter.style.left=gx+8+'px';hinter.style.top=gy-16+'px';hinter.innerHTML=hint;}}}
function mmov(obj){if(typeof(obj)!=un){var hinter=document.getElementById('hinter');if(hinter.style.visibility=='visible'){hinter.style.left=gx+8+'px';hinter.style.top=gy-16+'px';}}}
function mout(obj,img_src){if(typeof(obj)!=un){if(img_src&&(obj.tagName=='IMG')){obj.src=img_src;}};var hinter=document.getElementById('hinter');hinter.style.visibility='hidden';}
function shint(obj,msg){if(!DL){return;};if(msg){obj.onmouseover=function(){movr(this,msg,false);}}else{obj.onmouseover=function(){movr(this,this.alt,false);}};
  obj.onmousemove=function(){mmov(this);};obj.onmouseout=function(){mout(this,false);};movr(obj,(msg?msg:obj.alt),false);return;}



var selection;
function bbCheck(trg){var v=trg.value;trg.value=v;return;}
function bbCode(obj,e,target_id){
  mout(obj,e,false);var trg;if(target_id){trg=document.getElementById(target_id);}else{trg=obj.form.message;}
  var param;var selection;var before;var after;
  if(document.selection){try{trg.focus();}catch(e){}selection=document.selection.createRange().text;}
  else{var startPos=trg.selectionStart;var endPos=trg.selectionEnd;before=trg.value.substr(0,startPos);
    selection=trg.value.substr(trg.selectionStart,(trg.selectionEnd-trg.selectionStart));
    after=trg.value.substr(trg.selectionEnd,(trg.value.length-trg.selectionEnd));}
  if(!selection){selection='';};var bbcode=selection;
  switch(obj.name){case'b':bbcode='[b]'+selection+'[/b]';break;case'u':bbcode='[u]'+selection+'[/u]';break;case'i':bbcode='[i]'+selection+'[/i]';break;
    case'url':var link_addr=prompt("Укажите адрес ссылки:",'http://');var link_name=prompt("Укажите название ссылки:",selection);if(!link_addr){link_addr='http://';};if(!link_name){link_name='название';};bbcode='[url='+link_addr+']'+link_name+'[/url]';break;
    case'img':var img_addr=prompt("Укажите адрес картинки:",selection);if(!img_addr){img_addr='ссылка_на_картинку';};bbcode+='[img]'+img_addr+'[/img]';break;
    case'size':var fsize=prompt("Укажите размер шрифта:",'8');if(!fsize){fsize='8';};bbcode='[size='+fsize+']'+selection+'[/size]';break;
    case'font':var ttf=prompt("Укажите шрифт:",'tahoma');if(!ttf){ttf='tahoma';};bbcode='[font='+ttf+']'+selection+'[/font]';break;
    case'color':var col=prompt("Укажите цвет шрифта:",'green');if(!col){col='green';};bbcode = '[color='+col+']'+selection+'[/color]';break;
    case't':bbcode='[title]'+selection+'[/title]';break;case'sep':bbcode+="\n[sep]\n";break;
    case'H':if(obj.selectedIndex){var h=obj.options[obj.selectedIndex].value;bbcode='['+h+']'+selection+'[/'+h+']';obj.options[0].selected=true;}else{return;};break;
    case'bbtest':var TXT=trg.value;var PTXT=document.getElementById(target_id+'bb');
      if(PTXT.style.display!='none'){PTXT.innerHTML='';PTXT.style.display='none';trg.style.display='';obj.value='PAGE';obj.alt='переключиться в режим предпросмотра';return;}
      else{trg.style.display='none';obj.value='VIEV';obj.alt='переключиться в режим редактирования';}
      TXT=TXT.replace(/\n/gi,"<br>\n");TXT=TXT.replace(/\[br\]/gi,"<br>\n");
      TXT=TXT.replace(/\[b\]/gi,"<b>");TXT=TXT.replace(/\[\/b\]/gi,"</b>");TXT=TXT.replace(/\[i\]/gi,"<i>");TXT=TXT.replace(/\[\/i\]/gi,"</i>");TXT=TXT.replace(/\[u\]/gi,"<u>");TXT=TXT.replace(/\[\/u\]/gi,"</u>");
      TXT=TXT.replace(/\[URL=(http:\/\/[^[]+)\](.{1,})\[\/URL\]/gi,"<a href=\"$1\" class=\"reg\">$2</a>");TXT=TXT.replace(/\[URL\](http:\/\/[^[]+)\[\/URL\]/gi,"<a href=\"$1\" class=\"reg\">$1</a>");
      TXT=TXT.replace(/\[h(\d)\]([^[]+)\[\/h(\d)\]/gi,"<div class=\"h$1\">$2</div>");
      TXT=TXT.replace(/\[img\](.{1,})\[\/img\]/gi,"<img src=\"$1\" border=\"0\">");
      TXT=TXT.replace(/\[img=(\d)+,(\d)+\](.{1,})\[\/img\]/gi,"<img src=\"$3\" width=\"$1\" height=\"$2\" border=\"0\">");
      TXT=TXT.replace(/\[mail=([a-zA-Z0-9\.\-_]{1,}\@([a-zA-Z0-9\-_]{1,}\.){1,2}[a-zA-Z]{2,4})\](.{1,})\[\/mail\]/gi,"<a href=\"mailto:$1\" class=\"reg\">$3</a>");
      TXT=TXT.replace(/\[mail=([a-zA-Z0-9\.\-_]{1,}\@([a-zA-Z0-9\-_]{1,}\.){1,2}[a-zA-Z]{2,4})\]/gi,"<a href=\"mailto:$1\" class=\"reg\">$1</a>");
      TXT=TXT.replace(/\[font=(tahoma|verdana|arial|fixedsys|telepat|courier)\](.{1,})\[\/font\]/gi,"<span style=\"font-family:$1;\">$2</span>");
      TXT=TXT.replace(/\[color=(#[0-9a-fA-F]{6}|[A-Za-z]{3,8})\](.{1,})\[\/color\]/gi,"<span style=\"color:$1;\">$2</span>");
      TXT=TXT.replace(/\[size=([0-9]{1,2})\](.{1,})\[\/size\]/gi,"<span style=\"font-size:$1pt;\">$2</span>");
      TXT=TXT.replace(/\[title\]([^[]+)\[\/title\]/gi,"<div class=\"title\">$1</div>");PTXT.innerHTML=TXT;
      PTXT.style.display='';
    break;
  }
  if(document.selection){document.selection.createRange().text=bbcode;}
  else{trg.value=before+bbcode+after;}
  //bbCheck(trg);
  return;
}
function bbdeCode(TXT){
  TXT=TXT.replace(/\n/gi,"<br>\n");TXT=TXT.replace(/\[br\]/gi,"<br>\n");
  TXT=TXT.replace(/\[b\]/gi,"<b>");TXT=TXT.replace(/\[\/b\]/gi,"</b>");TXT=TXT.replace(/\[i\]/gi,"<i>");TXT=TXT.replace(/\[\/i\]/gi,"</i>");TXT=TXT.replace(/\[u\]/gi,"<u>");TXT=TXT.replace(/\[\/u\]/gi,"</u>");
  TXT=TXT.replace(/\[URL=(http:\/\/[^[]+)\](.{1,})\[\/URL\]/gi,"<a href=\"$1\" class=\"reg\">$2</a>");TXT=TXT.replace(/\[URL\](http:\/\/[^[]+)\[\/URL\]/gi,"<a href=\"$1\" class=\"reg\">$1</a>");
  TXT=TXT.replace(/\[h(\d)\]([^[]+)\[\/h(\d)\]/gi,"<div class=\"h$1\">$2</div>");
  TXT=TXT.replace(/\[img\](.{1,})\[\/img\]/gi,"<img src=\"$1\" border=\"0\">");
  TXT=TXT.replace(/\[img=(\d)+,(\d)+\](.{1,})\[\/img\]/gi,"<img src=\"$3\" width=\"$1\" height=\"$2\" border=\"0\">");
  TXT=TXT.replace(/\[mail=([a-zA-Z0-9\.\-_]{1,}\@([a-zA-Z0-9\-_]{1,}\.){1,2}[a-zA-Z]{2,4})\](.{1,})\[\/mail\]/gi,"<a href=\"mailto:$1\" class=\"reg\">$3</a>");
  TXT=TXT.replace(/\[mail=([a-zA-Z0-9\.\-_]{1,}\@([a-zA-Z0-9\-_]{1,}\.){1,2}[a-zA-Z]{2,4})\]/gi,"<a href=\"mailto:$1\" class=\"reg\">$1</a>");
  TXT=TXT.replace(/\[font=(tahoma|verdana|arial|fixedsys|telepat|courier)\](.{1,})\[\/font\]/gi,"<span style=\"font-family:$1;\">$2</span>");
  TXT=TXT.replace(/\[color=(#[0-9a-fA-F]{6}|[A-Za-z]{3,8})\](.{1,})\[\/color\]/gi,"<span style=\"color:$1;\">$2</span>");
  TXT=TXT.replace(/\[size=([0-9]{1,2})\](.{1,})\[\/size\]/gi,"<span style=\"font-size:$1pt;\">$2</span>");
  TXT=TXT.replace(/\[title\]([^[]+)\[\/title\]/gi,"<div class=\"title\">$1</div>");
  return TXT;
}
function mailtest(mail){
  var ret=/^[a-zA-Z0-9\.\-_]{1,}\@([a-zA-Z0-9\-_]{1,}\.){1,2}[a-zA-Z]{2,4}$/.test(mail);
  return(ret);
}


function checkForm(frm){
  switch(frm.name){
    case'topicForm':
      if(typeof(frm.ttl)!=un){if(!frm.ttl.value.length){alert('Вы не вписали заголовок.');return(false);}}
      if(typeof(frm.cnt)!=un){if(!frm.cnt.value.length){alert('Вы не вписали текст.');return(false);}}
    break;
  }
  return(true);
}



function arlecchino_news_script(){
  document.write('<div id="MCD" style="overflow:hidden;">');document.write('<div style="position:relative;top:0px;left:0px;" id="content">');
  document.write('<table cellpadding="8" cellspacing="0" border="0" width="100%"><tr><td>');
  if(ARNewsAd){document.write('<div class="alp">');document.write('[ <a href="javascript:admin_news_edit(\''+ARNewsID+'\');" class="ctrlAdm">текст</a>');
    if(ARNewsAdPH){document.write(' | <a href="javascript:admin_image_list(\''+ARNewsPhotoID+'\',1);" class="ctrlAdm">фото</a>');}
    document.write(' ]</div>');}
  document.write('<div class="news_date">'+ARNewsDate+'</div>');document.write('<div class="news_ttl">'+ARNewsTitle+'</div>');
  document.write('<div class="news_text">'+bbdeCode(ARNewsText)+'</div>');document.write('</td></tr></table></div></div>');
}

function arlecchino_news_archive_script(){
  document.write('<div id="MCD" style="overflow:hidden;">');document.write('<div style="position:relative;top:0px;left:0px;" id="content">');
  document.write('<table cellpadding="8" cellspacing="0" border="0" width="713">');document.write('<tr><td colspan="4" class="newsarchcell">'+ARNATTL+'</td></tr>');
  if(ARNAAd&&ARNAAdPH){document.write('<tr><td colspan="4"><div class="alp">[ <a href="javascript:admin_image_list(\''+ARNAPhotoID+'\',1);" class="ctrlAdm">фото</a> ]</div></td></tr>');}
  if(ARNALyears.length){
    for(var nay=0;nay<ARNALyears.length;nay++){var c=0;var year=ARNALyears[nay];
      document.write('<tr><td colspan="4" class="newsarchcell">'+year+'</td></tr>');
      for(var i=0;i<ARNAL[year].length;i++){if(c==0){document.write('<tr>');}
        document.write('<td valign="top" onMouseOver="nasw(this,1);" onMouseOut="nasw(this,0);" width="25%"');
        if(parseInt(ARNAL[year][i]['clickable'])){document.write(' onClick="window.location=\''+ARNAL[year][i]['path']+ARNAL[year][i]['id']+'\';" style="cursor:pointer;"');}
        document.write('>');
        if(parseInt(ARNAL[year][i]['clickable'])){document.write('<a href="'+ARNAL[year][i]['path']+ARNAL[year][i]['id']+'">'+ARNAL[year][i]['text']+'</a>');}
        else{document.write(ARNAL[year][i]['text']);}
        document.write('</td>');
        if(c==3){document.write('</tr>');c=0;}else{c++;}
      }
    }
  }
  document.write('</table></div></div>');
}

function arlecchino_left_panel(){
  document.write('<div id="ACCMDIV" style="overflow:hidden;">');
  document.write('<div style="height:'+((accordOpen=='ACCsec2')?'18':'424')+'px;overflow:hidden;" id="ACCsec1">');
  document.write('<div class="lpttl"><img src="img/'+LPuserlang+'/'+LPsweetch+'/announcements.gif" width="169" height="18" border="0" alt="анонсы" onMouseOver="accord(\'ACCsec1\');" onMouseOut="accord(\'ACCsec1\',true);"></div>');
  document.write('<div class="lpcnt" style="z-index:10;">');
  document.write('<img src="img/'+LPuserlang+'/'+LPsweetch+'/accshade.gif" width="169" height="9" border="0" id="sec1sh" alt=""><br>');
  if(LPannounce.length){
    for(var i=0;i<LPannounce.length;i++){document.write('      <div class="news" onMouseOver="ovrNews(this,1);" onMouseOut="ovrNews(this,0);"');
      if(parseInt(LPannounce[i]['clickable'])){document.write(' onClick="window.location=\'/announce-'+LPannounce[i]['id']+'\';" style="cursor:pointer;"');}
      document.write('>');
      if(parseInt(LPannounce[i]['clickable'])){document.write('<a href="/announce-'+LPannounce[i]['id']+'">'+LPannounce[i]['date']+'</a><br><a href="/announce-'+LPannounce[i]['id']+'">'+LPannounce[i]['text']+'</a>');}
      else{document.write(LPannounce[i]['date']+'<br>'+LPannounce[i]['text']);}
      document.write('</div><div class="sep"><img src="img/line.gif" width="138" height="1" alt="" border="0" class="sep"></div>');
    }
  }
  document.write('</div></div>');
  document.write('<div style="height:'+((accordOpen=='ACCsec2')?'424':'18')+'px;overflow:hidden;background-image:url(img/lpbg.jpg);" id="ACCsec2">');
  document.write('<div class="lpttl"><img src="img/'+LPuserlang+'/'+LPsweetch+'/news.gif" width="169" height="18" border="0" alt="новости" onMouseOver="accord(\'ACCsec2\');" onMouseOut="accord(\'ACCsec2\',true);"></div>');
  document.write('<div class="lpcnt" style="z-index:11;">');
  document.write('<img src="img/'+LPuserlang+'/'+LPsweetch+'/accshade.gif" width="169" height="9" border="0" id="sec2sh" alt=""><br>');
  if(LPnews.length){
    for(var i=0;i<LPnews.length;i++){document.write('<div class="news" onMouseOver="ovrNews(this,1);" onMouseOut="ovrNews(this,0);"');
      if(parseInt(LPnews[i]['clickable'])){document.write(' onClick="window.location=\'/news-'+LPnews[i]['id']+'\';" style="cursor:pointer;"');}
      document.write('>');
      if(parseInt(LPnews[i]['clickable'])){document.write('<a href="/news-'+LPnews[i]['id']+'">'+LPnews[i]['date']+'</a><br><a href="/news-'+LPnews[i]['id']+'">'+LPnews[i]['text']+'</a>');}
      else{document.write(LPnews[i]['date']+'<br>'+LPnews[i]['text']);}
      document.write('</div><div class="sep"><img src="img/line.gif" width="138" height="1" alt="" border="0" class="sep"></div>');
    }
  }
  document.write('<div class="news" onMouseOver="ovrNews(this,1);" onMouseOut="ovrNews(this,0);" onClick="window.location=\'/news-archive\';" style="cursor:pointer;"><a href="/news-archive">'+LPnewsArchive+'</a></div>');
  document.write('</div></div><div class="lpbimg"><img src="img/leftbottom.gif" width="169" height="4" border="0" alt=""></div></div>');
}

function arlecchino_page_script(){
  document.write('<div id="MCD" style="overflow:hidden;">');document.write('<div id="content" style="position:relative;top:0px;left:0px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="500"><tr><td>');
  if(ARPageAd){document.write('<div class="alp">[ <a href="javascript:admin_page_edit(\''+ARPageID+'\');" class="ctrlAdm">текст</a>');
    if(ARPageAdPH){document.write(' | <a href="javascript:admin_image_list(\''+ARPagePhotoID+'\',1);" class="ctrlAdm">фото</a>');}
    document.write(' ]</div>');}
  document.write(bbdeCode(ARPageText));document.write('</td></tr></table></div></div>');
}

function arlecchino_video(SWEETCH,VIDEOFILE,AUTOPLAY){
  if(AC_FL_RunContent&&DetectFlashVer(9,0,0)){
    AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
      'width','320','height','286','src','/videoplayer','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer',
      'align','middle','play','true','loop','true','scale','showall','wmode','transparent','devicefont','false',
      'id','/videoplayer','bgcolor','#585553','name','videoplayer','menu','true','allowFullScreen','false',
      'allowScriptAccess','sameDomain','movie','videoplayer','salign','','flashVars','site='+SWEETCH+'&video_file='+VIDEOFILE+'&autoplay='+AUTOPLAY);
  }else{document.write('Для просмотра видео необходима поддержка Adobe Flash.<br><a href="http://www.macromedia.com/go/getflashplayer/" style="text-decoration:underline;">Загрузите последнюю версию проигрывателя Flash.</a>');}
}

function arlecchino_video_list(){
  document.write('<div id="videoScrollMouse" style="overflow:hidden;" onmouseover="vSpp(this,event,true);" onmousemove="vSpp(this,event,true);" onmouseout="outVL(this,event);">');
  document.write('<div id="videoScrollDiv" style="position:absolute;top:0px;left:0px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">');
  document.write('<tr>');document.write('<td class="videoScrollCell" valign="top">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" id="videoScrollTable">');document.write('<tr>');
  document.write('<td><img src="img/video/left.gif" width="3" height="94" border="0" alt=""></td>');
    for(var i=0;i<ARVL.length;i++){
      document.write('<td class="vidpv" valign="top"><a href="'+ARVL[i]['link']+'"><img src="'+ARVL[i]['img']+'" width="107" height="78" border="0" class="vidpvi" alt="'+ARVL[i]['alt']+'" onMouseOver="shint(this,\''+ARVL[i]['alt']+'\');"></a></td>');
      document.write('<td><img src="img/video/right.gif" width="3" height="94" border="0" alt=""></td>');}
  document.write('</tr>');document.write('</table>');document.write('</td>');document.write('</tr>');
  document.write('</table>');document.write('</div>');document.write('</div>');
}

function arlecchino_decor_list(){
  document.write('<div id="videoScrollMouse" style="overflow:hidden;" onmouseover="vSpp(this,event,true);" onmousemove="vSpp(this,event,true);" onmouseout="outVL(this,event);">');
  document.write('<div id="videoScrollDiv" style="position:absolute;top:0px;left:0px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">');
  document.write('<tr>');document.write('<td class="videoScrollCell" valign="top">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" id="videoScrollTable">');document.write('<tr>');
  document.write('<td><img src="img/video/left.gif" width="3" height="94" border="0" alt=""></td>');
    for(var i=0;i<ARDL.length;i++){
      document.write('<td class="vidpv" valign="top"><a href="'+ARDL[i]['link']+'"><img src="'+ARDL[i]['img']+'" width="107" height="78" border="0" class="vidpvi" alt="'+ARDL[i]['alt']+'" onMouseOver="shint(this,\''+ARDL[i]['alt']+'\');"></a></td>');
      document.write('<td><img src="img/video/right.gif" width="3" height="94" border="0" alt=""></td>');}
  document.write('</tr>');document.write('</table>');document.write('</td>');document.write('</tr>');
  document.write('</table>');document.write('</div>');document.write('</div>');
}

function arlecchino_listing_script(){
  document.write('<div id="MCD" style="overflow:hidden;">');document.write('  <div style="position:relative;top:0px;left:0px;" id="content">');
  if(ARListAd){document.write('<div class="alp">[ <a href="javascript:admin_list_edit(\''+ARListID+'\');" class="ctrlAdm">текст</a>');
    if(ARListAdPH){document.write(' | <a href="javascript:admin_image_list(\''+ARListPhotoID+'\',1);" class="ctrlAdm">фото</a>');}
    document.write(' ]</div>');}
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%">');document.write('      <tr>');
  document.write('<td width="33%" valign="top">'+ARList1+'</td>');document.write('<td width="33%" valign="top">'+ARList2+'</td>');
  document.write('<td width="33%" valign="top">'+ARList3+'</td>');document.write('</tr>');document.write('</table>');
  document.write('</div>');document.write('</div>');
}

function arlecchino_vacancy_script(){
  scrWndH=198;scrWndT='vacancy';
  document.write('<div class="MCD" style="overflow:hidden;"><div style="position:relative;top:0px;left:0px;">');
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td>');
  document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td width="33%" valign="top">');
  document.write('<table cellpadding="2" cellspacing="0" border="0" width="100%">');
  if(vacancyAd){document.write('<tr><td>');document.write('<div class="alp">[ <a href="javascript:admin_vacancy_list(\''+vacancyID+'\');" class="ctrlAdm">вакансии</a>');
    if(vacancyAdPH){document.write(' | <a href="javascript:admin_image_list(\''+vacancyPhotoID+'\',1);" class="ctrlAdm">фото</a>');}document.write(' ]</div>');document.write('</td></tr>');}
  if(vacancy_list.length){for(var i=0;i<vacancy_list.length;i++){
    if(parseInt(vacancy_list[i]['active'])){document.write('<tr><td style="font-size:10pt;text-decoration:underline;color:#FFFFFF;">'+(vacancy_list[i]['text'])+'</td></tr>');}
    else{document.write('<tr><td><a href="/vacancy-'+vacancy_list[i]['id']+'" style="font-size:10pt;">'+(vacancy_list[i]['text'])+'</a></td></tr>');}}}
  document.write('</table></td><td valign="top" width="67%" style="padding:4px;">');
  document.write('<div id="vacHandler"><div id="content" style="position:absolute;top:0px;width:100%;"><span>'+bbdeCode(vacancyText)+'</span></div></div></td>');
  document.write('<td width="8" valign="top"><div id="mScroller"></div></td>');
  document.write('</tr>');
  document.write('<tr><td></td><td colspan="2">');
  if(parseInt(vacancyAnk)&&vacancyID){document.write('<a href="/anketa-'+vacancyID+'" target="_blank"><img src="img/fillform_ru.gif" width="200" height="25" border="0" alt="заполнить анкету"></a>');}
  if(vacancyAd){document.write(' | <a href="javascript:admin_vacancy_anklist('+vacancyID+');">список анкет</a> | <a href="javascript:admin_vacancy_list('+vacancyID+');">редактировать</a>');}
  document.write('</td></tr></table></td></tr></table></div></div>');
}

function handle(delta){
  if(scrObj){var scrMove;if(delta<0){scrMove=false;}else{scrMove=true;}
    if(scrLim=parseInt(scrObj.clientHeight)){}else if(scrLim=parseInt(scrObj.firstChild.clientHeight)){};
    if(scrLim>scrWndH){scrLim=-1*(scrLim-scrWndH);var pos=parseInt(scrObj.style.top);
      if(scrMove===false){if((pos-scrStep)<=scrLim){pos=scrLim;}else{pos-=scrStep;};scrObj.style.top=pos+'px';}
      else if(scrMove===true){if((pos+scrStep)>=0){pos=0;}else{pos+=scrStep;};scrObj.style.top=pos+'px';}}}
}
function wheel(event){
  var delta=0;if(!event){event=window.event;}
  if(event.wheelDelta){delta=event.wheelDelta/120;}
  if(window.opera){delta=delta;}else if(event.detail){delta=-event.detail/3;}
  if(delta){handle(delta);};if(event.preventDefault){event.preventDefault();};event.returnValue=false;
}

function mInit(){DL=true;
  if(mScr()&&scrObj){if(scrObj.addEventListener){scrObj.addEventListener('DOMMouseScroll',wheel,false);};scrObj.onmousewheel=wheel;}
  if(window.Event){document.captureEvents(Event.MOUSEMOVE);};
  document.onmousemove=getXY;
}
function catSecOvr(obj,ev){var tr=obj.parentNode;
  for(var i=0;i<tr.cells.length;i++){
    switch(ev.type){
      case'mouseover':tr.cells[i].style.backgroundColor='#000000';tr.cells[1].innerHTML='<img src="img/catarr.gif" width="10" height="10" border="0">';break;
      case'mouseout':tr.cells[i].style.backgroundColor='';tr.cells[1].innerHTML='';break;
      case'click':break;}}
}
function catItemOvr(obj,ev){var tr=obj.parentNode;
  for(var i=0;i<tr.cells.length;i++){
    switch(ev.type){
      case'mouseover':tr.cells[i].style.backgroundColor='#000000';break;
      case'mouseout':tr.cells[i].style.backgroundColor='';break;
      case'click':break;}}
}
var videoScrollW;var videoScrollL=744;var videoScrollStp=3;
var vst=false;var vsd=false;var vsmvdir=0;var msmid=false;
function vSpp(obj,ev,tm){
  if(!vst){vst=document.getElementById('videoScrollTable');}
  if(!vsd){vsd=document.getElementById('videoScrollDiv');}
  videoScrollW=vst.clientWidth;var xyobj=obj;
  var xoff=ev.pageX-obj.offsetLeft;var yoff=ev.pageY-obj.offsetTop;
  while(xyobj=xyobj.offsetParent){xoff-=xyobj.offsetLeft;yoff-=xyobj.offsetTop;};var xpos=xoff;var ypos=yoff;
  if((typeof(ev.offsetX)!=un)&&((ev.offsetY)!=un)){xpos=ev.offsetX;ypos=ev.offsetY;ev=ev.target||ev.srcElement;
    while(ev&&(ev.id!=obj.id)){xpos+=ev.offsetLeft;ypos+=ev.offsetTop;ev=ev.offsetParent;}}
  if((xpos>=0)&&(xpos<=100)){vsmvdir=-1;}else if((xpos>=(videoScrollL-100))&&(xpos<=(videoScrollL))){vsmvdir=1;}else{vsmvdir=0;}
  if(typeof(tm)==un){var tm=false;}
  vSmv(tm);
}
function vSmv(tm){clearTimeout(msmid);msmid=false;
  if(vsmvdir!=0){var mvlim=-1*(videoScrollW-videoScrollL);
    var cp=parseInt(vsd.style.left);var lft=0;var np=cp-(videoScrollStp*vsmvdir);
    if((np<=0)&&(np>=mvlim)){lft=np;}else{if(vsmvdir<0){lft=0;}else{lft=(videoScrollL-videoScrollW);};tm=false;}
    vsd.style.left=lft+'px';if(tm){msmid=setTimeout('vSmv(true);',5);}
  }
}
function outVL(obj,ev){var xoff=ev.pageX-obj.offsetLeft;var yoff=ev.pageY-obj.offsetTop;var xyobj=obj;
  while(xyobj=xyobj.offsetParent){xoff-=xyobj.offsetLeft;yoff-=xyobj.offsetTop;};var xpos=xoff;var ypos=yoff;
  if((typeof(ev.offsetX)!=un)&&((ev.offsetY)!=un)){xpos=ev.offsetX;ypos=ev.offsetY;ev=ev.target||ev.srcElement;
    while(ev&&(ev.id!=obj.id)){xpos+=ev.offsetLeft;ypos+=ev.offsetTop;ev=ev.offsetParent;}}
  if(((xpos<100)||(xpos>videoScrollW))&&((ypos<=0)||(ypos>100))){clearTimeout(msmid);msmid=false;}
}

//CATALOGUE
function getHeight(){var myWidth=0,myHeight=0;
  if(typeof(window.innerWidth)=='number'){myWidth=window.innerWidth;myHeight=window.innerHeight;}
  else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;}
  else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
  return(myHeight);
}
var clh=getHeight();if(clh){clh-=225;if(ammode){clh-=65;}}if(clh<=0){clh=false;}
var catplate=false;var catsec=false;var dsttop=false;var scrcatprc=false;var wlz=false;
function scrCatalog(id){if(scrcatprc){return;}
  if(!catplate){catplate=document.getElementById('catplate');}
  catsec=document.getElementById(id);dsttop=parseInt(catsec.offsetTop);
  if((dsttop<0)||wlz){wlz=true;dsttop=Math.abs(parseInt(catplate.style.top))-(-1*dsttop);}
  scrcatprc=true;scrCatalog_r();
}
function scrCatalog_r(){
  var t=Math.abs(parseInt(catplate.style.top));var stp=0;
  if(t<dsttop){
    if((dsttop-t)>800){stp=80;}else if((dsttop-t)>400){stp=40;}else if((dsttop-t)>100){stp=20;}else if((dsttop-t)>25){stp=10;}else{stp=2;}
    t+=stp;if(t>=dsttop){t=dsttop;catplate.style.top='-'+t+'px';scrcatprc=false;return;}
  }else if(t>dsttop){
    if((t-dsttop)>800){stp=80;}else if((t-dsttop)>400){stp=40;}else if((t-dsttop)>100){stp=20;}else if((t-dsttop)>25){stp=10;}else{stp=2;}
    t-=stp;if(t<=dsttop){t=dsttop;catplate.style.top='-'+t+'px';scrcatprc=false;return;}
  }else{scrcatprc=false;return;}
  catplate.style.top='-'+t+'px';
  setTimeout('scrCatalog_r();',15);
}
function createCatWnd(wndY,wndW,wndTitle,wndText,noShade,askClose,wndH){
  if(!wndY){wndY=155;};if(!wndW){wndW=400;};if(!wndText){wndText='Загрузка...';};var n=Math.round(Math.random()*9999)+Math.round(Math.random()*9999);
  var shade=false;if(!noShade){shade=document.createElement('DIV');shade.id='wndShade'+n;shade.className='wndShade';shade.style.zIndex=++zndx;document.body.appendChild(shade);}
  
  var wnd=document.createElement('DIV');wnd.id='wnd'+n;wnd.style.position='absolute';wnd.style.minWidth='500px';wnd.style.textAlign='center';
  wnd.style.left='0px';wnd.style.width='100%';wnd.style.display='none';wnd.style.top=wndY+'px';wnd.style.zIndex=++zndx;document.body.appendChild(wnd);

  var wndNavi=document.createElement('DIV');wndNavi.id='wndNavi'+n;
  wnd.appendChild(wndNavi);
  
  wndNavi.style.position='absolute';wndNavi.style.top='-40px';wndNavi.style.left='0px';wndNavi.style.zIndex=++zndx;
  wndNavi.style.fontFamily='verdana,tahoma,arial,sans-serif';wndNavi.style.fontSize='8pt';
  wndNavi.innerHTML='<div id="wndMenu'+n+'" style="position:relative;margin:auto;width:198px;height:32px;"><img src="img/cat/navplate.png" width="198" height="32" border="0">'+
  '<div id="wndLeft'+n+'" style="position:absolute;left:3px;top:3px;"><img src="img/cat/left.gif" width="26" height="26" border="0" style="cursor:pointer;"></div>'+
  '<div id="wndClose'+n+'" style="position:absolute;left:30px;top:3px;"><img src="img/cat/close.gif" width="26" height="26" border="0" style="cursor:pointer;" onClick="killWnd(\''+n+'\''+(((typeof(askClose)!=un)&&askClose)?',1':'')+');"></div>'+
  '<div id="wndRight'+n+'" style="position:absolute;left:57px;top:3px;"><img src="img/cat/right.gif" width="26" height="26" border="0" style="cursor:pointer;"></div>'+
  '<div id="wndPos'+n+'" style="position:absolute;right:16px;top:9px;color:#000000;"><b>0</b> / 0</div>'+
  '</div>';
  wndNavi.style.width='100%';wndNavi.style.minWidth='198px';
  wndNavi.style.bottom='-42px';wndNavi.style.textAlign='center';

  var wndCnt=document.createElement('DIV');wndCnt.id='wndCnt'+n;wndCnt.style.position='relative';wndCnt.style.textAlign='left';
  wndCnt.style.marginLeft='auto';wndCnt.style.marginRight='auto';wndCnt.style.width=wndW+'px';wndCnt.style.zIndex=++zndx;
  wndCnt.style.border='0px #ffffff solid';wndCnt.style.backgroundColor='#FFFFFF';wndCnt.style.padding='6px';wnd.appendChild(wndCnt);
  wndCnt.style.width='300px';wndCnt.style.height='400px';
  
  var wndHTML=document.createElement('DIV');wndHTML.style.position='relative';wndHTML.style.zIndex=++zndx;wndHTML.style.height='100%';
  wndHTML.style.fontFamily='verdana,tahoma,arial,sans-serif';wndHTML.style.border='0px #ffffff solid';wndHTML.style.fontSize='8pt';
  wndHTML.innerHTML='<div id="wndHTML'+n+'" style="border-top:0px #ffffff solid;color:#000000;"><img src="img/ajax.gif" border="0"></div>';
  
  wndCnt.appendChild(wndHTML);document.body.appendChild(wnd);wnd.style.display='';wndList[wndList.length]=n;
  var trgHTML=document.getElementById('wndHTML'+n);var trgTitle=document.getElementById('wndTitle'+n);
  wndObj[n]=new JSWND(n,wnd,wndCnt,trgTitle,wndHTML,trgHTML,shade);
  wndObj[n].wndNavi=wndNavi;shsw(1);return(wndObj[n]);
}
var nwnd=false;
var catloadfunc=function(a,t){var resp=a.responseText;var sys=resp.substr(0,resp.indexOf('|'));
  sys=sys.split(':');sys[0]=parseInt(sys[0]);sys[1]=parseInt(sys[1]);
  if(sys[2]){sys[2]=parseInt(sys[2]);}if(sys[3]){sys[3]=parseInt(sys[3]);}
  if(sys[2]&&sys[3]){sys[2]+=parseInt(nwnd.wndHTML.style.padding)*2;sys[3]+=parseInt(nwnd.wndHTML.style.padding)*2;catwndresize(nwnd.id,sys[2],sys[3]);}
  nwnd.catid='';nwnd.itmid='';nwnd.part=sys[0];nwnd.parts=sys[1];
  var wndPos=document.getElementById('wndPos'+nwnd.id);
  if(wndPos){wndPos.innerHTML='<b>'+sys[0]+'</b> / '+sys[1];}
  var wndLeft=document.getElementById('wndLeft'+nwnd.id);
  if(wndLeft){if(sys[0]>1){switch(nwnd.cmd){
        case'video':wndLeft.firstChild.onclick=function(){cat_item_video(nwnd.cid,nwnd.part-1);};break;
        case'image':wndLeft.firstChild.onclick=function(){cat_item_foto(nwnd.cid,nwnd.part-1);};break;
        case'text':wndLeft.firstChild.onclick=function(){cat_item_info(nwnd.cid,nwnd.part-1);};break;}
      wndLeft.style.display='block';}else{wndLeft.style.display='none';}}
  var wndRight=document.getElementById('wndRight'+nwnd.id);
  if(wndRight){if(sys[0]<sys[1]){switch(nwnd.cmd){
        case'video':wndRight.firstChild.onclick=function(){cat_item_video(nwnd.cid,nwnd.part+1);};break;
        case'image':wndRight.firstChild.onclick=function(){cat_item_foto(nwnd.cid,nwnd.part+1);};break;
        case'text':wndRight.firstChild.onclick=function(){cat_item_info(nwnd.cid,nwnd.part+1);};break;}
      wndRight.style.display='block';}else{wndRight.style.display='none';}}
  resp=resp.substr(resp.indexOf('|')+1);t.innerHTML=resp;
  if(catwndresizeproc){t.style.display='none';}
  return(ajax0());
}
function cat_item_info(cid,part,lng){
  if(!nwnd){nwnd=createCatWnd();nwnd.kill=function(){nwnd=false;return(ajax0());};}
  nwnd.wndHTML.style.padding='32px';nwnd.cmd='text';
  if(to(cid)){nwnd.cid=cid;}else if(!to(nwnd.cid)){nwnd.cid=0;}
  if(to(part)){nwnd.part=part;}else if(!to(nwnd.part)){nwnd.part=1;}
  if(to(lng)){nwnd.lng=lng;}else{nwnd.lng=false;}
  ajaxget('/tools/catalogue.php?cmd='+nwnd.cmd+'&part='+nwnd.part+'&itemid='+nwnd.cid+(nwnd.lng?'&lang='+nwnd.lng:''),'wndHTML'+nwnd.id,false,false,catloadfunc);
}
function cat_item_foto(cid,part){
  if(!nwnd){nwnd=createCatWnd();nwnd.kill=function(){nwnd=false;return(ajax0());};}
  nwnd.wndHTML.style.padding='0px';nwnd.cmd='image';
  if(to(cid)){nwnd.cid=cid;}else if(!to(nwnd.cid)){nwnd.cid=0;}
  if(to(part)){nwnd.part=part;}else if(!to(nwnd.part)){nwnd.part=1;}
  ajaxget('/tools/catalogue.php?cmd='+nwnd.cmd+'&part='+nwnd.part+'&itemid='+nwnd.cid,'wndHTML'+nwnd.id,false,false,catloadfunc);
}
function cat_item_video(cid,part){
  if(!nwnd){nwnd=createCatWnd();nwnd.kill=function(){nwnd=false;return(ajax0());};}
  nwnd.wndHTML.style.padding='0px';nwnd.cmd='video';
  if(to(cid)){nwnd.cid=cid;}else if(!to(nwnd.cid)){nwnd.cid=0;}
  if(to(part)){nwnd.part=part;}else if(!to(nwnd.part)){nwnd.part=1;}
  ajaxget('/tools/catalogue.php?cmd='+nwnd.cmd+'&part='+nwnd.part+'&itemid='+nwnd.cid,'wndHTML'+nwnd.id,false,false,catloadfunc);
}
var catwndresizeproc=false;var cwrp_wnd=false;var cwrp_wndCnt=false;var cwrp_wndNavi=false;var cwrp_wndHTML=false;
var cwrp_tw=false;var cwrp_th=false;var cwrp_ws=false;var cwrp_hs=false;
function catwndresize(id,w,h,ws,hs){
  if(catwndresizeproc){return;}
  cwrp_wnd=document.getElementById('wnd'+id);
  cwrp_wndCnt=document.getElementById('wndCnt'+id);
  cwrp_wndNavi=document.getElementById('wndNavi'+id);
  cwrp_wndHTML=document.getElementById('wndHTML'+id);
  if(cwrp_wndCnt){
    cwrp_tw=w;cwrp_th=h;
    if((typeof(ws)!=un)&&ws){cwrp_ws=ws;}else{cwrp_ws=15;}
    if((typeof(hs)!=un)&&hs){cwrp_hs=hs;}else{cwrp_hs=15;}
    if((typeof(cwrp_wndCnt.style.width)==un)||!parseInt(cwrp_wndCnt.style.width)){cwrp_wndCnt.style.width='1px';}
    if((typeof(cwrp_wndCnt.style.height)==un)||!parseInt(cwrp_wndCnt.style.height)){cwrp_wndCnt.style.height='1px';}
    catwndresizeproc=true;catwndresize_r();
  }
}
function catwndresize_r(){
  var movedw=false;var movedh=false;
  var cw=parseInt(cwrp_wndCnt.style.width);
  var ch=parseInt(cwrp_wndCnt.style.height);
  if(cw>cwrp_tw){movedw=true;cw-=cwrp_ws;if(cw<cwrp_tw){cw=cwrp_tw;}}
  else if(cw<cwrp_tw){movedw=true;cw+=cwrp_ws;if(cw>cwrp_tw){cw=cwrp_tw;}}
  if(movedw){cwrp_wndCnt.style.width=cw+'px';}
  if(ch>cwrp_th){movedh=true;ch-=cwrp_hs;if(ch<cwrp_th){ch=cwrp_th;}}
  else if(ch<cwrp_th){movedh=true;ch+=cwrp_hs;if(ch>cwrp_th){ch=cwrp_th;}}
  if(movedh){cwrp_wndCnt.style.height=ch+'px';/*cwrp_wndNavi.style.top=(ch+20)+'px';*/}
  if(movedw||movedh){cwrp_wnd.style.display='none';cwrp_wnd.style.display='';setTimeout('catwndresize_r();',15);}
  else{catwndresizeproc=false;cwrp_wndHTML.style.display='block';return;}
}
