$(document).ready(function(){  
   scrollTheLogo();
	var erNede = false;
	
	$("ul#menu>li>ul").addClass("niv-2"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  
	
	$("ul#menu>li").hoverIntent(
			{
			over: function () {
				$(this).addClass('drop');
				$(this).find("ul.niv-2").stop(true, false).slideDown(400);
			}, 
			timeout: 500,
			out:function () {
				$(this).removeClass('drop');
				$(this).find("ul.niv-2").stop(true, false).slideUp(400);
			}
		}
	);
	
	$(".nyhet1>p>strong, .nyhet2>p>strong").each(function() {
		if($(this).text().length > 200) {
			$(this).replaceWith('<strong>' + $(this).text().substr(0, 200) + '...</strong>');
		}
	});
	
	$(".nyhet1, .nyhet2").wrapAll('<div id="top-news-wrapper"/>');
	
	$('<h2 class="mellomheading"><span>Flere nyheter fra MIF.no</span></h2>').insertAfter('#top-news-wrapper');
	
	$('.galleri h1').wrapInner('<span />');
	$('#flashdiv').wrapInner('<div class="innerart" />');
	
	//$("#scrollable").scrollable({circular: true}).autoscroll({interval: 5000});
	
//	alert($(".nyhet1>p>strong").text().substr(0, 50));
	
});  


// logo slider
function scrollTheLogo(){
	var firstDiv = $('#scrollable .items p:first') ;
    var innerhtml = $(firstDiv).html();
    $(firstDiv).animate({width: '0px' , opacity: 0},1000 , function(){
		$(firstDiv).remove();
        $('#scrollable .items').append('<p>' + innerhtml +  '</p>');
        setTimeout ( 'scrollTheLogo()', 3000 );

	});
}

