//IE用画像ちらつき防止
try { 
document.execCommand('BackgroundImageCache', false, true); 
} catch(e) {}

//IE6のメイリオ
document.getElementsByTagName('html')[0].setAttribute('lang','ja');

//以下RO
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/
function initRollovers() {

	if (!document.getElementById) return
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'swap') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

$(document).ready(initRollovers);

/*
自リンクの場合、オーバー画像を表示
*/
function SelfLinkImage() {
	var url = location.pathname
	var dir = url.split('/');

	/*
	除外ディレクトリ設定
	*/
	if(dir[1] != '' && dir[1] != 'information' && dir[1] != 'banner' && dir[1] != 'staff' && dir[1] != 'privacy' && dir[1] != 'clients' && dir[1] != 'mt' && dir[1] != 'Terms-of-Use' && dir[1] != 'common' && dir[1] != 'skeleton-cart'){
		var currentDirectory = '/' + dir[1] + '/'
	}else{
		var currentDirectory = '/'
	}

	/*
	トップページを除外
	*/
	if(currentDirectory != '/'){
	var currentA = $('#header ul li a[@href=' + currentDirectory + '] img');

	var imgsrc = currentA.attr('src');
	var dot = imgsrc.lastIndexOf('.');
	var imgsrcCurrent = imgsrc.substr(0, dot) + '_on' + imgsrc.substr(dot, 4);

	currentA.attr({ src: imgsrcCurrent });
	currentA.removeClass('swap');
	}
};

$(document).ready(SelfLinkImage);

/*
自リンクの<A>を削除
*/
function SelfLinkAnchor() {

	var href = location.href.split('#')[0];

		$('a').not('.logo-link').each(function() {
		  if (href == this.href)
		    $(this)
		     .before(this.childNodes)
		     .remove();
			});

};

$(document).ready(SelfLinkAnchor);
