/**
 * jQuery - Config file
 */
jQuery(document).ready(function($)
{
	$.googleAnalytics('UA-10800406-1');

	$('a[href^="http"]').not('a[href^="http://'+ location.host +'"]').NewWinOpen();
	$('a img, input:image').not('#header h1 img').rollover();

	var basePath = location.pathname.split('/')[1];
	basePath = basePath == '' ? '/' : '/' + basePath + '/';

	/**
	 * Wrapper background image
	 */
	$('body')
		.css('backgroundImage', 'url(' + basePath + 'share/img/body_bg.jpg)')
		.find('#container')
			.wrapInner('<div id="wrap" />')
			.find('#wrap')
				.css('backgroundImage', 'url(' + basePath + 'share/img/wrap_bg.jpg)')
			.end()
		.end()
	;

	/**
	 * Global navigation subnavi
	 */
	var active = [], src = [], time = [];
	var innerList = $('#gNavi li ul');
	innerList
		.css({
			display  : 'none',
			position : 'absolute',
			top      : '0',
			left     : '200px'
		})
		.each(function(i) {
			var
				self   = $(this),
				parent = self.parent(),
				image  = parent.find('img:first')
				child  = self.find('a');
			parent
				.hover(
					function() {
						if (active[i] == true) return;
						innerList.not(self).hide();
						clearTimeout(time[i]);
						active[i] = true;
						self.show(300);
					},
					function() {
						active[i] = false;
						time[i] = setTimeout(function() {
							self.hide(300);
						}, 1000)
					}
				)
			;
		})
	;

	var photos = $('#floorGuide');
	if (photos.size() > 0) {
		$('a', photos).lightBox();
	}

	$('a[href="/nara/virtual/"]').NewWinOpen([
		'width=950',
		'height=599',
		'center=no',
		'location=no',
		'toolbar=no',
		'status=no',
		'menubar=no',
		'scrollbars=no',
		'directories=no',
		'resizable=no',
		'maximize=no'
	].join(','));
});
