$(document).ready(function() {

	
	// **********************************
	// Dropdown menu
	// **********************************	
	var config = {    
		 sensitivity: 50, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 20,  // number = milliseconds for onMouseOver polling interval    
		 over: doOpen,   // function = onMouseOver callback (REQUIRED)    
		 timeout: 100,   // number = milliseconds delay before onMouseOut    
		 out: doClose    // function = onMouseOut callback (REQUIRED)    
	};
	
	function doOpen() {
		//$('#nav>li ul').hide();
		$(this).addClass("hover");
		$('ul:first',this).show();
	}
 
	function doClose() {
		$(this).removeClass("hover");
		$('ul:first', this).hide();
	}
	$("#nav>li").hoverIntent(config).css("zIndex", 100);
	//$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	
	
	// **********************************
	// **********************************
	
	$("#budskaber_carousel").jCarouselLite({vertical: true,
		auto: 8000,
		speed: 200,
		circular: true, 
		visible: 1
	});
	
	// **********************************
	// FORSIDE IKONER
	// **********************************
	
	// PRELOAD
	
	$("#iconteaser .icons img").each(function (){
		$("<img>").attr("src", "/img/v4/" + $(this).attr("rel") + ".png");
	});
	
	$("<div id=\"klikformere\" style=\"width: 134px; height: 46px; z-index: 300; display: none;\"><img src='/img/v4/klikformere.png' alt='' style='border:0;' /></div>").appendTo("body");
	
	$("#iconteaser .icons img").hover(function (){
		rel=$(this).attr('rel');
		offset = $(this).offset();
		position = $(this).position();
		$("#klikformere").css("position", "absolute").css("left", offset.left+90).css("top", offset.top-20).show();
	}, function (){
		if (!$(this).hasClass('activeicon')) {
			rel=$(this).attr('rel');
			//$(this).attr("src", "/img/v4/icon_"+ rel +".png");
		}
		$("#klikformere").hide();
	});

	$("#iconteaser .icons img").click(function (){
		rel=$(this).attr('rel');
		
		oldRel = $("#iconteaser img.active").attr("rel");
		$("#iconteaser img.activeicon").removeClass('activeicon');
		$(this).addClass('activeicon');
		
		$info = $("#" + rel + "_info");
		
		$(".infobox .inner").slideUp(200, function (){
			$(".infobox .inner").html($info.html());	
			$(".infobox .inner").slideDown();
		})
	});

	// **********************************
		
	$('#blogExtract').jCarouselLite({
		vertical: true,
		auto: 8000,
		speed: 1500,
		circular: true, 
		visible: 2, 
		btnPrev: '#prevbutton',
		btnNext: '#nextbutton'
	});
	
	$(".carouselbutton").hover(function (){
		$(this).addClass("activebutton");
	}, function (){
		$(this).removeClass("activebutton");
		
	});
	$("#blogExtract li").hover(function (){
		$(this).addClass("hover");
	}, function (){
		$(this).removeClass("hover");
	})
	$('#blogExtract li').click(function (){
		location.href=$("a", this).attr("href");
	})
	
	/*
	*  FORUM EXTRACT
	*/
	
	$('#forumExtract_container').jCarouselLite({
		vertical: true, 
		auto: 8000,
		speed: 600,
		circular: true, 
		visible: 2
	});
	$('#forumExtract_container li').click(function (){
		location.href=$("a", this).attr("href");
	})
	
	$("#youtubePlayerSmall").hover(function() {
		$("#youtubePlayerSmallLink").slideDown();
	}, function() {
		$("#youtubePlayerSmallLink").slideUp();
	})
	
	
});

