$(document).ready(function() {
    $('#tabbedBoxContent .tab:not(:first)').css('display', 'none');
    $('#tabbedList li:first a').addClass('selected');
    
    $('#tabbedList li a').click(function() {
        var id = $(this).attr('href');
        
        $('#tabbedBoxContent .tab').css('display', 'none');
        $('#tabbedList li a').removeClass('selected');
        
        $('#tabbedBoxContent .tab:has(a[name='+id.substring(1)+'])').css('display', 'block');
        $('#tabbedList li a[href=#'+id.substring(1)+']').addClass('selected');
        
        $('#tabbedBoxContent .tab:has(a[name='+id.substring(1)+']) .location li:first a').click().addClass('selected');
        
        $('.tab:has(a[name='+id.substring(1)+']) .location .map').each(function() {
            var centerLatitude = Number($(this).attr('centerLat'));
            var centerLongitude = Number($(this).attr('centerLong'));
            var myLatlng = new google.maps.LatLng(centerLatitude, centerLongitude);
            var myPointer = new google.maps.LatLng(centerLatitude, centerLongitude); 
            
            var myOptions = {
              zoom: Number($(this).attr('zoom')),
              center: myLatlng,
              draggable: false,
              scrollwheel: false,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById($(this).attr('id')), myOptions);
    
            var marker = new google.maps.Marker({
                position: myPointer, 
                map: map
            });
        });

        return false;
    });
    
    $('#tabbedBoxContent .location .times:not(:first)').css('display', 'none');
    $('#tabbedBoxContent .location ul:first li:first a').addClass('selected');
    
    $('#tabbedBoxContent .location li a').click(function() {
        var id = $(this).attr('href');
        
        $('#tabbedBoxContent .location .times').css('display', 'none');
        $(this).parents('ul:first').find('li a').removeClass('selected');
        
        $('#tabbedBoxContent .location .times.'+id.substring(1)).css('display', 'block');
        $(this).addClass('selected');
        
        return false;
    });
});
