$(function(){
    $('#local-area-map').hover(
        function(){$('#local-area-map .box').css('z-index', '-1');},
        function(){$('#local-area-map .box').css('z-index', '99');}
    );
    
    $('#local-area-map ul').addClass('areas');
    $('#greater-london-map ul').addClass('areas');

    $('.London').click(function(event) {				   
        $('#greater-london-map').fadeIn(400);
        event.preventDefault();
    });

    $('#dialog_surrey').dialog({
        autoOpen: false,
        modal: true,
        resizable: false
    });
    $('.Surrey').click(function(event) {				   
        $('#dialog_surrey').dialog('open');
        event.preventDefault();
    });

//    $('.Kent, .IOW, .Wiltshire, .Hampshire, .WSussex, .Surrey, .ESussex, .Essex, .Bucks, .Norths, .Lincs, .Cambs, .Norfolk').click(function() {				   
//  	$('#greater-london-map').css({'visibility' : 'hidden'});
//    });
    //$('.area:not(.London, #greater-london-map .area)').hover(
    //    function(){$('#greater-london-map').css({'visibility' : 'hidden'});},
    //    function(){}
    //);

    var glm_timeout;
    $('#greater-london-map').hover(
        function(){clearTimeout(glm_timeout);},
        function(){glm_timeout=setTimeout(function(){$('#greater-london-map').fadeOut(200);}, 600);}
    );


    $('#local-area-map #message').text('Click on your local area or enter your postcode below.');

    $('#local-area-map li a').hover(
        function(event){$('#lam_tooltip').stop(true, true).text($(this).attr('title')).css({'top': (event.pageY-20-$('#local-area-map').offset().top)+'px', 'left': (event.pageX+20-$('#local-area-map').offset().left)+'px'}).fadeIn(250); $(this).attr('title', '');},
        function(){$(this).attr('title', $('#lam_tooltip').text()); $('#lam_tooltip').fadeOut(200);}
    );
});

