// JavaScript Document

// マイドメインの指定

var mydomain="http://"+location.host;
var mySSLdomain="https://"+location.host;

// ホームトピックスのカラーリング

$(function(){
	$('#home-topics dd:odd').addClass('color');
});

// メニュータブの開閉

$(function(){
	$("#menu h3").toggle(function(){
		$(this).addClass("close");
		$(this).next(".menu-inner").toggle();
	},
	function(){
		$(this).removeClass("close");
		$(this).next(".menu-inner").toggle();
	});
});

$(function(){
	$(".general #sub-menu h3").toggle(function(){
		$(this).addClass("close");
		$(this).next(".inner").toggle();
	},
	function(){
		$(this).removeClass("close");
		$(this).next(".inner").toggle();
	});
});

// リンク制御

$(function(){

	$('#contents a[href^="http"], #menu a[href^="http"], #sub-menu a[href^="http"]')
		.not('a[class*="no-mark"], a[href^='+ mydomain +'], a[href^='+ mySSLdomain +'], a[href$=".pdf"], a[href$=".doc"], a[href$=".xls"], a[href$=".docx"], a[href$=".xlsx"], :has(img)')
		.after('<span class="blank">&nbsp;</span>')
		.click(function(){
			window.open(this.href, '_blank');
			return false;
	});
	
	$('#home-info a, #contents-inner a')
		.not('a[class*="no-arrow"], :has(img)')
		.before('<span class="link-mark">&nbsp;</span>');
	
	$('#contents a[href$=".pdf"], #menu a[href$=".pdf"], #sub-menu a[href$=".pdf"]')
		.not('a[class*="no-mark"], :has(img)')
		.after('<span class="pdf">&nbsp;</span>')
		.click(function(){
			window.open(this.href, '_blank');
			return false;
	});
	
	$('#contents a[href$=".doc"], #menu a[href$=".doc"], #sub-menu a[href$=".doc"], #contents a[href$=".docx"], #menu a[href$=".docx"], #sub-menu a[href$=".docx"]')
		.not('a[class*="no-mark"], :has(img)')
		.after('<span class="word">&nbsp;</span>')
		.click(function(){
			window.open(this.href, '_blank');
			return false;
	});
	
	$('#contents a[href$=".xls"], #menu a[href$=".xls"], #sub-menu a[href$=".xls"], #contents a[href$=".xlsx"], #menu a[href$=".xlsx"], #sub-menu a[href$=".xlsx"]')
		.not('a[class*="no-mark"], :has(img)')
		.after('<span class="excel">&nbsp;</span>')
		.click(function(){
			window.open(this.href, '_blank');
			return false;
	});
	
	$('#contents a[href^="mailto"], #menu a[href^="mailto"], #sub-menu a[href^="mailto"]')
		.not('a[class*="no-mark"], :has(img)')
		.after('<span class="mail">&nbsp;</span>');
	
	$('#banner-link a')
		.click(function(){
			window.open(this.href, '_blank');
			return false;
	});
});
