/* ------------------------------------------------------------
	
	filename:	navigation.js
	created:	071020
	update:		071214
	copyright:	(c)2008 Intelligentnet, Inc. All rights reserved.
	
------------------------------------------------------------ */

$(function(){
	//別窓ウインドウ
	$('[@href^="http"]').not('[@href*="'+document.domain+'"]').click(function(){
		window.open(this.href, "_blank");
		return false;
	}).each(function() {
		$(this.parentNode).addClass('external');
	});

	//PDF
	$('a[@href$=".pdf"]').click(function(){
		window.open(this.href, "_blank");
		return false;	
	}).each(function() {
		$(this.parentNode).addClass('pdf');
	});	

	var pdfIcon = '<img src="/common/images/icon-pdf.gif" alt="PDF">';
	$('div#mainContents ul.links li a[@href$=".pdf"]').after(pdfIcon);
	$('div#mainContents dd.links a[@href$=".pdf"]').after(pdfIcon);
	
	urlEn = location.href.indexOf("/en/");
	if (urlEn == -1){
		$('[@href^="http"]').filter('[@href!*="'+document.domain+'"]').attr("title","別ウィンドウが開きます");
		$('[@href$=".pdf"]').attr("title","別ウィンドウが開きます");
	} else {
		$('[@href^="http"]').filter('[@href!*="'+document.domain+'"]').attr("title","Another window opens.");
		$('[@href$=".pdf"]').attr("title","Another window opens.");
	}
	
	//ローカルナビカレント表示
	$('div#localNav a[@href]').each(function(){
		var crURL = location.href.split("#");
		if (this.href == crURL[0]) {
			$(this.parentNode).addClass('current');
		}
	});

	$('div#localNav ul li ul li a[@href]').each(function(){
		if (this.href == location.href) {
			$(this.parentNode.parentNode.parentNode).addClass('open');
		}
	});
	
	//Scroll
	var pageUrl = location.href.split('#')[0];
	$('a[@href]').each(function() {
		if (this.href.indexOf(pageUrl + '#') == 0) {
			var id = this.href.split('#')[1];
			$(this).click(function() {
				$('#' + id).ScrollTo(300, 'easeout');
				return false;
			});
		}
	});
	
	//ボタン
	$('.btn img').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "-on$1");
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});	

	$('.btn input').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "-on$1");
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});	

	$('ul.globalNav img').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "-on$1");
	}).hover(function(){
		$(this).attr('src',this.rolloverSrc);
	},function(){
		$(this).attr('src',this.originalSrc);
	});	


});  