$(function(){	//handle map functionality during node editing
	$('#locationXY').each(function(){
		$('.map').each(function(){
			place_point($('#locationXY').val().split(','));		
		}).click(function(e){
			base=$(this).offset();
			var xy=(e.pageX-base.left)+','+(e.pageY-base.top);
			$('#locationXY').val(xy);
			place_point(xy.split(','));
		});	
	});

	$('#links1 A,#links2 A').click(function(){
		$('#'+$(this).attr('id').replace('location','point')).click();
	});
	
	$('.map').click(function(){
	});

	$('.map .point').each(function(){
		var xy=$(this).children('SMALL').html().split(',');
		$(this).css('top',xy[1]+'px').css('left',xy[0]+'px').show();
		
		$(this).mouseover(function(){
			var content=$(this).children('ADDRESS').html().replace(/[\r\n]/g,'<br />');
			_top=parseInt($(this).css('top'))-119;
			_left=parseInt($(this).css('left'))-79;
			$('.infowindow').css('top',_top+'px').css('left',_left+'px').show().html(content);
			//$('.locationInformation').html($(this).children('DIV').html());
		});
		$(this).mouseout(function(){$('.infowindow').hide()});
		
		$(this).click(function(e){
			$('.locationInformation').hide();
			$('#'+$(this).attr('id').replace('point_','info')).show();
		});

	});
	

		$('.mapTextLink').each(function(){
			var id='#'+$(this).attr('id').replace('link_','point_');
			$(this).click(function(){$(id).click()});
			$(this).mouseover(function(){$(id).mouseover()});
			$(this).mouseout(function(){$(id).mouseout()});
		});
	
	
	
		
	$('#homepage-banner ul').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '60px'
	});	
		


});




function place_point(xy){
	$('.map .point').remove();
	$('.map').append('<div class="point"></div>');
	$('.map .point').each(function(){
//		xy[0]-=12;
//		xy[1]-=12;
		$(this).css('top',xy[1]+'px').css('left',xy[0]+'px').show();
	});
};