// helper functions
var mon = new Array("января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря")
var selection = null;
var i=0;
newCol='';
function expand(node, a)
{
        ul = document.getElementById("ul" + node);
        img = document.getElementById("img" + node);

        if (ul != null && img != null && ul.className != null && ul.innerHTML != null)
        {
                str = img.src;
                if ((ul.className == "Shown") || (ul.className == ""))
                {
                        ul.className = "Hidden";
                        img.src = str.substr(0, str.length-5) + "c.bmp";
                        i = img.id + "0";
                        im = document.getElementById(i);
                        im.src= im.src.substr(0, im.src.length-5) + "c.gif";
                        if (a != null) a.href = "javascript:;";
                }
                else
                        if (ul.className == "Hidden")
                        {
                                img.src = str.substr(0, str.length-5) + "o.bmp";
                                ul.className = "Shown";
                        i = img.id + "0";
                        im = document.getElementById(i);
                        im.src= im.src.substr(0, im.src.length-5) + "o.gif";
                        }

                if (ul.innerHTML == "")
                {
                        ul.innerHTML = "<DIV class='loadMsg'>&nbsp;Загрузка,&nbsp;пожалуйста&nbsp;подождите...&nbsp;</DIV>";
                        ul.className="";
                }

                if ((a != null) && ("object" == typeof(a) && (parent.window.length > 0))) {a.target = 'fra' + node;}
        }

}



function clearSelection(node)
{
        if (node != null && node.className != null)
                node.className = "";
}

function setSel(node)
{
        if (selection != null) clearSelection(selection);
        selection = node;
        if (node) node.className = "Current";
}

function loadNode(id, node)
{
        ul = document.getElementById("ul"+id);
        if (ul && node && "object" == typeof(node)) 
        {
                ul.className = "Hidden";
                ul.innerHTML = node.innerHTML;
                expand(id);
        }
}


function cont()
{
var frameset=parent.document.getElementById('home');
var conten=parent.document.getElementById('content');
if(frameset.cols!='0%,*') {
  newCol=Math.round((conten.scrollWidth*100)/frameset.scrollWidth).toString(10)+'%,*';
  frameset.cols='0%,*'; 
  parent.frames.toper.displ.src='images/displaymenu1.gif'; 
  parent.frames.toper.displ.title='Показать оглавление';
}
else {
  frameset.cols = (newCol=='NaN%,*') ? '25%,*': newCol; 
  parent.frames.toper.displ.src='images/hidemenu1.gif';
  parent.frames.toper.displ.title='Скрыть оглавление';
  }
}

function work()
{
var nam=/content|toper|footer/i;
if(parent.frames.length==0 && location.href.search(nam)<0) 
{
if(typeof window.opener!='object') setcookie(location.href);
else 
{
try
{
var op=opener.location.href;
if(op.indexOf('gilpravo')>0) {return false;}
else setcookie(location.href);
}
catch(e){}

finally
{
if(op==null) setcookie(location.href);
}
}
}
else if(parent.frames.length==0 && location.href.search(nam)>0) location='index.html';
else if(self.frames.length>1 && location.href.search(nam)>0) {if(top.frames.length==self.frames.length){top.location='index.html';}}
else if(self.frames.length>1 && location.href.search(nam)<0) {getcookie(); document.cookie='';}
}

function getcookie()
{
//Проверяется наличие Cookie
var allcookies=document.cookie;
if(allcookies=='') return false;             //если cookie нет для этой страницы
//Ищем Cookie с нужным именем
var pos=allcookies.indexOf('framnam=');
//Если нашлись cookie с этим именем, извлекаем его
if (pos==-1) return false;                   //если не нашли cookie с этим именем
var start=pos+8;                             //начало значений cookie
var end=allcookies.indexOf(";", start);      //конец значения cookie
if (end==-1) end=allcookies.length;
var value=allcookies.substring(start, end);  //извлекаем значения
var c=new Array('texts','kodex','news','Crosswords','about','mag_','ruls','price','articles','juruslugi');
for (var i=0;i<c.length; i++) {
   if(value.indexOf(c[i])>0) {
      parent.frames['text'].location=value; 
      break;
   }
}
}

function setcookie(a)
{
if(parent.frames.length==0) 
{
document.cookie='framnam='+a+';path=/';
var price=/price|about|mag_|juruslugi/i;
if (a.search(price)>0) location='index.html';
else location='../index.html';
}
}


function anonce(was,day)
{
  var now = (new Date()).getTime()
  if((now-was)/1000/60/60/24<=day)
  {
  nw=(new Date(was)).getDate();
  nw=nw+' '+mon[(new Date(was)).getMonth()];
  document.write('<span title="Обновлено '+nw+'" class=new><b>NEW</b></span>');
  }
}