jQuery(document).ready(function($){
	//Initially rotator
	$("#slideshow-holder a.BackOffice_Link").wrapAll('<div id="admin-holder">');
	$('#admin-holder').prependTo('#content-holder');
	$('#slideshow-holder br' ).remove();
	$("#slideshow-holder").cycle ({
			fx			: 'fade',
			speed		: '2000',
			timeout		: '7000',
			random		: true 
		});
	//Blocks on home page animated function
	$('.block .content-holder').hover(function(){
			$(this).animate({queue:false, paddingTop:'30px', duration: '5000' });
		}, function(){
			$(this).animate({queue:false, paddingTop:'9px', duration: '5000', complete:true});		
	});		
			
	//Menu elements
	$("li.level1-item:has(li)").addClass("level2").parent();	
	$("li.selected .level2").clone().appendTo('#left-block .left');
	// Add hover function for menu overflow visible
	$("#level1").hover(function(){
		$(this).parents('#header').css('overflow', 'visible');
	}, function(){
		$(this).parents('#header').css('overflow', 'hidden');
	});
	
	// Add class to menu items with a mouseover and remove when mouse is out
	$("#level1 li").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});
	
	//Initially show fax/phone
	$('#companyinfo .list-item .info:empty').parent().hide();
	
	// Calculate width of menu items (adminBlock)
	var totalWidth = $("#menu.top").outerWidth();
	var startWidth = 0;
	
	// Append other menu item (adminBlock)
	$(".level1-item").each(function() {
		startWidth += $(this).outerWidth();
		if(startWidth > totalWidth)
		{
			$(this).appendTo("#adminBlockWrapper").parent().css('border', '4px solid #cdcfd2').css('padding', '20px');
		}	
	});
	
});	
