/*
Copyright (c) 2008 Mediasparx (http://www.mediasparx.com)
Notes: Menu shift on hover
*/

var config = {
     sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
     interval: 200, // number = milliseconds for onMouseOver polling interval
     over: Over, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: Out // function = onMouseOut callback (REQUIRED)
};

$(function() {

$('#menu ul li a').hoverIntent( config )

});

function Over(){
	$current = $(this);
	$current.blur();
	$id = $current.parent().attr("id")

	//Hvis nåværende ikke allerede er valgt
	if($id.length == 6){

		//Fjern selected
		$('#menu-1-selected').attr("id","menu-1").css({backgroundColor:""});
		$('#menu-2-selected').attr("id","menu-2").css({backgroundColor:""});
		$('#menu-3-selected').attr("id","menu-3").css({backgroundColor:""});
		$('#menu-4-selected').attr("id","menu-4").css({backgroundColor:""});
		$('#menu-5-selected').attr("id","menu-5").css({backgroundColor:""});
		$('#menu-6-selected').attr("id","menu-6").css({backgroundColor:""});

		//Endre current til selected
		$id += "-selected";
		$current.parent().attr("id",$id);

		//Endre farge undermeny
		$count = $id.substring(5,6);
		$oldBG = $('#content-menu div').css("background-color");
		$newBG = $current.css("background-color");
		$('#content-menu div').attr("id","content-menu" + $count);
		$current.parent().css({backgroundColor:$newBG});
		$('#content-menu div').stop().css({backgroundColor:$oldBG}).animate({backgroundColor:$newBG}, "slow");

		//Endre undermeny
		$('#content-menu div ul').empty();
		$current.parent().find("li").clone().appendTo('#content-menu div ul');
		$('#content-menu div ul').hide().fadeIn("slow");
	}
}
function Out(){}