/**
 * jQuery - Config file
 */
jQuery(function($) {
	/**
	 * Google Analytics
	 */
	$.GATracker('UA-7202200-26');

	/**
	 * Window Open
	 */
	$('a[href^="http"]').not('a[href^="http://'+ location.host +'"]').winOpen();

	/**
	 * Image Rollover
	 */
	$('#gNavi a img').rollover();


	var page = location.pathname, option;
	var main = $('#main'), gNavi = $('#gNavi');

	// Top
	if (page === '/') {
		option = {
			src: '/img/top.swf',
			width: 900,
			height: 280
		};

		$('a', gNavi).not('[href="/"]').each(function() {
			var self = $(this), href = self.attr('href');
			self.attr('href', href +'#'+ href);
		});

	// Others
	} else {
		option = {
			src: '/share/img/other.swf',
			width: 900,
			height: 80
		};

		var isIE6 = $.browser.msie && $.browser.version === '6.0';

		if (isIE6) {
			var h = $('#header');
			h.css({position: 'absolute'});
			h.css({
				position: 'fixed',
				left: h.position().left - 450,
				margin: 0
			}).exFixed();
		}

		$('a:gt(0)', gNavi).live('click', function() {
			var self = $(this);
			$.historyLoad(self.attr('href'));
			return false;
		});

		$.historyInit(function(href) {
			$.get(href, function(targetHTML) {
				gNavi.empty().html(
					targetHTML
						.split(/<div id="gNavi" class="nav">/)[1]
						.split(/<!-- Section \[gNavi\] End --><\/div>/)[0]
				);
				$('img', gNavi).rollover();
				main.empty().html(
					targetHTML
						.split(/<div id="main">/)[1]
						.split(/<!-- Section \[main\] End --><\/div>/)[0]
				);
				$('#movie').movie(480, 360);
			});
		});
	}

	$('#header').html($('<div/>').flash(option));

	$('#movie').movie(480, 360);

});

