/*
	rollover.js
	require jQuery
*/

var $j = jQuery;

// メニューのハイライト
$j(function(){
	var path = location.pathname.split("/")[1];
	if(path.match("index")) {
		path = "";
	}
	$j("dl#globalNav dd ul li a").each(function(){
		var link1 = $j(this).attr("href").split("/");
		var directory1;
		if(link1[0] == "http:" || link1[0] == "https:") {
			directory1 = link1[3];
		}else {
			directory1 = link1[1];
		}
		if(path == directory1) {
			/*$j(this).find("img").attr("src",$j(this).find("img").attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))*/
		}else {
			$j(this).find("img").addClass("rollover");
		}
	});
	
	var shopCat = location.pathname.split("/")[2];
	if($j("div").hasClass("forShop") || $j("div").hasClass("forShopIndex")){
		
		$j("div.shopListNav dl dd ul li a").each(function(){
			var link2 = $j(this).attr("href").split("/");
			var directory2;
			
			if(link2[0] == "http:" || link2[0] == "https:") {
				directory2 = link2[4];
			}else if(link2[0].indexOf("#") != -1) {
				directory2 = link2[0];
			}else {
				directory2 = link2[2];
			}
			if(directory2.indexOf("cat-"+shopCat) != -1 && shopCat != "") {
			}else {
				$j(this).find("img").addClass("rollover");
			}
		});
	}
})

// ロールオーバー
$j(function(){
	// rolloverクラス
	$j("img.rollover").mouseover(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
	}).each(function(){
		$j("<img>").attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	});
})

