function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()
var loop, timer

function makeObj(obj,nest){
    nest=(!nest) ? "":'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp;this.down=goDown;
	this.moveIt=moveIt; this.x=0; this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

var px = bw.ns4||window.opera?"":"px";

function moveIt(x,y){
	this.x = x
	this.y = y
	this.css.left = this.x+px
	this.css.top = this.y+px
}

function goDown(move){
	if (this.y>-this.scrollHeight+oCont.clipHeight){
		this.moveIt(0,this.y-move)
			if (loop) setTimeout(this.obj+".down("+move+")",speed)
	treeY -= move;
	}
}

function goUp(move){
	if (this.y<0){
		this.moveIt(0,this.y-move)
		if (loop) setTimeout(this.obj+".up("+move+")",speed)
	treeY -= move;
	}
}

function scrollTree(speed){
	if (scrolltextLoaded){
		loop = true;
		if (speed>0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

var scrolling_news = null;
function scrollNews(move){
	if (scrollnewsLoaded){
		if (oNews.y<-oNews.scrollHeight){
		clearTimeout(scrolling_news);
			oNews.y=oNewsCont.clipHeight;
		}
			oNews.moveIt(0,oNews.y-move)
		clearTimeout(scrolling_news);
			scrolling_news = setTimeout("scrollNews("+move+")",1)
			//scrolling_news = setTimeout("scrollNews("+move+")",5000)
	}
}
	

function noScroll(){
	loop = false
	if (timer) clearTimeout(timer)
}
var scrollnewsLoaded = false

function scrollnewsInit(){
	oNewsCont = new makeObj('divScrollNewsCont')
	oNews = new makeObj('divNews','divScrollNewsCont')
	oNews.moveIt(0,0)
	oNewsCont.css.visibility = "visible"
	scrollnewsLoaded = true
	scrolling_news = setTimeout("scrollNews(0.1)",1)
}

//PullMenu functions by Asparuh Krastev
//Copyright Lemon Graphics


var menu_opacity = 100;
var menu_fade_step = 20;
var menu_scroll_step = 7;
var menu_top_limit = 180;

var menuMouseOver = "";

var opened_menu = new Array("root_menu_div");
var closing = null;
var pending_menu = null;
function pullDown(menu, div_id)
{
	clearTimeout(closing);
	var menu_div = document.getElementById(menu.id+"_div");
	if (menuMouseOver) {menuMouseOver.bgColor='';menuMouseOver.style.color = '';}
	menuMouseOver = menu;
	menu.style.color = menuOverColor;
	menu.bgColor = markerColor;
	if (menu_div)
	{
		pending_menu = menu_div.id;
		div = document.getElementById(div_id);
		if (div_id=='root_menu_div')
		{
			switch(div.orient)
			{
				case "col":
					var top_pos = 5;
					menu_div.style.left = menu.clientWidth*0.7;
					eval_str1 = "menu.rowIndex";
					eval_str2 = "top_pos += root_table.rows[i].clientHeight;";
					eval_str3 = "menu_div.style.top = top_pos*1.05;";
					break;
				default :
					var left_pos = 0;
					menu_div.style.top = menu.clientHeight;
					eval_str1 = "menu.cellIndex";
					eval_str2 = "left_pos += root_table.cells[i].clientWidth;";
					eval_str3 = "menu_div.style.left = left_pos;";
			}
			var root_table = document.getElementById("root_menu");
			for (i=0; i<eval(eval_str1); i++)		
			{
				eval(eval_str2);
			}
			eval(eval_str3);
		}
		else
		{
			menu_div.style.left = parseInt(div.style.left) + menu.clientWidth*1.00;
			menu_div.style.top  = (parseInt(div.style.top) + menu.clientHeight*menu.rowIndex)*1.00;
		}
		if (!hideMenu(div_id)) showMenu()
	}
	else {pending_menu=null; hideMenu(div_id)}
}

function hideMenu(menu_div)
{
	ret = false;
 	for(var i=opened_menu.length-1; i; i--)
	{
		var op_menu = document.getElementById(opened_menu[i]);
		if (opened_menu[i]!=menu_div&&opened_menu[i]!=pending_menu)
		{
			fadeOut(opened_menu[i], menu_opacity);
			opened_menu.pop();
			ret = true;
		}
		else break;
	}
	return(ret);
}

function showMenu()
{
	var next_i = opened_menu.length;
	//alert("show");
	if (opened_menu[next_i-1] != pending_menu)
	{
		opened_menu[next_i] = pending_menu;
		document.getElementById(pending_menu).style.visibility = "visible";
		pending_menu = null;		
		fadeIn(opened_menu[next_i], 0);
	}
}

function fadeIn(menu_div_id, oc) {
	menu_div = document.getElementById(menu_div_id);
	menu_div.style.filter="Alpha(opacity="+oc+", style=0)";
	menu_div.style.visibility = "visible";
	if(oc<menu_opacity)
	{
		fading = setTimeout('fadeIn(\'' + menu_div_id + '\', '+(oc+=menu_fade_step)+')',10);
	}
	else
	{
		menu_div.style.filter="Alpha(opacity="+menu_opacity+", style=0)";
	}
}
var fading = null;

function fadeOut(menu_div_id, oc) {
	menu_div = document.getElementById(menu_div_id);
	menu_div.style.filter="Alpha(opacity="+oc+", style=0)";
	if(oc>0) fading = setTimeout('fadeOut(\'' + menu_div_id + '\', '+(oc-=menu_fade_step)+')',10);
	else
	{
		fading = null;
		menu_div.style.visibility = "hidden";
		menu_div.style.filter="Alpha(opacity=0, style=0)";
		if (pending_menu)
		{//alert("show");
			showMenu();
		}
	}
}
onresize = initLayersPos;

function initLayersPos()
{
 	if (document.getElementById("left_column"))
		document.getElementById("root_menu_div").style.left=0+document.getElementById("left_column").clientWidth;
	var divNews;
 	if (divNews = document.getElementById("divScrollNewsCont")) {
		divNews.style.left=9+document.getElementById("resize_cell").clientWidth;
		divNews.style.visibility='visible';
	}
}

function initialize()
{
	initMenu()
	if (document.getElementById("divScrollNewsCont")) scrollnewsInit();
	initLayersPos();
}

onload = initialize;
var menuTop;
var menu_layer =null;

function initMenu()
{	
	menu_layer = document.getElementById("root_menu_div");
	menuTop = parseInt(menu_layer.style.top);
}

var scrollSpeed = 0;
var menu_scrolling = null;
var startMenu = null;
var offsetMenu = 0;
var dist_divident = 0;

function initMoveMenu()
{
	clearTimeout(startMenu);
	if (!menu_layer) initMenu();
	menu_layer_top = parseInt(menu_layer.style.top);
	dist_divident = Math.abs(-menu_layer_top +document.body.scrollTop+menu_top_limit);
	startMenu = setTimeout("moveMenu()", 200);
}

function moveMenu()
{
	clearTimeout(menu_scrolling);
	if ((y = document.body.scrollTop+menu_top_limit-menuTop) ==0) return;
	menu_layer_top = parseInt(menu_layer.style.top);
	(dist = menuTop+y - menu_layer_top)>0?sign=1:sign=-1;
	dist = Math.abs(dist);
	menu_layer_top += sign*scrollSpeed;
	if (menu_layer_top < menuTop)
	{
		scrollSpeed=0;
		menu_layer.style.top = menuTop;
	}
	else if (sign*menu_layer_top<sign*(menuTop+y))
	{
		y<0?extra=180:extra=0;
		(scrollSpeed = (dist-extra)/(dist_divident-extra)*menu_scroll_step)<1?scrollSpeed=1:0;
		menu_layer.style.top = menu_layer_top;
		menu_scrolling = setTimeout("moveMenu("+y+")", 10);
	}
	else  if (menu_layer_top>menuTop+y)
	{
		scrollSpeed=0;
		menu_layer.style.top = menuTop+y;
	}
}