var move = false;
var firObj = null;

function scroll(dir){
	ul = document.getElementById('newsList');
	if(ul==null)
		return false;
	children = ul.childNodes;
	move = true;
	firObj = null;
	numLi = 0;
	for(i=0;i<=children.length-1;i++){
		if(children[i].tagName!=null && children[i].tagName.toLowerCase()=='li'){
			numLi++;
		}
	}
	for(i=0;i<=children.length-1;i++){
		if(children[i].tagName!=null && children[i].tagName.toLowerCase()=='li'){
			if(firObj == null){
				firObj = children[i];
			}
			obj = children[i].id;
			moveObj(obj, dir);
		}
	}
}

function moveObj(objId, dir){
	var ulHeight = 50; //THIS MUST BE THE SAME VALUE AS ul#newsList HEIGHT IN style.css
	var liHeight = 13; //THIS MUST BE THE SAME VALUE AS ul#newsList li  ESTIMATED HEIGHT (INCLUDING TOP/BOTTOM PADDING/MARGIN IN style.css)
	var scrollHeight = liHeight*numLi;
	if(scrollHeight<ulHeight)
		scrollHeight =  0;
	var speed = 2;
	var obj = document.getElementById(objId);
	if(obj.style.top!="")
		objTop = Math.abs(parseInt(obj.style.top));
	else
		objTop = 0;
	//document.getElementById('txtbx').innerHTML = Math.abs(objTop) +" "+scrollHeight;
	//alert(dir+" "+" "+objTop+" "+" "+scrollHeight)
	if((dir==1 && objTop<scrollHeight) || (dir==-1 && objTop>0)){
		dist = parseInt(obj.style.top)-(dir*speed);
		obj.style.top = dist+'px';
		
		if(move){
			setTimeout("moveObj('"+objId+"', "+dir+")", 75);
		}
	}

}

function hoverTyreImage(item, hover){
		e = document.getElementById(item);
		if(e!=null){
			if(hover){
				e.style.background = "url('/Images/tyresMenu-Red-NoSq.gif') no-repeat";
			}
			else{
				e.removeAttribute('style'); //NOTE - we remove the style tag so that it doesn't override external css :hover
			}
		}
	}
	
	function hoverTyreList(item, hover){
		var e = document.getElementById(item);
		if(e!=null){
			var tyre = item.substr(8, item.length);
			if(hover){			
				e.style.background = "url('/Images/bt_"+tyre+"-hover.jpg') no-repeat";
				e.childNodes[0].style.visibility = 'visible';
			}
			else{
				e.removeAttribute('style');
				e.childNodes[0].removeAttribute('style');
			}	
		}
	}
