//************************
//実行
//************************
$(document).ready(function(){
	pageScroll(".to-top a","#container");
	smartRollover();
	mainav();
});


//************************
//関数
//************************

//スマートロールオーバー
//---------------------------
var smartRollover = function () {  
	if(document.getElementsByTagName) {  
		var images = document.getElementsByTagName("img");  
			for(var i=0; i < images.length; i++) {  
				if(images[i].getAttribute("src").match("_off.")){  
					images[i].onmouseover = function() {  
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));  
				}
				images[i].onmouseout = function(){
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));  
					}
				}
			}
		}  
}

//スマートスクロール
//---------------------------
var pageScroll = function (trg,target){
	$(trg).click(function () {
		$(this).blur();
		$('html,body').animate({ scrollTop: $(target).offset().top }, 'fast');
		return false;
	});
}


var mainav = function(){
	var bodyID = $("body").attr("id");
	var replaceImages = new Array(
		"/common/images/nav/nav0_cr.jpg",
		"/common/images/nav/nav1_cr.jpg",
		"/common/images/nav/nav2_cr.jpg",
		"/common/images/nav/nav3_cr.jpg",
		"/common/images/nav/nav4_cr.jpg",
		"/common/images/nav/nav5_cr.jpg",
		"/common/images/nav/nav6_cr.jpg");
	
	if(bodyID.indexOf("news") != -1){
		$("#nav img:eq(0)").attr("src",replaceImages[0])
	}
	if(bodyID.indexOf("price") != -1){
		$("#nav img:eq(2)").attr("src",replaceImages[2])
	}
	if(bodyID.indexOf("outline") != -1){
		$("#nav img:eq(1)").attr("src",replaceImages[1])
	}
	if(bodyID.indexOf("cource") != -1){
		$("#nav img:eq(3)").attr("src",replaceImages[3])
	}
	if(bodyID.indexOf("clubhouse") != -1){
		$("#nav img:eq(4)").attr("src",replaceImages[4])
	}
	if(bodyID.indexOf("competition") != -1){
		$("#nav img:eq(5)").attr("src",replaceImages[5])
	}
	if(bodyID.indexOf("access") != -1){
		$("#nav img:eq(6)").attr("src",replaceImages[6])
	}
}