$(function() {

    // Link logo to the home page

    var logoURL = '/index.php?sid=32489&lang=en&act=page&id=127684';
    var logoTitle = 'B Nebbet and Son';
    var buildLink = '<a href="'+ logoURL +'" title="'+ logoTitle +'"></a>'; 
    
    $('#siteMainDynHeaderImage1').wrap(buildLink);
    
    
    // add telephone box to the header area
    
    var boxText = '020 8648 7379';
    var buildBox = '<div id="headerContact">'+ boxText +'</div>';
    
    $('#header').prepend(buildBox);
    
    // menu items - add class on hover
    
	$('.sitemenu ul li ul').addClass('open');
	
    $('.sitemenu ul li').hover(
    function() {
        $(this).addClass('hover');
		if($('ul',this).hasClass('open')){
			$('ul',this).removeClass('open');
			$('ul',this).fadeIn(200);
		}
    }, 
    function() {
        $(this).removeClass('hover');
		$('ul',this).fadeOut(200, function() {
			$(this).addClass('open');
		});
    });
	
	$('.sitemenu > ul > li > ul > li.first').remove();
	$('.sitemenu > ul > li.current > ul > li.current').parent().parent().removeClass('current');
    
    // add class to submenu parent
    
    $('#header .sitemenu > ul > li > ul').parent().find('> a').addClass('submenu');
    
    // move slider
    
    $('.sliderTarget').html($('#bgSlideshow'));
	
	// Calculate height of the tallest blueColumn
	var max = 0;    
	$('.blueColumn').each(function() {
		max = Math.max($(this).height(), max);
	}).height(max);
	
	// Create CTA
	$('.homeBody #content address').appendTo('.wideImage');
    
});
