var timeout_ms=10;
var roll_step=2;
var roll_steps=10;
var starting_pos=2;
function menu_rollover(menu_item){
	var t=get_menu_item_top_pos(menu_item);
	var b=get_menu_item_background(menu_item);
	if(!b&&t==starting_pos){
		setTimeout("menu_animation('"+menu_item+"')",timeout_ms);
	}
};
function menu_rollout(menu_item){
	var t=get_menu_item_top_pos(menu_item);
	var b=get_menu_item_background(menu_item);
	if(b&&t==starting_pos){
		setTimeout("menu_animation('"+menu_item+"')",timeout_ms);
	}
	else{
		setTimeout("menu_animation('"+menu_item+"')",timeout_ms*(roll_steps*2));
	}
};
function menu_animation(menu_item){
	var t=get_menu_item_top_pos(menu_item);
	var b=get_menu_item_background(menu_item);
	if((t>=starting_pos-(roll_step*roll_steps)&&t<=starting_pos)||(t>=starting_pos&&t<=starting_pos+(roll_step*roll_steps))){
		t=b?(t-roll_step):(t+roll_step);
	}
	else if(t<starting_pos-(roll_step*roll_steps)||t>starting_pos+(roll_step*roll_steps)){
		t=t>starting_pos?(starting_pos-(roll_step*roll_steps)):(starting_pos+(roll_step*roll_steps));
		if(!b){
			document.getElementById(menu_item).style.color="#c5c5c5";
		}
		else{
			document.getElementById(menu_item).style.color="#7a7a7a";
		}
	};
	//alert(t);
	if(t==starting_pos){
		document.getElementById(menu_item).style.background=b?"none":"transparent url(tpl/img/top_menu_bg_hover.gif) center top repeat-y";
	}
	else{
		setTimeout("menu_animation('"+menu_item+"')",timeout_ms);
	}
	document.getElementById(menu_item).childNodes[0].style.top=t+(t?"px":"");
};
function get_menu_item_top_pos(menu_item){
	var t=document.getElementById(menu_item).childNodes[0].style.top;
	if(t=="NaN"||t==""){
		t=starting_pos;
	}
	return parseInt(t);
};
function get_menu_item_background(menu_item){
	var b=document.getElementById(menu_item).style.background;
	if(b.indexOf('none')!=-1){
		b="";
	}
	return b;
};

