var j = jQuery.noConflict();
j(document).ready(function($){

    // Clickable Logo
    $('body').addClickableLogo({
        name: 'International Association of TORCH Clubs',
        url: 'http://www.torch.org/'
    });

	// Map Popups
	$('#region2, #region5, #region6').each(function(){
		$(this).clone().attr('id',$(this).attr('id') +'b').insertAfter($(this));
	});
	$('#iatcMap area').bind({
		mouseover: function(event){
			var id = $(this).attr('alt');
			showPopup(id);
		},
		mouseout: function(){
			var id = $(this).attr('alt');
			hidePopup(id);
		}
	});
	$('#iatcMap .popup').bind({
		mouseover: function(){
			var id = $(this).attr('id');
			showPopup(id);
		},
		mouseout: function(){
			var id = $(this).attr('id');
			hidePopup(id);
		}
	});
	
	var timer = 0;
	function showPopup(id){
		clearTimeout(timer);
		$('#mapiatc').attr('src','/associations/12231/imgs/map-'+ id +'.png');
		$('#'+id).stop(true,true).show();
	}
	function hidePopup(id){
		clearTimeout(timer);
		$('#'+id).delay(200).animate({
			bottom: '+=25',
			opacity: 0,
			filter: 'alpha(opacity=0)'
		}, 200, 'linear', function(){
			$('#'+id).removeAttr('style').hide();	
		});
		timer = setTimeout("j('#mapiatc').attr('src','/global/css/imgs/trans1.gif')",200);
	}
	
	/*
	// Mouse Following Popups
	$('#iatcMap area').bind({
		mouseover: function(event){
			var id = '#'+ $(this).attr('alt');
			var h = $(id).height();
			var w = $(id).width();
			$(id).stop(true,true).css('top', event.pageY-h-5 +'px').css('left', event.pageX-(w/2) +'px').fadeIn('fast');
		},
		mousemove: function(event){
			var id = '#'+ $(this).attr('alt');
			var h = $(id).height();
			var w = $(id).width();
			$(id).css('top', event.pageY-h-5 +'px').css('left', event.pageX-(w/2) +'px');
		},
		mouseout: function(){
			var id = '#'+ $(this).attr('alt');
			$(id).delay(1000).animate({
				top: '-=25',
				opacity: 0
			}, 200, 'linear', function(){
				$(this).hide().css('opacity',1);	
			});
		}
	});
	$('#iatcMap .popup').bind('mouseover', function(){
		$(this).stop(true,true).show();
	});
	*/
	
});
