
_editor_lang = "en";
_editor_url = "/blog/html_area";
var agent =  navigator.userAgent.toLowerCase();
var editors = {'descr' : null};
function initEditor(j) {
  for (var i in editors)
  {
  editors[i] = new HTMLArea("ta_"+i);
  editors[i].config.pageStyle = "@import url(/blog/blog.css);\n";
  editors[i].generate();
  }
  return false;
  el = document.getElementById('onload');
}
function exitEditors()
{
  for (var i in editors)
  {
    try { editors[i]._textArea.value = editors[i].getHTML(); } catch(e) {}
  }
}
var x, y, dx;
var basedOn = 'id';
function getPos(el)
{
  var r = { x: el.offsetLeft, y: el.offsetTop };
  if (el.offsetParent)
  {
    var tmp = getPos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
}
var lastTip = null;
function helpLoaded()
{
  if (!lastTip) return;
  loadedTips[lastTip] = document.getElementById('tips').innerHTML = document.getElementById('help_frame').contentWindow.document.body.innerHTML;
}
var loadedTips = new Array();
function listenEvents(evt) 
{
  evt = (evt) ? evt : ((event) ? event : null);
  if (evt)
  {
   var el = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   var tipsEl    = document.getElementById('tips');
   if (el && tipsEl)
   {
     if (el[basedOn] && (str = new String(el[basedOn])) && str.substring(0,5)=='HINT:') 
     {
       r = getPos(el);
       x = r.x;
       y = r.y;
       if (el.height) y += el.height + 10; else y += 20;
       tipsEl.innerHTML = str.substring(5, str.length);
       tipsEl.style.visibility = 'visible';
       tipsEl.style.left = (x) + 'px';
       tipsEl.style.top = (y) + 'px';
     }
     else if (el[basedOn] && (str = new String(el[basedOn])) && str.substring(0,5)=='HELP:') 
     {
       r = getPos(el);
       x = r.x;
       y = r.y;
       if (el.height) y += el.height + 10; else y += 20;
       if ((window.innerWidth && (x > window.innerWidth/2)) || (document.body.clientWidth && (x > document.body.clientWidth/2))) x = x - 300;
       tip = str.substring(5, str.length);
       lastTip = tip;
       if (loadedTips[tip])
       {
         tipsEl.innerHTML = loadedTips[tip];
       }
       else
       {
         frame = document.getElementById('help_frame');
         if (!frame)
         {
           frame = document.createElement('iframe');
           frame.id = 'help_frame';
           try { frame.setAttribute('id','help_frame') } catch(e) {}
           document.body.appendChild(frame);
           frame.height = 1;
           frame.width = 1;
           frame.style.visibility = 'hidden';
           frame.onload = function() {loadedTips[lastTip] = document.getElementById('tips').innerHTML = document.getElementById('help_frame').contentWindow.document.body.innerHTML;}
         }
         if (frame.src != '/help.php?hidden=1&page='+tip) frame.src = '/help.php?hidden=1&page='+tip;
         tipsEl.innerHTML = 'Загружается';
       }
       tipsEl.style.visibility = 'visible';
       tipsEl.style.left = (x) + 'px';
       tipsEl.style.top = (y) + 'px';
     }
     else
     {
       tipsEl.style.visibility = 'hidden';
       tipsEl.style.left = '0px';
       tipsEl.style.top = '0px';
     }
   }
  }
}
function limit_access(el)
{
  path = new String(document.location.href);
  path = path.replace(/\?limit_acc=[01-9]*/gi, '').replace(/&limit_acc=[01-9]*/gi, '');
  val = el.options[el.selectedIndex].value;
  if (val != 0)
  {
    if (path.indexOf('?') == -1) path += '?'; else path += '&';
    path += 'limit_acc='+val;
  }
  document.location.href = path;
}
function openPreview(src, w, h)
{
  tmpWindow = window.open("", "_popup", "width="+w+",height="+h+",status=no,toolbar=no,menubar=no");
  tmpWindow.document.open();  
  tmpWindow.document.write('<html><head><title>Фотографии</title></head><body style="background:#FFFFFF; margin:0px; padding:0px;"><img src=' + src + ' border="0" /></body></html>');
  tmpWindow.document.close();
}
function hide_help(id)
{
  document.getElementById('help').style.display = 'none';
  _closed = getCookie('closed_helps');
  if (_closed) _closed += ',' + id; else _closed = id;
  _exp = new Date('1 january 2100 01:01:01')
  setCookie('closed_helps',_closed, _exp,'/')
}
function setCookie(pv_nom,pv_valor,pv_expira,pv_path,domain,secure){
	document.cookie = pv_nom + '=' + escape(pv_valor) + ((pv_expira == null)?'':('; expires=' + pv_expira.toGMTString())) + ((pv_path)?';path=' + pv_path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':'');
}
function getCookie(pv_nom) {
    if(document.cookie == '') {
	return false; 
    } else {
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(pv_nom);
	var NN2Hack = firstChar + pv_nom.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) {
	    firstChar += pv_nom.length + 1;
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else {
	    return false;
	}
    }	
}
function quick_name()
{
  if (document.getElementById('quick_name')) document.getElementById('quick_name').style.display='';
  if (document.getElementById('quick_name2')) document.getElementById('quick_name2').style.display='none';
}
function do_resize()
{
  try {
    menu2_spacer = document.getElementById('menu2_spacer');
    menu1_spacer = document.getElementById('menu1_spacer');
    content_spacer = document.getElementById('content_spacer');
    content_block  = document.getElementById('content_block');
  } catch(e) {}
  if (!content_spacer)
  {
    window.setTimeout('do_resize', 100);
    return false;
  }
  fl = 'height';
  /*
  for (i in content_block.style)
  {
    if (i == 'minHeight') fl = 'minHeight';
  }
  */
  if (window.innerWidth) fl = 'minHeight';
  if (menu1_spacer && menu1_spacer.offsetTop > content_spacer.offsetTop)
  {
    content_block.style[fl] = menu1_spacer.offsetTop + 'px';
  }
  if (menu2_spacer && menu2_spacer.offsetTop > content_spacer.offsetTop && (!menu1_spacer || menu2_spacer.offsetTop > menu1_spacer.offsetTop))
  {
    content_block.style[fl] = menu2_spacer.offsetTop + 'px';
  }
}
