//FlashPlayerバージョン
var majorFlashVersion = '9';

//代替アンカーリンク
function backToTop() {
window.scrollTo(0,0);
}
function link() {
document.write('<p class="pagetop"><a href="JavaScript:void(0);" onclick="backToTop(); return false"><img src="/common/img/img_pagetop_off.gif" width="119" height="19" alt="ページの先頭へ" /></a></p>');
}

//Netscapeには読み込ませない
if((navigator.userAgent.indexOf('Firefox')==-1) && (navigator.appName=='Netscape')) {

} else {
	document.write('\
	<script type="text/javascript" src="/common/js/ui.core.js"></script>\
	<script type="text/javascript" src="/common/js/jquery.easing.1.3.js"></script>\
	<script type="text/javascript" src="/common/js/jquery.cookie.js"></script>\
	<script type="text/javascript" src="/common/js/jquery.scrollfollow.js"></script>\
	');
}

// mouseover script
// @param なし
// @return なし
$(function imgOver() {
	$('img').each(function() {
		var node = this;
		if(node.src.match("_off.")) {
			node.originalSrc = node.src;
			node.temporarySrc = node.originalSrc.replace(/_off/,'');
			node.rolloverSrc = node.temporarySrc.replace(/(\.gif|\.jpg|\.png)/,'_on'+"$1");
			//画像のプリロード処理開始
			preloadImage(node.rolloverSrc);
			//Mouseover
			node.onmouseover = function() {
				this.src = this.rolloverSrc;
			}
			//Mouseout
			node.onmouseout = function() {
				if(this.className!='active') {
					this.src = this.originalSrc;
				}
			}
		}
	});
});

// 画像のプリロードを行う関数
// @param string 画像のパス
// @return なし
preloadImages = [];
preloadImage = function(path) {
	var pre = preloadImages;
	var len = pre.length;
	pre[len] = new Image();
	pre[len].src = path;
}

// global nav active
// @param なし
// @return なし
$(function setGlobalActive() {
	//画像のアクティブ・非アクティブ
	if(activeMenu) {
		$('#menu-area .global li img,#menu-area .subnav li img').each(function(index,node) {
			if(activeMenu==index) {
				this.src = this.rolloverSrc;
				$(this).addClass('active');
			}
		});
	}
	//グローバルメニュー追っかけ（Netscapeには読み込ませない）
	if((navigator.userAgent.indexOf('Firefox')==-1) && (navigator.appName=='Netscape')) {
		
	} else {
		//ブランドヒストリーページでは停止（Flash PlayerのVersionが低い時のみ再生）
		if(!document.URL.match(/\/history\//)) {
			$('#menu-area').scrollFollow({});
		} else {
			var requestedVer = new deconcept.PlayerVersion([majorFlashVersion,0,0]);
			var installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
			if (!installedVer.versionIsValid(requestedVer)) {
				$('#menu-area').scrollFollow({});
			}
		}
	}
});



// local nav active
// @param なし
// @return なし
$(function setLocalActive() {
	//.local-nav dl
	$('#main-area .local-nav dl').each(function(index,node) {
		this.index = index;
		$(this).addClass('active');
		this.child = this.getElementsByTagName('img')[0];
		this.child.activeSrc = this.child.temporarySrc.replace(/(\.gif|\.jpg|\.png)/,'_active'+"$1");
		preloadImage(this.child.activeSrc);
		
		if(activeNav==this.index) {
			this.child.src = this.child.activeSrc;
			$(this.child).addClass('active');
		}
		this.onmouseover = function() {
			$(this).addClass('on');
			this.child.src = this.child.rolloverSrc;
		}
		this.onmouseout = function() {
			$(this).removeClass('on');
			if(this.child.className!='active') {
				this.child.src = this.child.originalSrc;
			} else {
				this.child.src = this.child.activeSrc;
			}
		}
	});
	//.local-nav li img
	$('#main-area .local-nav li img').each(function(index,node) {
		if(activeNav==index) {
			this.src = this.rolloverSrc;
			$(this).addClass('active');
		}
	});
});

//外部リンクにクラス名「external」、target="_blank"を追加
$(function addExtLink() {
	$('#main-area a').each(function() {
		var selfDomain = document.domain;
		if((this.href.indexOf(selfDomain)==-1) && (this.href.indexOf('mailto')==-1) && (this.href.indexOf('http://www.adobe.com/')==-1)) {
			$(this).addClass('external');
			$(this).attr('target','_blank');
		}
	});
});
