﻿// data
function MakeArray(n) {
	this.length = n
	return this
}
monthNames = new MakeArray(12)
monthNames[1] = "Января"
monthNames[2] = "Февраля"
monthNames[3] = "Марта"
monthNames[4] = "Апреля"
monthNames[5] = "Мая"
monthNames[6] = "Июня"
monthNames[7] = "Июля"
monthNames[8] = "Августа"
monthNames[9] = "Сентября"
monthNames[10] = "Октября"
monthNames[11] = "Ноября"
monthNames[12] = "Декабря"

function customDateString() {
	currentDate = new Date()
	var theMonth = monthNames[currentDate.getMonth() + 1]
	msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	if (msie4) {
	    var theYear = currentDate.getYear()
	}
	else {
	     var theYear = currentDate.getYear() +1900
	}
	return currentDate.getDate() + " " + theMonth + " " + theYear + " г."
}

function setupMenu(id, mode) {
         container = document.getElementById('level2');
         var list = [];
         if (mode == 'hide') {
            if (isOn == 1)
               return;
               
            currentId = 0;
            container.style.display = 'none';
         } else if (id > 0 && mode == 'show' && isOn == 0) {
            isOn = 1;
            currentId = id;
            while (container.firstChild) {
              container.removeChild(container.firstChild);
            }            
            
            container.style.display = 'block';
            eval ("list = level_"+id);

            if (list.length > 1) {
                
var c0 = document.createElement('TABLE'); 
c0.style.cssText = "margin-top: 6px; width: 100%; background-color: #CC3729; border: 0px; border-collapse: collapse; border-spacing: 0px;";
c0.setAttribute("style","margin-top: 6px; width: 100%; background-color: #CC3729; border: 0px; border-collapse: collapse; border-spacing: 0px;");
c0.setAttribute("cellSpacing","0");
c0.setAttribute("cellPadding","0");
var c1 = document.createElement('TBODY');
var c2 = document.createElement('TR');
var c3 = document.createElement('TD');

var d0 = document.createElement('TABLE'); 
//d0.style.cssText = "border-collapse: collapse; border-spacing: 0px;";
d0.setAttribute("cellSpacing","0");
d0.setAttribute("cellPadding","0");
var d1 = document.createElement('TBODY');
var d2 = document.createElement('TR');

var ids = 0;                
               for (i=0; i<(list.length - 1); i++) {
ids = ids + 1;
d3 = document.createElement('TD');
d3.setAttribute("id","prr_"+ids);
d3.setAttribute("width","1");
d4 = document.createElement("img");
d4.setAttribute("src","http://www.inkspb.ru/images/s.gif");
d4.setAttribute("width","1");
d4.setAttribute("height","20");
d3.appendChild( d4 );
d2.appendChild( d3 );


d3 = document.createElement('TD');
d3.setAttribute("width","4");
d3.setAttribute("id","prv_"+ids);
d3.style.cssText = "padding: 2px 2px 2px 10px;";
d3.setAttribute("style","padding: 2px 2px 2px 10px;");
d4 = document.createElement("img");
d4.setAttribute("src","http://www.inkspb.ru/images/b1.gif");
d4.setAttribute("id","img_"+ids);
d4.setAttribute("width","4");
d4.setAttribute("height","5");
d3.appendChild( d4 );
d2.appendChild( d3 );
                                   
d3 = document.createElement('TD');
d3.style.cssText = "padding: 2px 5px 2px 5px;";
d3.setAttribute("style","padding: 2px 5px 2px 5px;");
d3.setAttribute("align","left");
d4 = document.createElement("a");
d4.setAttribute("style","color: white;");
d4.setAttribute("id","ths_"+ids);
d4.onmouseover = function () {this.parentNode.style.background="#00559D"; var ss = this.getAttribute('ID'); ss = ss.replace('ths_', ''); document.getElementById('prr_'+ss).style.background="#00559D"; document.getElementById('prv_'+ss).style.background="#00559D"; document.getElementById('img_'+ss).setAttribute("src","http://www.inkspb.ru/images/b1.gif");};
d4.onmouseout = function () {this.parentNode.style.background="#CC3729"; var ss = this.getAttribute('ID'); ss = ss.replace('ths_', ''); document.getElementById('prr_'+ss).style.background="#CC3729"; document.getElementById('prv_'+ss).style.background="#CC3729"; document.getElementById('img_'+ss).setAttribute("src","http://www.inkspb.ru/images/b1.gif");};
d4.style.cssText = "color: white;";
d4.setAttribute("href", list[i][0]);
d5 = document.createTextNode(list[i][1]);
d4.appendChild( d5 );
d3.appendChild( d4 );
d2.appendChild( d3 );

               } 
d1.appendChild( d2 );
d0.appendChild( d1 );
c3.appendChild( d0 );
c2.appendChild( c3 );
c1.appendChild( c2 );
c0.appendChild( c1 );

container.appendChild( c0 );
               
               if (container.parentNode.offsetWidth > 0) {
                   container.style.width = (container.parentNode.offsetWidth - 0)+ 'px';
               } else {
                   container.style.width = '100%'
               }
            } else {
               container.innerHTML = '';
            }
         }
}

function clearMenu() {
    setupMenu(-1, 'hide');
}

// img_nav

var pong;
var loaded=0;
window.onerror=null

if (document.images){
 var snavp = new Image(12,12);
 var snavm = new Image(12,12);

  snavp.src = "http://www.inkspb.ru/images/plus.gif";
  snavm.src = "http://www.inkspb.ru/images/minus.gif";
}

// basic image swap for mouseovers

function mAction(iname, s){
  if (document.images && loaded){
  	subnav = "subnav"+s; 	
    document.images[subnav].src = eval("s"+iname+".src");	
		}
}

function preloadImages() {
}
// end img_nav

function show_hide(id, s) {
	obj=document.getElementById('var'+id).style;
	if (obj.display=='none') {
		obj.display='inline';
		mAction('navm', s);
	} else {
		obj.display='none';
		mAction('navp', s)
	}
}
function hide(id) {
	obj=document.getElementById('var'+id).style;
	obj.display='none';
	mAction('navp')
}

