﻿// JavaScript Document

//▼▼　ロールオーバー　▼▼

//$(function(){
//    $("img.rollover").mouseover(function(){
//        $(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
//    }).mouseout(function(){
//        $(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
//    })
//})

//▼▼　ロールオーバー透過PNG対応　▼▼

$(function(){
    $("img.rollover").each(function(){
        $("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
    });
    if($.browser.msie && $.browser.version<7){
		$("img.alpha").each(function(){
            $(this)
                .data("src",$(this).attr("src"))
                .attr("src","transparent.gif")
                .css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')")
        });
        $("img.rollover:not([src*='_on.'])").each(function(){
            $(this)
                .data("src",$(this).attr("src"))
                .attr("src","transparent.gif")
                .css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')")
            
        }).mouseover(function(){
            $(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2")+"',sizingMethod='scale')")
        }).mouseout(function(){
            $(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')")
        })
    }else{
        $("img.rollover:not([src*='_on.'])").mouseover(function(){
            $(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
        }).mouseout(function(){
            $(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
        });
    }
});

//▼▼　カルーセルパネル　▼▼
$(function(){
    //初期設定
    $("#carouselInner").css("height",522*$("#carouselInner ul.column").size()+"px");
    $("#carouselInner ul.column:last").prependTo("#carouselInner");
    $("#carouselInner").css("margin-top","-522px");
    //戻るボタン
    $("#next").click(function(){
        $("#next,#prev").hide();
        $("#carouselInner").animate({
            marginTop : parseInt($("#carouselInner").css("margin-top"))+522+"px"
        },1500,"swing" , 
        function(){
            $("#carouselInner").css("margin-top","-522px")
            $("#carouselInner ul.column:last").prependTo("#carouselInner");
            $("#next,#prev").show();
        });
    });
    //進むボタン
    $("#prev").click(function(){
        $("#next,#prev").hide();
        $("#carouselInner").animate({
            marginTop : parseInt($("#carouselInner").css("margin-top"))-522+"px"
        },1500,"swing" , 
        function(){
            $("#carouselInner").css("margin-top","-522px")
            $("#carouselInner ul.column:first").appendTo("#carouselInner");
            $("#next,#prev").show();
        });
    });
    //タイマー
	var timerID = setInterval(function(){
		$("#next").click();
	},10000);
	$("#next img,#prev img").click(function(){
			clearInterval(timerID);
	});

});


//▼▼　IE7以下で不必要なツールチップを非表示　▼▼
$(function(){
	if($.browser.msie && $.browser.version<8){
		$("img:not('nav img')").attr("title","");
	}
});

//▼▼　"別ウィンドウで開きます"ツールチップを自動表示　▼▼
$(function(){
	$("a[target='_blank']:not('#side a,footer a')").attr("title","別ウィンドウで開きます").addClass("blankwindow");
});

//▼▼　最後にlastクラスを追加　▼▼
$(function(){
	$("li:last-child").addClass("last");
	$("table tr:last-child").addClass("last");
});

//▼▼　クリックでリストを表示　▼▼
$(function(){
	$(".openclose ul").css("display","none");
//	$(".openclose > img").css("cursor","pointer");
//	$(".openclose > img").click(function(){
//			$("+ul",this).slideToggle("0");
//			return false;
//	});
});

//▼▼　ストライプテーブル　▼▼
$(function(){
	$(".stripe tr:nth-child(odd)").addClass("odd");
	$(".stripe td:first-child").addClass("ami");
	$(".stripe td:last-child").addClass("last");
});

//▼▼　ストライプリンク　▼▼
$(function(){
	$(".stripe li:nth-child(even)").addClass("even");
});

//▼▼　テーブルのサマリーでクラスを追加　▼▼
$(function(){
	$("table[summary*='photoStyleA']").addClass("photoStyleA");
	$("table[summary*='photoStyleB']").addClass("photoStyleB");
	$("table[summary*='right']").addClass("float_right");
	$("table[summary*='left']").addClass("float_left");
	$("table[summary*='center']").addClass("center");
	$(".photoStyleA").each(function(){
		$(this).css("width",$("img",this).width());
	});
	$(".photoStyleB").each(function(){
		$(this).css("width",$("img",this).width());
	});
});

//▼▼　テーブルのサマリーでクラスを追加　▼▼
//$(function(){
//	$("table[summary*='photoStyleA']").wrap("<div class='photoStyleA'></div>");
//	$("table[summary*='photoStyleB']").wrap("<div class='photoStyleB'></div>");
//	$(".photoStyleB").each(function(){
//		$(this).css("width",$("img",this).width());
//	});
//	$("table[summary*='right']").closest("div").addClass("float_right");
//	$("table[summary*='left']").closest("div").addClass("float_left");
//});

//▼▼　FireFoxのバグ回避　▼▼
function resetRollover() {
	var images = $('img.rollover');
	for(var i = 0; i < images.length; i++){
		if(images[i].getAttribute("src").match("_on.")) {
			images[i].setAttribute("src", images[i].getAttribute("src").replace("_on.", "."));
		}
	}
}
