activateMenu = function(nav) {
	if (document.all && document.getElementById(nav).currentStyle) {
        var navroot = document.getElementById(nav);
        var lis=navroot.getElementsByTagName("LI");
        for (i=0; i<lis.length; i++) {
            if(lis[i].lastChild.tagName=="UL"){
             	lis[i].onmouseover=function() {
                   var ul = this.getElementsByTagName( "ul" );
                   ul[0].parentNode.firstChild.className = "active";
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {
                   var ul = this.getElementsByTagName( "ul" );
                   ul[0].parentNode.firstChild.className = "";
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
var heyMateIsThisTheIndexPage=false;
window.onload= function(){
    activateMenu('navUL');
    if(heyMateIsThisTheIndexPage) {showMeTheNextTab(); autoscrollCats();}
}
function popup()	{
	window.open("http://bulinfo.info/policy",null,"height=600,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
var currentSlider = 'newest';
function sidebarSlider(id) {
	if(currentSlider == id) return false;
	new Effect.BlindUp($(currentSlider).getElementsByTagName('DL')[0],{duration: 0.6});
	new Effect.BlindDown($(id).getElementsByTagName('DL')[0],{duration: 0.6});
	$(currentSlider).className = 'inactive';
	$(id).className = '';
	currentSlider = id;
	return false;
}
var stopAutoscroll = false;
var currentBox = 0;
var currentTabItem = 3;
var currentTabId = 0;
function calculatePrev() {
	currentTabItem--;
	$('showBox_next').className = '';
	var testThisShit = $('showBox'+currentTabId).getElementsByTagName("DIV");
	if(currentTabItem==3) $('showBox_prev').className = 'inactive'; else $('showBox_prev').className = '';
}
function calculateNext() 
{
	currentTabItem++;
	$('showBox_prev').className = '';
	var testThisShit = $('showBox'+currentTabId).getElementsByTagName("DIV");
	if(testThisShit.length-2 == currentTabItem) $('showBox_next').className = 'inactive'; else $('showBox_next').className = '';
}
function showBoxTabSelect(id) {
	currentTabId = id;
	currentTabItem = 3;
	var tabsUl = $('showBox_categories').getElementsByTagName("LI");
	for(var i=0;i<tabsUl.length;i++) 
	{
		if(i==id) 
		{
			tabsUl[i].className = 'selected';
			$('showBox'+i).style.display = 'block';
			my_glider = new Glider('showBox'+i, {duration:0.5});
		}else{
			tabsUl[i].className = '';
			$('showBox'+i).style.display = 'none';
		}
	}
	var curLI = $('showBox'+id).getElementsByTagName("DIV");
	if(curLI.length-2 <= 3) $('showBox_next').className = 'inactive'; else $('showBox_next').className = '';
}
function showMeTheNextTab() 
{
	if(stopAutoscroll) return false;
	var tabsUl = $('showBox_categories').getElementsByTagName("LI");
	var nextTab = 0;
	var curTab = 0;
	for(var i=0;i<tabsUl.length;i++) if(tabsUl[i].className=='selected') curTab = i;
	if(curTab+1 == tabsUl.length) nextTab = 0; 
	else nextTab = curTab+1;

	showBoxTabSelect(nextTab);
	newTimeout = eval("durationBox"+nextTab) * 1000;
	setTimeout (showMeTheNextTab,newTimeout);


/*
	showBoxTabSelect(nextTab);
	
	//stopAutoscroll = true;
	my_glider.callBack = "stopAutoscroll = false;calculateNext();showMeTheNextTab()";	
	my_glider.periodicallyUpdate();
*/


}
function moveThisTo(container, element){
  Position.prepare();
  container_y = Position.cumulativeOffset($(container))[1]
  element_y = Position.cumulativeOffset($(element))[1]
  new Effect.Scroll(container, {x:0, y:(element_y-container_y), duration: .3});
  return false;
}
var curSubnav = 0;
var curAutoscroll = false;
function autoscrollCats() {
	if(curAutoscroll) return false;
	moveNext();
	setTimeout (autoscrollCats,7000);
}
function movePrev() {
	curSubnav = curSubnav-6;
	var catsDL = $('subcatslist').getElementsByTagName("DIV");
	if(curSubnav < 0) curSubnav = (Math.round((catsDL.length-1)/6)*6)-1;
	moveThisTo('subcatslist', 'subcat'+curSubnav);
}
function moveNext() {
	curSubnav = curSubnav+6;
	var catsDL = $('subcatslist').getElementsByTagName("DIV");
	if(catsDL.length <= curSubnav) curSubnav = 0;
	moveThisTo('subcatslist', 'subcat'+curSubnav);
}

function freeze_slider()
{
	setTimeout("stopAutoscroll = false;calculateNext();showMeTheNextTab();", 180000);
}
