// timers
var upTimerId = 0;
var downTimerId = 0;
var stepSize = 20;
var stepTime = 300;

$(function(){

	//Show/Hide BilInfo menu
	$("#bilinfo-liste").hover(
		function(){
			$("#scroller").show();
			$(this).css("background-image","url(../gfx/menuhover.gif)");
		},
		function(){
			$("#scroller").hide();
			$(this).css("background-image","none");
		}
	),
	
	// UP/DOWN buttons
	$("#scrDown").hover(
		function(){
			upTimerId = setInterval("scrUp()", stepTime );
		},
		function(){
			clearTimeout(upTimerId);
		}
	),
	$("#scrUp").hover(
		function(){
			downTimerId = setInterval("scrDown()", stepTime );
		},
		function(){
			clearTimeout(downTimerId);
		}
	)

	// to fix menu in IE6
	if(jQuery.browser.msie && (parseInt(jQuery.browser.version) == 6))
	{
		//alert("6 B: " + jQuery.browser.msie + " V: " + parseInt(jQuery.browser.version));
		$("#nav li").hover(
			function(){
				$(this).addClass("sfhover");
			},
			function(){
				$(this).removeClass("sfhover");
			}
		)
	}

	// to fix menu in IE7 - when hover over IFRAME
	if(jQuery.browser.msie && (parseInt(jQuery.browser.version) >= 7))
	{
		//alert("7 B: " + jQuery.browser.msie + " V: " + parseInt(jQuery.browser.version));
		$("iframe").hover(
			function(){
				$("#nav li li").hide();
			},
			function(){
				$("#nav li").show();
			}
		)
	};

	if($("#bil-info-content").attr("src") != undefined)
	{
		window.print = function(){
			alert("Brug print knappen på den viste side");
		}
	};

});

function scrUp()
{
	var ulHeight = parseInt($("#theBIList").innerHeight({ margin: true }));

	var top = parseInt($("#bilinfo-liste .bilinfo").css("margin-top").replace(/px/gi, ""));
	if(top <= -(ulHeight-150))
	{
		clearTimeout(upTimerId);
	}
	else
	{
		$("#bilinfo-liste .bilinfo").css("margin-top",top-stepSize+"px");
	}
}

function scrDown()
{
	var top = parseInt($("#bilinfo-liste .bilinfo").css("margin-top").replace(/px/gi, ""));
	if(top >= 0)
	{
		clearTimeout(downTimerId);
	}
	else
	{
		$("#bilinfo-liste .bilinfo").css("margin-top",top+stepSize+"px");
	}
}


