$(function() {
	function setHeightBody() {
		get_height_right = $('#ta_navi_right').height();
		get_height_left = $('#ta_navi_left').height();
		get_height_body = $('#body_frame').height();
		set_height_body = 0;
		//alert(get_height_right);
		//alert(get_height_left);
		//alert(get_height_body);
		if(get_height_right >= get_height_left && get_height_right >= get_height_body) {
			set_height_body = get_height_right;
		} else if(get_height_left >= get_height_right && get_height_left >= get_height_body) {
			set_height_body = get_height_left;
		} else {
			set_height_body = 'auto';
		}
		//alert(set_height_body);
		
		$('#body_frame').height(set_height_body);
		get_height_body = $('#body_frame_photo').height();
		if(get_height_left > get_height_body) {
			set_height_body = get_height_left;	
		} else {
			set_height_body = 'auto';
		}
		$('#body_frame_photo').height(set_height_body);
	}
	setHeightBody();
	function close_sub_navi(event) {
		event.preventDefault();
		$('#ta_sub_navi_left')
		.css(
			{
				'top':'-1000px',
				'display':'block'
			}
		);
	}
	$('#past_events')
	.bind('mouseover', function(event) {
		/*$('body')
		.append($('<div>')
			.attr('id', 'ta_sub_navi_left')
			.append($('<div>')
				.attr('id', 'sub_top')				
			)
			.append($('<div>')
				.attr('id', 'sub_mid')
				.append($('<div>')
					.attr('id', 'sub_left_top')
				)
				.append($('<div>')
					.attr('id', 'sub_left_bottom')					
				)
				.append($('<div>')
					.attr('id', 'sub_main')
					.append($('<ul>')
						.append($('<li>')
							.append($('<a href="runners.php?marathon_date=201004" <?php echo $now_201004;?>>')
								.html('Donating to our<br />2010 Half-Marathon Team')
							)
						)
						.append($('<li>')
							.append($('<a href="runners.php?marathon_date=200911" <?php echo $now_200911;?>>')
								.html('Donating to our<br />2009 ING Marathon Team')
							)
						)
					)
				)
				.append($('<div>')
					.attr('id', 'sub_right')
				)
			)
			.append($('<div>')
				.attr('id', 'sub_bottom')
			)
		)*/
		
		var body_width = $(window).width();
		var body_height = $(window).height();
		var point = $('#past_events').offset();
		//alert(point.left);
		//alert(point.top);
		//alert($('#sub_main').height());
		$('#sub_mid')
		.css(
			{
				'height':$('#sub_main').height() + 'px'
			}
		);
		$('#sub_right')
		.css(
			{
				'position':'absolute',
				'top': point.top + 'px',
				'left':(360 + point.left) + 'px',
				'height':$('#sub_main').height() + 'px',
				'width':(body_width - 360 - point.left) + '180px'
			}
		);
		$('#sub_left_bottom')
		.css(
			{
				'position':'absolute',
				'top': (point.top + $('#past_events').height()) + 'px',
				'left': '0px',
				'height':($('#sub_main').height() - $('#past_events').height()) + 'px',
				'width':(180 + point.left) + 'px'
			}	 
		);
		
		$('#sub_left_top')
		.css(
			{
				'position':'absolute',
				'top': point.top + 'px',
				'left':point.left + 'px',
				'height':$('#past_events').height() + 'px',
				'width':'180px'
			}
		);
		$('#sub_main')
		.css(
			{
				'position':'absolute',
				'top':point.top + 'px',
				'left':(point.left + 180) + 'px'
			}
		);
		
		$('#ta_sub_navi_left')
		.css(
			{
				'position':'absolute',
				'top':'0',
				'left':'0',
				'width':body_width + 'px',
				'height':body_height + 'px'
			}
		);
		$('#sub_top')
		.css(
			{
				'height':point.top + 'px',
				'width':body_width + 'px'
			}
		);
		
		$('#sub_bottom')
		.css(
			{
				'height': (body_height - point.top) + 'px',
				'width':body_width + 'px'
			} 
		);
		$('#ta_sub_navi_left').show();
		$('#sub_top, #sub_bottom, #sub_right, #sub_left_bottom')
		.bind('mouseover', close_sub_navi);
	});
	$('#sub_top, #sub_bottom, #sub_right, #sub_left_bottom')
		.bind('mouseover', close_sub_navi);
	
	
});