var bp_int = new Array(5);
function showBP(el,ind){
	if(document.getElementById(el)){
	if(bp_int[ind])
		clearInterval(bp_int[ind]);
	bp_int[ind] = setInterval(function(){showBPMove(el)},15)
	}
}

function hideBP(el,ind){
	if(bp_int[ind])
		clearInterval(bp_int[ind]);
	bp_int[ind] = setInterval(function(){hideBPMove(el)},15)
}

function showBPMove(el,ind){
	elt = document.getElementById(el);
	ct = parseInt(elt.style.top);
	if(!ct)
		ct = 0;
	if(ct<50)
		elt.style.top = ct + 5;
	else
		clearInterval(bp_int[ind]);
}

function hideBPMove(el,ind){
	elt = document.getElementById(el);
	ct = parseInt(elt.style.top);
	if(ct>0)
		elt.style.top = ct - 5;
	else
		clearInterval(bp_int[ind]);
}

//{{Rolling functions
function blockRoller(){}
blockRoller.prototype = {
	hide: function(oThis){
		if(oThis.obj.offsetHeight>oThis.minHeight&&oThis.curMove<oThis.obj.offsetHeight){
			vall = oThis.obj.offsetHeight-oThis.curMove;
			oThis.obj.style.height = vall;	
			oThis.curMove+=oThis.step;
			setTimeout(function(){roller.hide(oThis);},oThis.freq);
		}else{
			oThis.obj.style.height = oThis.minHeight;
		}
	},
	show: function(oThis){
		if(oThis.obj.offsetHeight<oThis.hght){
			vall = oThis.obj.offsetHeight+oThis.curMove;
			oThis.obj.style.height = vall;	
			oThis.curMove+=oThis.step;
			setTimeout(function(){roller.show(oThis);},oThis.freq);
		}else{
			oThis.obj.style.height = oThis.hght;
		}
	}
}
//}}

//{{Class of rolling block
function hidingBlock(id){
	//{{you may change these values
	this.freq = 10; // Скорость
	this.minHeight = 1; // Высота свернутого блока
	this.sn = 1; // Начальное значение параметра изменения
	this.step = 1; // Шаг увеличения параметра изменения
	//}}
	this.obj = document.getElementById(id);
	this.hght = this.obj.offsetHeight;
	this.curStat = 1;
	this.controlBut = document.getElementById(id+'_cnt');
	this.initializeBehavior();
}

hidingBlock.prototype = {	
	initializeBehavior: function(){
		var oThis = this;
		this.changeStatus();
		this.controlBut.onclick = function(){oThis.changeStatus();}
	},	
	changeStatus: function(){
		this.curMove = this.sn;
		if(this.curStat){
			roller.hide(this);
			this.curStat = 0;
		}else{
			roller.show(this);
			this.curStat = 1;
		}			
	}	
}

function initBlocks(){
	ct = 1;
	while(document.getElementById('tb'+ct)){
		new hidingBlock('tb'+ct);
		ct++;
	}
}
//}}


window.onload = function(){
	var ind = 1;
	while(elt = document.getElementById("link"+ind)){
		if(elt.className!="cur"){
			elt.onmouseover = function(){this.className='hover';}
			elt.onmouseout = function(){this.className=''}
		}
		ind++;
	}
	var cr = document.getElementById("cur");
	if(cr){		
		var p = cr.parentNode;
		var mt = p.parentNode.parentNode.parentNode;
		document.getElementById("sub_menu").style.paddingLeft = p.offsetLeft + mt.offsetLeft + 174 + cr.offsetWidth/2 - 1;
		document.getElementById("sub_menu").className = document.getElementById("sub_menu").className + " vis";
	}
}