
// コンフリクトを回避
jQuery.noConflict();

(function($) {

	$(function(){

		//アクティブハイライト処理
		switch($("body").attr("class")){
			case "dokuritsu" :
				var menu = $("#menu1 img");
				break;
			case "products" :
				var menu = $("#menu2 img");
				break;
			case "menzukuri" :
				var menu = $("#menu3 img");
				break;
			case "hikaku" :
				var menu = $("#menu4 img");
				break;
			case "support" :
				var menu = $("#menu5 img");
				break;
		}
		if(menu!=undefined){
			menu.removeClass("over").attr("src",menu.attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
		}

		//ロールオーバー
		$("img.over").mouseover(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
		}).mouseout(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
		}).each(function(){
			$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
		}).click(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
		});

		//アンカーリンク
		if(location.href.indexOf("file")==0){
			var url = "file://" + location.hostname + location.pathname + location.search;
		}else if(location.href.indexOf("https")==0){
			var url = "https://" + location.hostname + location.pathname + location.search;
		}else{
			var url = "http://" + location.hostname + location.pathname + location.search;
		}
		$("a[href*=#],area[href*=#]").click(function() {
			var id = this.href.substring(this.href.indexOf('#'),this.href.length);
			var hrefUrl = this.href.split(id);
			if(String(hrefUrl[0]) == String(url)) {
				var hash = this.hash;
				if(!hash || hash == "#")
					return false;
				if(id == '#inbox') { 
					$($.browser.safari ? 'body' : 'html')  
						.animate({scrollTop: 0}, 500, "easeInOutCubic");
					return false;
				}else if(id != "#"){
					$($.browser.safari ? 'body' : 'html')  
						.animate({scrollTop: $(hash).offset().top}, 500, "easeInOutCubic");
					return false;
				}
			}
		});

	});

})(jQuery);
