/*
	基本のJS
	作成日：080211
	更新日：080211
*/
jQuery.noConflict();
var j$ = jQuery;

/* ちらつき回避 */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

j$(function(){
	// 見出しの前にロケータがある場合
	j$("div#mainContents div.locator h2:first-child").addClass("siblingA");//margin-top: 10px;
	j$("div#mainContents div.locator h3:first-child").addClass("firstChild");//margin-top: 10px;
	j$("div#mainContents div.locator h4:first-child").addClass("firstChild");//margin-top: 10px;
	j$("div#mainContents div.locator + h2").addClass("siblingA");//margin-top: 10px;
	j$("div#mainContents div.locator + h3").addClass("siblingA");//margin-top: 10px;
	j$("div#mainContents div.locator + h4").addClass("siblingA");//margin-top: 10px;

	// 見出し要素の後ろにカラムがある場合
	j$("div#mainContents h2 + div.locator h3:first-child").addClass("siblingB");//margin-top: 0;

	// 見出しが連続する場合
	j$("div#mainContents h2 + h3").addClass("siblingB");//margin-top: 0;
	j$("div#mainContents h3 + h4").addClass("siblingB");//margin-top: 0;

	// lastChild
	j$("div#platform p:last-child").addClass("lastChild");
	j$("div#platform ul:last-child").addClass("lastChild");
	j$("div#platform ol:last-child").addClass("lastChild");
	j$("div#platform li:last-child").addClass("lastChild");
	j$("div#platform dl:last-child").addClass("lastChild");
	j$("div#platform dt:last-child").addClass("lastChild");
	j$("div#platform dd:last-child").addClass("lastChild");
	j$("div.inner > :last-child").addClass("directLastChild");

	// lastChild
	j$("div#platform p:first-child").addClass("firstChild");
	j$("div#platform ul:first-child").addClass("firstChild");
	j$("div#platform ol:first-child").addClass("firstChild");
	j$("div#platform li:first-child").addClass("firstChild");
	j$("div#platform dl:first-child").addClass("firstChild");
	j$("div#platform dt:first-child").addClass("firstChild");
	j$("div#platform dd:first-child").addClass("firstChild");

	j$("div#mainContents p.symbol + ul").addClass("symbol");
	
	// adjoin
	j$("div#mainContents div.locator + p.submit").addClass("adjoining");
	j$("div#mainContents div.itemsA + p.submit").addClass("adjoining");

	urlEn = location.href.indexOf("/en/");
	if (urlEn == -1){
		j$('[@href^="http"]').filter('[@href!*="'+document.domain+'"]').attr("title","別ウィンドウが開きます");
		j$('a[@href$=".pdf"]').attr("title","別ウィンドウが開きます");
	
		//プリントボタン
		j$('p.printBtn img').click(function(){
			window.open("/print.html?"+location.href);
		});		
	} else {
		j$('[@href^="http"]').filter('[@href!*="'+document.domain+'"]').attr("title","Another window opens.");
		j$('a[@href$=".pdf"]').attr("title","Another window opens.");
		
		//プリントボタン
		j$('p.printBtn img').click(function(){
			window.open("/en/print.html?"+location.href);
		});	
	}
	
	//奇数、偶数を自動追加
	j$('ul').each(function(){
		j$(this).find('li:odd').addClass('even');
		j$(this).find('li:even').addClass('odd');
	});
	j$('table').each(function(){
		j$(this).find('tr:odd').addClass('even');
		j$(this).find('tr:even').addClass('odd');
	});
	
/*	//簡単カレント表示
	j$('div#sectionNav a[@href]').each(function(){
			var localHref = this.href.split('/');
			var locationHref = location.href.split('/');
		alert(localHref + " debug:"+ locationHref)

		if (localHref[3] == locationHref[3]) {
			j$(this.parentNode).addClass('current');
			var oriSrc = j$(this.childNodes).attr('src');
			var crSrc = oriSrc.replace(/(\.gif|\.jpg|\.png)/, "-on$1");
			j$(this.childNodes).attr('src',crSrc).attr('height',27);
			
		}
	});
	
	//カレント表示
	if(j$('div#topicPath ul li').length){
		var pathFirst = j$('div#topicPath ul li')[1].innerHTML.replace(/\s/g,'').replace(/\<[^>]*\>/g, "");
		j$('div#localNav ul li a[@href]').each(function(){
			var categoryTxt = this.innerHTML.replace(/\s/g,'').replace(/\<[^>]*\>/g, "");
			//alert(pathFirst+'\n'+categoryTxt);
			if (categoryTxt == pathFirst) {
				j$(this.parentNode).addClass('current');
			}
			//if (this.href == location.href) {
				//j$(this.parentNode).addClass('current');
			//}
		});
	}
*/	
	//ポップアップ
	j$('a[@href~="/sim.html"]').click(function(){
		
		window.open(this.href, "shop","width=690,height=320");
		return false;
	});

	j$('[@href~="/sim.html"]').click(function(){
		
		window.open(this.href, "shop","width=690,height=320");
		return false;
	});


	//申し込み
	j$('a[@href^="https://www.fusioncom.co.jp/toiawase/h_rm-inquiry.shtml"]').attr("href","javascript:location.href=inq");
	j$('a[@href^="https://www.fusioncom.co.jp/toiawase/h_rm_req.shtml"]').attr("href","javascript:location.href=req");


		

});
