// mouseover script
// @param なし
// @return なし
$(function imgOver() {
    $('img, input:image').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");
            node.activeSrc = node.temporarySrc.replace(/(\.gif|\.jpg|\.png)/,'_active'+"$1");
            //画像のプリロード処理開始
            preloadImage(node.rolloverSrc);
            //Mouseover
            node.onmouseover = function() {
                if(this.className!='active') {
                    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;
}


//デザイン修正
$(function addTrClass() {
    $('#Contents .com_flbox .flin .linebox:first-child dl').addClass('top');
    $('#Contents .com_slbox .listbox .line:last-child').addClass('bot');
    $('#Contents .com_slbox .listbox.long .line .list:odd').addClass('odd');
    $('#Contents .com_slbox .listbox.long .line .list:last-child').addClass('last');
    $('#PDBOX .pd_listbox ul li:first-child').addClass('top');
    $('#TPBOX .grbox .grin .picbox .line dl:first-child').addClass('top');
    $('#DTBOX .mlsbox .navibox ul li:first-child').addClass('top');
});


//外部リンクにクラス名「external」、target="_blank"を追加
$(function addBlankExtLink() {
    var selfDomain = document.domain;
    $('a').each(function() {
        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');
        }
    });
});

//ページスクロール
$(function pagetop() {
        $('.com_toppage a').click(function () {
            $(this).blur();

			if (window.opera)
			{
				$('html').animate({ scrollTop: 0 }, 'fast');
			}else{
				$('html,body').animate({ scrollTop: 0 }, 'fast');
			}
            return false;
        });
});


var selecttarget = "";

//セレクトボックス
$(function jump() {
    $('.headbox .catebox .btn a').click(function () {
		var url = document.form1.select.options[document.form1.select.selectedIndex].value;
	
		if(url != "" ){
			if(selecttarget == 'top'){
				top.location.href = url;
			}
			else if(selecttarget == 'blank'){
				window.open(url, 'window_name');
			}
			else if(selecttarget != ""){
				eval('parent.' + selecttarget + '.location.href = url');
			}
			else{
				location.href = url;
			}
		}
        });							
});
