// JavaScript Document
setRollOverGlobal=function(){};

$(function() {
	
	//************************************************テストサイト用絶対パス補助//本サーバーアップ時には削除
	var topURL="/";
	var u = $(location).attr('href');
	var homeD = "/shstest/";
	topURL = String(u.slice(0,u.indexOf(homeD)))+homeD
	
	$("a").each(function(i){
		if($(this).attr('href').slice(0,1)=="/"){
			$(this).attr('href', $(this).attr('href').replace("/", topURL));
		}
	});
	$("img").each(function(i){
		if($(this).attr('src').slice(0,1)=="/"){
			$(this).attr('src', $(this).attr('src').replace("/", topURL));
		}
	});
	//************************************************テストサイト用絶対パス補助ここまで
	
	
	//************************************************ナビ_ページ毎_on画像変換
	var urlHref = $(location).attr('href');
	
	/////////ディレクトリを登録（トップページは仮）
	var urlName = ["/top___/","/toyano/","/nagaoka/","/philosophy/","/recommend/","/30th/"];
	
	for(var ui=1;ui<urlName.length;ui++){
		if(urlHref.indexOf(urlName[ui])!=-1){$("#header a img").eq(ui).attr('src',$("#header a img").eq(ui).attr('src').replace("_off", "_on")).unwrap();}
	}
	
	//************************************************ボタン_マウスオーバー・アウト
	var ovTime = 400;
	var ovTime2 = 600;
	var ovEasing = 'easeOutQuart';
	var ouTime = 200;
	var ouTime2 = 300;
	var ouEasing = 'easeInQuart';
	setRollOver("a");
	
	function setRollOver(target){
		$(target).each(function(i){
			if($(".overImg",this).length){
				$(this).parent().css("background-image","url("+$("img",this).attr('src').replace("_off", "_on")+")");
				$(this).mouseover(function(){
					$(".overImg",this).stop().animate({opacity:0},{easing:ovEasing,duration:ovTime2});
				}).mouseout(function(){
					$(".overImg",this).stop().animate({opacity:1},{easing:ouEasing,duration:ouTime2});
				});
			}else if($("img",this).length && $("img",this).attr('src').search("_off")!=-1){
				$(this).mouseover(function(){
					$("img",this).attr('src', $("img",this).attr('src').replace("_off", "_on"));					
				}).mouseout(function(){
					$("img",this).attr('src', $("img",this).attr('src').replace("_on", "_off"));					
				});
			}else if($("img",this).length){
				$(this).mouseover(function(){
					$("img",this).stop().animate({opacity:0.6},{easing:ovEasing,duration:ovTime});
				}).mouseout(function(){
					$("img",this).stop().animate({opacity:1},{easing:ouEasing,duration:ouTime});
				});
			}else{
			}
		});
	}
	setRollOverGlobal=setRollOver;
});

