$(document).ready(function(){
	var eqheight = 0;
	var liWidth = $('div.guide div.containerpadding').width();
    var gcheight = 0;    
    $('div.guide').parents('div.container').css('clear','both');
    $('div.guide div.containerpadding').css('position','relative');	    
    $('div.guide div.containerpadding').css('display','block');
    
	$("div.guide div.guideitem").each(function(i)
	{       
	   if(eqheight < $(this).height())
	             eqheight = $(this).height();
       
        if(gcheight < $(this).children('div.guidecontent').height())
	             gcheight = $(this).children('div.guidecontent').height();

	        $(this).css('position','relative');
		    $(this).children('div.guidecontent').css('position','absolute');
            $(this).children('div.gudiepagination').css('position','absolute');
            $(this).children('div.gudiepagination').css('width','100%');

	});
	
	    if(eqheight < 425)
	        eqheight = 425;
        $('div.guide div.containerpadding').css('height',eqheight);
        $('div.guide div.containerpadding').css('width',liWidth);

	$('div.guide div.containerpadding').css('overflow','hidden');
		
	$("div.guide div.guideitem").each(function(i)
	{  
                $(this).css('height',eqheight); 
                $(this).css('left',(liWidth+10)*i);
                $(this).css('top',-(eqheight*i));
                $(this).css('width',liWidth);
                $(this).children('div.guidecontent').css('top',0);
                $(this).children('div.gudiepagination').css('bottom',0);
                $(this).children('div.gudiepagination').children('ul').css('float','right');
	});	
	$('a.guideprev').each(function(i)
	{
		$(this).click(function()
		{		    
		    //move current slide right
			$(this).parents('div.guideitem').animate({left: (liWidth*2)}, 400);
			//move prev slide to start position
			$($(this).attr('href')).show().animate({left: 0}, 400);			
			$('img.js').hide();
			return false;			
		});
	});
	$('a.guidenext').each(function(i)
	{
	    $(this).click(function()
		{	        
		    //move current slide left
			$(this).parents('div.guideitem').animate({left: -(liWidth*2)}, 400);
			//move next slide to start position
			$($(this).attr('href')).show().animate({left: 0}, 400);
			$('img.js').hide();
			return false;
		});
	});
	$('a.imgguidenext').each(function(i)
	{
	    $(this).click(function()
		{	        
		    //move current slide left
			$(this).parents('div.guideitem').animate({left: -(liWidth*2)}, 400);
			//move next slide to start position
			$($(this).attr('href')).show().animate({left: 0}, 400);
			$('img.js').hide();
			return false;
		});
	    $(this).append('<img src="/kommunalse/guide/arrow.gif" class="js" style="position:absolute;left:380px;top:10px;z-index:9999;"/>');
	    $('img.js').hide();
		$(this).mouseover(function(){
		    $(this).children('img.js').fadeIn();
		});
		$(this).mouseout(function(){
		   $(this).children('img.js').fadeOut();
		});
	});
	$('a.imgguideprev').each(function(i)
	{
	    $(this).click(function()
		{	        
		    //move current slide left
			$(this).parents('div.guideitem').animate({left: (liWidth*2)}, 400);
			//move next slide to start position
			$($(this).attr('href')).show().animate({left: 0}, 400);
			$('img.js').hide();
			return false;
		});
	});
});