
var j$ = jQuery.noConflict();

j$(document).ready(function(){
	// apply popup styles.
	j$('#gnavi01 > li > ul').each(function(e){
		var w = 0;
		// calc child elements width.
		j$(this).show().children('li').each(function(e){
			w += j$(this).width();
		});
		j$(this).hide().css({'width': w +'px', 'opacity': '0.8'});
	});

	// define popup behavior.
	j$('#gnavi01 > li').hover(
		function(){
			j$(this).children('ul').slideDown(128);
			if (document['aexternal']) {
				document["aexternal"].setOver(j$('#gnavi01 > li').index(this) + 1);
			}
		},
		function(){
			j$(this).children('ul').slideUp(128);
			if (document['aexternal']) {
				document["aexternal"].setOver(0);
			}
		}
	);
	j$('#gnavi01 > li > ul').hover(
		function(){
			var imgSrc = j$(this).siblings('a').children('img.over').attr('src');
			j$(this).siblings('a').children('img.over').attr('src', imgSrc.replace(/^(.+)(\.[a-z]+)$/, '$1_over$2'));
		},
		function(){
			var imgSrc = j$(this).siblings('a').children('img.over').attr('src');
			j$(this).siblings('a').children('img.over').attr('src', imgSrc.replace(/^(.+)_over(\.[a-z]+)$/, '$1$2'));
		}
	);

	// set rollover.
	j$('img[@class=over]').hover(
		function(){
			this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1_over$2');
		},
		function(){
			this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, '$1$2');
		})
		.each(function(){
			this.preloaded = new Image;
			this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1_over$2');
		}
	);

	// open popup window. (630x???)
	j$('a[@class=popup]').click(function(){
		window.open(this.href, '_blank', 'status=yes,toolbar=no,location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=630');
		return false;
	});

	// open popup window for privacy policy. (735x???)
	j$('a[@class=popup-privacy]').click(function(){
		window.open(this.href, '_blank', 'status=yes,toolbar=no,location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=735');
		return false;
	});

	// open popup window for access map. (890x430)
	j$('a[@class=popup-map]').click(function(){
		window.open(this.href, '_blank', 'status=yes,toolbar=no,location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=890,height=430');
		return false;
	});

	// open popup window for access map. (890x430)
	j$('a[@class=blank]').click(function(){
		window.open(this.href, '_blank');
		return false;
	});

	// map button handler.
	j$('#sidebar01 ul.extra div.contact input').click(function(){
		location.href = j$(this).parent('a').attr('href');
		return false;
	});

});

// open popup for flash.
function win(url){
	window.open(url, 'popup2', 'status=yes,toolbar=no,location=yes,menubar=yes,scrollbars=yes,width=630');
}
