/* ************************************************************************

   CMS NoteSite ver. 1.2.15

   http://www.spmo.ru

   Copyright:
     2000-2009 LLC SPMO, Russia, http://www.spmo.ru

   License:
     LGPL: http://www.gnu.org/licenses/gpl.html

   Authors:
     * Studio PMO

************************************************************************ */

window.name='index';
var search=window.location.href.lastIndexOf(window.location.search);
var indexFileName=window.location.href.substring( window.location.href.lastIndexOf('/',search)+1,search );
indexFileName=indexFileName.substring( 0,indexFileName.indexOf('.'));
if( ((indexFileName=='')||(indexFileName=='index')) && (window.location.search==""))window.location.search=index[0][1];
else if(window.location.search.split("&")[1]!=null)window.location.search=window.location.search.split("&")[0];
search=unescape(window.location.search.substr(1));
indexFileName='';
var ul=0;
var listStyleImageCollapsed=null;
var listStyleImageExpanded=null;
var listStyleImageChildrenless=null;
//---------------------------------------------------------------------------
function putMenuImg(ctgnum,img1,img2)
{
 var hrefstring='';
 for(var i=0;i<index.length;i++)
 {
  if(index[i].toString().indexOf(search)!=-1)
  {
   if (i==ctgnum)hrefstring="<img src="+img2+" onmouseover=src='"+img2+"' onmouseout=src='"+img2+"' border=0>";
   break;
  }
 }
 if (hrefstring=='')hrefstring="<img src="+img1+" onmouseover=src='"+img2+"' onmouseout=src='"+img1+"' border=0>";
 document.write(hrefstring);
}
//---------------------------------------------------------------------------
function topTitle()
{
 if(search!='')
 {
  for(var i=0;i<index.length;i++)
  {
   if(index[i].toString().indexOf(search)!=-1)
   {
    document.write(index[i][0]);
    break;
   }
  }
 }
}
function title()
{
 if (search!='')
 {
  var Caption=subTitle(index);
  if(Caption!=null)document.write(Caption);
 }
}
function subTitle(p_index)
{
 var Result=null;
 for(var i=0;i<p_index.length;i++)
 {
  if(p_index[i][1]==search)
  {
   Result=p_index[i][0];
   break;
  }
  else
  {
   if(p_index[i][p_index[i].length-1])
   {
    Result=subTitle(p_index[i][p_index[i].length-1]);
    if(Result)break;
   }
  }
 }
 return Result;
}

function showMenu(p_this,p_index)
{
  var j=document.anchors.length;
  for(var i=j;i<j+p_index.length;i++)
  {
    printMenu(i,j,i,p_this,p_index);
  }
}

function showOddMenu(p_this,p_index)
{
  var j=document.anchors.length;
  var k=j;
  for(var i=j;i<j+p_index.length;i=i+2)
  {
    printMenu(i,j,k,p_this,p_index);
    k++;  }
}

function showEvenMenu(p_this,p_index)
{
  var j=document.anchors.length;
  var k=j;
  for(var i=j+1;i<j+p_index.length;i=i+2)
  {
   printMenu(i,j,k,p_this,p_index);
   k++;  }
}

function printMenu(i,j,k,p_this,p_index)
{
   if(search!='' && p_index[i-j].toString().indexOf(search)!=-1 && p_this.leftSelectHTML!='')document.write(p_this.leftSelectHTML);
   else document.write(p_this.leftHTML);
   document.write(p_index[i-j][0].anchor('anc'+i));
   if(p_index[i-j].toString().indexOf(search)!=-1 && p_this.rightSelectHTML!='')document.write(p_this.rightSelectHTML);
   else document.write(p_this.rightHTML);
   document.anchors[k].style.fontSize=p_this.fontSize;
   document.anchors[k].style.fontWeight=p_this.fontWeight;
   document.anchors[k].style.fontFamily=p_this.fontFamily;
   document.anchors[k].href=indexFileName+"?"+p_index[i-j][1];
   if((search!="") && (p_index[i-j].toString().indexOf(search)!=-1))
   {
    document.anchors[k].onmouseover=new Function("document.anchors["+k+"].style.color='"+p_this.colorSelect+"';document.anchors["+k+"].style.textDecoration='"+p_this.textHoverDecoration+"'");
    document.anchors[k].onmouseout=new Function("document.anchors["+k+"].style.color='"+p_this.colorSelect+"';document.anchors["+k+"].style.textDecoration='"+p_this.textSelectDecoration+"'");
    document.anchors[k].style.color=p_this.colorSelect;
    document.anchors[k].style.textDecoration=p_this.textSelectDecoration;
   }
   else
   {
    document.anchors[k].onmouseover=new Function("document.anchors["+k+"].style.color='"+p_this.colorHover+"';document.anchors["+k+"].style.textDecoration='"+p_this.textHoverDecoration+"'");
    document.anchors[k].onmouseout=new Function("document.anchors["+k+"].style.color='"+p_this.color+"';document.anchors["+k+"].style.textDecoration='"+p_this.textDecoration+"'");
    document.anchors[k].style.color=p_this.color;
    document.anchors[k].style.textDecoration=p_this.textDecoration;
   }
   if(i!=(j+p_index.length-1))document.write(p_this.separatorHTML);
}

//---------------------------------------------------------------------------
// Announcement
//---------------------------------------------------------------------------
function announcements()
{
 this.templateHTML='';
 this.count=null;
 this.first=0;
 this.announce=new Array();
 this.init=initAnnouncements;
 this.initAnnounce=initAnnounce;
 this.show=showAnnouncements;
 this.showID=showAnnouncementsID;
 this.dateSort=dateSort;
}
//---------------------------------------------------------------------------
function showAnnouncementsID(id)
{
 for(var i=0;i<this.announce.length;i++)
 {
  if(this.announce[i][1]==id)
  { 
     template=this.templateHTML; 
     template=template.replace(/\$date/g,this.announce[i][2]);
     template=template.replace(/\$link/g,'?'+this.announce[i][1]);
     template=template.replace(/\$title/g,this.announce[i][0]);
     template=template.replace(/\$desc/g,this.announce[i][3]);
     document.write(template);
     break;
  }
 }
}
//---------------------------------------------------------------------------
function dateSort(a, b)
{
var ia = a[2].replace(/^(\d{2})[.\- ](\d{2})[.\- ](\d{4})/,"$3$2$1");
var ib = b[2].replace(/^(\d{2})[.\- ](\d{2})[.\- ](\d{4})/,"$3$2$1");
if (ia<ib) return 1;
if (ia>ib) return -1;
return 0; 
}
//---------------------------------------------------------------------------
function initAnnouncements()
{
 var j=0;
 var template;
 this.initAnnounce(index,j);
 this.announce.sort(dateSort);
 if (this.count==null) this.count=this.announce.length;
}
//---------------------------------------------------------------------------
function showAnnouncements()
{
 for(var i=this.first;i<this.first+this.count;i++)
 {
  if(i<this.announce.length)
  { 
     template=this.templateHTML; 
     template=template.replace(/\$date/g,this.announce[i][2]);
     template=template.replace(/\$link/g,'?'+this.announce[i][1]);
     template=template.replace(/\$title/g,this.announce[i][0]);
     template=template.replace(/\$desc/g,this.announce[i][3]);
     document.write(template);
  }
 }
}
//---------------------------------------------------------------------------
function initAnnounce(p_index,j)
{
 for(var i=0;i<p_index.length;i++)
 { 
   if(p_index[i][3]!='')
   {
   this.announce[j]=new Array();
   this.announce[j][0]=p_index[i][0];
   this.announce[j][1]=p_index[i][1];
   this.announce[j][2]=p_index[i][2];
   this.announce[j][3]=p_index[i][3];
   this.announce[j][4]=p_index[i][4];
   j++;
   }
   if(p_index[i][p_index[i].length-1])j=this.initAnnounce(p_index[i][p_index[i].length-1],j);
 }
 return j;
}

//---------------------------------------------------------------------------
// Êëàññ ìåíþ âòîðîãî óðîâíÿ
//---------------------------------------------------------------------------
function subMenu()
{
 this.colorSelect='';
 this.colorHover='';
 this.color='';
 this.fontSize='';
 this.fontFamily='';
 this.fontWeight='';
 this.textDecoration='';
 this.textSelectDecoration='';
 this.textHoverDecoration='';
 this.leftHTML='';
 this.rightHTML='';
 this.leftSelectHTML='';
 this.rightSelectHTML='';
 this.separatorHTML='';
 this.show=showSubMenu;
 this.showOdd=showOddSubMenu;
 this.showEven=showEvenSubMenu;
}
//---------------------------------------------------------------------------
function showSubMenu()
{
 var k=0;
 while(index[k].toString().indexOf(search)==-1)
 {
  k++;
  if (k==index.length) return;
 }
 var p_index=index[k][index[k].length-1];
 if(p_index!=null)showMenu(this,p_index);
}

function showOddSubMenu()
{
 var k=0;
 while(index[k].toString().indexOf(search)==-1)
 {
  k++;
  if (k==index.length) return;
 }
 var p_index=index[k][index[k].length-1];
 if(p_index!=null)showOddMenu(this,p_index);
}

function showEvenSubMenu()
{
 var k=0;
 while(index[k].toString().indexOf(search)==-1)
 {
  k++;
  if (k==index.length) return;
 }
 var p_index=index[k][index[k].length-1];
 if(p_index!=null)showEvenMenu(this,p_index);
}



//---------------------------------------------------------------------------
// Êëàññ ìåíþ âåðõíåãî óðîâíÿ
//---------------------------------------------------------------------------
function topMenu()
{
 this.colorSelect='';
 this.colorHover='';
 this.color='';
 this.fontSize='';
 this.fontFamily='';
 this.fontWeight='';
 this.textDecoration='';
 this.textSelectDecoration='';
 this.textHoverDecoration='';
 this.leftHTML='';
 this.rightHTML='';
 this.leftSelectHTML='';
 this.rightSelectHTML='';
 this.separatorHTML='';
 this.show=showTopMenu;
}
//---------------------------------------------------------------------------
function showTopMenu()
{
 showMenu(this,index);
}
//---------------------------------------------------------------------------
// Êëàññ äðåâîâèäíîãî ìåíþ
//---------------------------------------------------------------------------
function tree()
{
 this.colorSelect='';
 this.colorHover='';
 this.color='';
 this.fontSize='';
 this.fontFamily='';
 this.lineHeight='';
 this.fontWeight='';
 this.textDecoration='';
 this.textSelectDecoration='';
 this.textHoverDecoration='';
 this.show=showTree;
 this.node=node;
}
//---------------------------------------------------------------------------
function showTree()
{
 this.node(index);
}
//---------------------------------------------------------------------------
function node(p_index)
{
 document.write('<ul id=ul'+ul+'>');

 document.getElementById('ul'+ul).style.paddingLeft='1em';
 document.getElementById('ul'+ul).style.margin='0em';
 document.getElementById('ul'+ul).style.lineHeight=this.lineHeight;

 if(ul)document.getElementById('ul'+ul).style.display='none';
 else document.getElementById('ul'+ul).style.display='block';
 var oldul=ul;
 ul++;
 for(var i=0;i<p_index.length;i++)
 {
  var j=document.anchors.length;
  document.write('<li id=li'+j+'>');
  document.getElementById('li'+j).onclick=new Function("nodeClick(this)");
  document.write(p_index[i][0].anchor('anc'+j));
  document.anchors[j].style.fontSize=this.fontSize;
  document.anchors[j].style.fontFamily=this.fontFamily;
  document.anchors[j].style.fontWeight=this.fontWeight;
  document.anchors[j].href=indexFileName+"?"+p_index[i][1];
  if(p_index[i][1]==search)
  {
   document.anchors[j].onmouseover=new Function("document.anchors["+j+"].style.color='"+this.colorHover+"';document.anchors["+i+"].style.textDecoration='"+this.textHoverDecoration+"'");
   document.anchors[j].onmouseout=new Function("document.anchors["+j+"].style.color='"+this.colorSelect+"';document.anchors["+i+"].style.textDecoration='"+this.textSelectDecoration+"'");
   document.anchors[j].style.color=this.colorSelect;
   document.anchors[j].style.textDecoration=this.textSelectDecoration;
  }
  else
  {
   document.anchors[j].onmouseover=new Function("document.anchors["+j+"].style.color='"+this.colorHover+"';document.anchors["+i+"].style.textDecoration='"+this.textHoverDecoration+"'");
   document.anchors[j].onmouseout=new Function("document.anchors["+j+"].style.color='"+this.color+"';document.anchors["+i+"].style.textDecoration='"+this.textDecoration+"'");
   document.anchors[j].style.color=this.color;
   document.anchors[j].style.textDecoration=this.textDecoration;
  }
  var oldj=document.anchors.length-1;
  if(p_index[i][p_index[i].length-1])this.node(p_index[i][p_index[i].length-1]);
  document.write('</li>');
  if(document.getElementById('li'+oldj).style.listStyleImage!=listStyleImageExpanded)
  {
   if(!document.getElementById('li'+oldj).childNodes[1])document.getElementById('li'+oldj).style.listStyleImage=listStyleImageChildrenless;
   else document.getElementById('li'+oldj).style.listStyleImage=listStyleImageCollapsed;
  }
  if(p_index[i][1]==search)
  {
   if(document.getElementById('li'+oldj).childNodes[1])parentID=document.getElementById('li'+oldj).childNodes[1].id;
   else parentID=document.getElementById('li'+oldj).parentNode.id;
   while(parentID!='ul0')
   {
    document.getElementById(parentID).style.display='block';
    document.getElementById(parentID).parentNode.style.listStyleImage=listStyleImageExpanded;
    parentID=document.getElementById(parentID).parentNode.parentNode.id;
   }
  }
 }
 document.write('</ul>');
}
//---------------------------------------------------------------------------
function nodeClick(arg1)
{
 for(var l=1;l<ul;l++)
 {
  var unchanged=false;
  var parentID=document.getElementById('ul'+l).id;     
  while(parentID!='ul0')
  {
   if(arg1.childNodes[1]&&parentID==arg1.childNodes[1].id)unchanged=true;
   parentID=document.getElementById(parentID).parentNode.parentNode.id;
  }
  if(unchanged==false)
  {
   document.getElementById('ul'+l).style.display='none';
   document.getElementById('ul'+l).parentNode.style.listStyleImage=listStyleImageCollapsed;
  }
 }
 if(arg1.childNodes[1])
 {
  if(arg1.childNodes[1].style.display=="none")
  {
   arg1.childNodes[1].style.display="block";
   arg1.style.listStyleImage=listStyleImageExpanded;
  }
  else
  {
   arg1.childNodes[1].style.display ="none";
   arg1.style.listStyleImage=listStyleImageCollapsed;
  }
 }
}
//---------------------------------------------------------------------------
