// 文字コード: UTF-8
$(document).ready(function() {
	function bindAjaxActions() {
		// Safariは対象外
		if ($.browser.safari) {
			return true;
		}

		$(this).bind('click', function() {
			function errorProcess() {
				location.href = this.url;
			}

			function successProcess(xhtml) {
				$('#news-header').html($(xhtml).find('#news-header').eq(0).html());
				$('#news-body').parent().html($(xhtml).find('#news-body').eq(0).parent().html());

				$('#news-header a').each(bindAjaxActions);
				$('#news-header,#news-body').find('a').each(bindOpenAnotherWindow);
			}

			$('#news-body')
				.css('position', 'relative')
				.css('min-height', '48px')
				.children()
				.css('visibility', 'hidden')
				.filter(':first-child')
				.before('<p style="position: absolute;"><img src="../image/common/ajax-loader.gif" width="48" height="48" alt="Now loading..." title="" /></p>');

			if ($.support.htmlSerialize) {
				$.ajax({
					type: 'GET',
					url: $(this).attr('href'),
					data: 'type=xml',
					timeout: 1000,
					success: successProcess,
					error: errorProcess
				});
			} else {
				$.ajax({
					dataType: 'html',
					type: 'GET',
					url: $(this).attr('href'),
					data: 'type=xml',
					timeout: 1000,
					success: successProcess,
					error: errorProcess
				});
			}

			return false;
		});
	}

	$('#news-header a').each(bindAjaxActions);
});
