<!--

var mainmenu_startpos = 0; // will be set by the page content itself - according to the current category selected
var mainmenu_lastpos = 0; // will save the last position - for the roll back of the tracker
var starting_point = 89;
var mainmenu_step = 55;
var menuIndict;
var was_init = false;
var is_rolling = false;
var rollback_step_size = 10;
var rollback_timer_start = 50;
var rollback_timer_step = 60;
var tmpCurPos = 0; // used as temp var
var inresizing = false; // states if we are in resizing process

function menuTrack_Init(){
//	window.status = "MENU: menuTrack_Init";
	menuIndict = document.getElementById("maincat_sel");
	starting_point += findPosY(document.getElementById("maincat_sel_anchor"));
	mainmenu_startpos_original = mainmenu_startpos;
	mainmenu_startpos += starting_point;
	menuIndict.style.top = (mainmenu_startpos) + "px";
	menuIndict.style.left = (findPosX(document.getElementById("maincat_sel_anchor")) + (_cur_lang=='he'?3:6)) + "px";
	menuIndict.style.display = 'block';
	// set flag 
	was_init = true;
	// get window resized 
	window.onresize = menuTrack_ReSize;
}

function menuTrack_ReSize(){
//	window.status = "MENU: menuTrack_Resize ("+inresizing+")";
	if (!inresizing){
		mainmenu_startpos = mainmenu_startpos_original;
		starting_point = 89;
		starting_point += findPosY(document.getElementById("maincat_sel_anchor"));
		mainmenu_startpos += starting_point;
		menuIndict.style.top = (mainmenu_startpos) + "px";
		menuIndict.style.left = (findPosX(document.getElementById("maincat_sel_anchor")) + (_cur_lang=='he'?3:6)) + "px";
		inresizing = true;
		setTimeout("menuTrack_ReSize_Done()",500); // after a while, set the inresizing = false - so we are not in resizing process
	}
}

function menuTrack_ReSize_Done(){
	inresizing = false;
}

function menuTrack_Start(){
//	window.status = "MENU: menuTrack_Start - " + mousePosY;
	// move tracker, only if was initiated already and in bounderies
	if (!was_init) return;
	// check bounderies - 17px bottom margin
	if ((mousePosY <= (starting_point+(mainmenu_step*5)-20)) && (mousePosY >= (starting_point))){
		// flag that the indicator is on the move
		is_rolling = false;
		// set pos
		menuIndict.style.top = (mousePosY-17) + "px";//(mainmenu_step + starting_point) + "px";
//		window.status = "mousePosY: "+mousePosY+" cur: "+menuIndict.style.top+" max: "+(starting_point+mainmenu_step*5);
	}
}

function menuTrack_Stop(){
//	window.status = "MENU: menuTrack_Stop";
	// if initiated already
	if (!was_init) return;
	// flag that the indicator hax stoped moving
	is_rolling = true;
	// roll the menu tracker back to original place - gradually
	setTimeout("menuTrack_RollBack("+mainmenu_startpos+")",rollback_timer_start);
}

function menuTrack_RollBack(moveTo){
	// check if the indicator hax started moving
	if (!is_rolling) return; 
	// get current pos
	tmpCurPos = parseInt(menuIndict.style.top.substring(0,menuIndict.style.top.length-2));
	// if need to move - than move
	if (Math.abs(moveTo - tmpCurPos) > rollback_step_size){
		// if BELLOW current pos
		if (moveTo > tmpCurPos) menuIndict.style.top = (tmpCurPos + rollback_step_size) + "px";
		// if ABOVE current pos
		else menuIndict.style.top = (tmpCurPos - rollback_step_size) + "px";
		// call the next step
		setTimeout("menuTrack_RollBack("+moveTo+")",rollback_timer_step);
	// if distance to target pos is less or equal than the defined steping size, than move to target (the last bit)
	}else{
		menuIndict.style.top = moveTo + "px";
	}
}

//-->