//Left_Menu
var OldList;
function ListMenu(){
	var menu = document.getElementById("menuAll");
	var items = menu.getElementsByTagName("li");
	for (var i=0; i<items.length; i++)
	{
			if( items[i].parentNode.className == "menu_list" )
			{
				var span = items[i].getElementsByTagName("span");
				if ( span[0] ) span[0].onclick=function ()
				{
					if ( OldList &&  OldList != this) OldList.parentNode.className = "";
					if (this.parentNode.className == "" || this.parentNode.className == "last" )
						{
							if( this.parentNode.className == "last" )this.parentNode.className = "selectlast";
																else this.parentNode.className = "select";
						}
							 else 
						{
							if( this.parentNode.className == "selectlast" )this.parentNode.className = "last";
																	  else this.parentNode.className ="";
						}
						
					OldList = this;	
					
				}
			}
	}
}


//Main_Menu
var old_div_bottom, old_div_top; 
var timer;

function showPopup( div_top, div_bottom )
{
	if( timer )clearTimeout( timer );

	if( old_div_bottom )
	{
		old_div_bottom.className = 'menu_button';	
		old_div_top.className = '';	
	}
	
	var div_bottom2 = document.getElementById( div_bottom );
	div_bottom2.className = 'menu_button show_popup';	
	div_top.className = 'active';		
	
	old_div_bottom = div_bottom2;
	old_div_top = div_top;	
}

function hiddePopup()
{
	timer = setTimeout("hiddePopupTimer()", 1000);
}

function hiddePopupTimer()
{
	old_div_bottom.className = 'menu_button';	
	old_div_top.className = '';		
}



//LISTER

var list_element_width = 50;
var list_scroll_step = 20;
var list_scroll_timeout = 40;
var list_max_position = new Array();
var list_position = new Array();
var new_list_position = new Array();

function UpdateListScrollButtons(block) {
	var list = document.getElementById(block);
	if (list) {
		if (list_max_position[block] < 0) {
			list_max_position[block] = 0;
			var list = document.getElementById(block);
			if (list) {
				for (var i = 0; i < list.childNodes.length; i++) {
					if (list.childNodes[i].nodeType == 1) list_max_position[block]++;
				} 
			} 
		}
	} 
} 

function ListScrollTimer(block) {
	var list = document.getElementById(block);
	if (list) {
		if (new_list_position[block] > list_position[block]) {
			list_position[block] += list_scroll_step;
			if (list_position[block] > new_list_position[block])
				list_position[block] = new_list_position[block];
		} else if (new_list_position[block] < list_position[block]) {
			list_position[block] -= list_scroll_step;
			if (list_position[block] < new_list_position[block])
				list_position[block] = new_list_position[block];
		} 
		list.style.left = -list_position[block] + "px";
		UpdateListScrollButtons(block);
		if (new_list_position[block] != list_position[block])
			setTimeout(function () { ListScrollTimer(block) }, list_scroll_timeout);
	} 
} 

function ListScroll(increment, block) {
	var list = document.getElementById(block);
	if (list) {
		if (!list_max_position[block]) list_max_position[block] = -1;
		if (!list_position[block]) list_position[block] = 0;
		if (!new_list_position[block]) new_list_position[block] = 0;
		UpdateListScrollButtons(block);
		new_list_position[block] += increment * list_element_width * 6;
		if (new_list_position[block] > (list_max_position[block] - 6) * list_element_width) {
			new_list_position[block] = (list_max_position[block] - 6) * list_element_width;
		} 
		if (new_list_position[block] < 0) new_list_position[block] = 0;
		if (new_list_position[block] != list_position[block])
			setTimeout(function () { ListScrollTimer(block) }, list_scroll_timeout);
	} 
	return false;
} 

var prevLi;
function changeContent(div){
    var li = div;
    if(prevLi)
        prevLi.className = '';
    li.className = 'active';
    prevLi = li;
	return false;
}



























