/**---------------------------------
 * common.js
 ---------------------------------*/

//
//スムーズスクロール
//

$(document).ready(function(){

$('.pagetop a[href*=#], .ancLink a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
	var $target = $(this.hash);
	$target = $target.length && $target
	|| $('[name=' + this.hash.slice(1) +']');
	if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body')
			.animate({scrollTop: targetOffset}, 1000, 'easeOutExpo');
		return false;
	}
}
});

});


//
//ロールオーバー
//
(function($){
	$(document).ready(function(){
		$("a img[src*='_ov']").addClass("current");
		
		$("a img[class!='current'],:image").mouseover(function(){
			if ($(this).attr("src").match(/_ot./)){
				$(this).attr("src",$(this).attr("src").replace("_ot.", "_ov."));
				return;
			}
		}).mouseout(function(){
			if ($(this).attr("src").match(/_ov./)){
				$(this).attr("src",$(this).attr("src").replace("_ov.", "_ot."));
				return;
			}
		}).click(function(){
			if ($(this).attr("src").match(/_ov./)){
				$(this).attr("src",$(this).attr("src").replace("_ov.", "_ot."));
				return;
			}
		});
		
		//preload images
		var images = [];
		$("a img,:image").each(function(index){
				if($(this).attr("src").match(/_ot./)){
					 images[index]= new Image();
					 images[index].src = $(this).attr("src").replace("_ov.", "_ot.");
				}
		});
		
	});
})(jQuery);


//高さ調整

function setEqualHeight(columns){
	var tallestcolumn = 0;
	columns.each(
	function(){
		currentHeight = $(this).height();
		if(currentHeight > tallestcolumn){
			tallestcolumn = currentHeight;
		}
	});
	columns.height(tallestcolumn);
 }
$(function(){
	setEqualHeight($(".setBox"));
	setEqualHeight($(".setTxt"));
});


//サイドナビ

$(function(){
	$("div#ctRight ul.sideNav > li").hover(function() {
			$(this).addClass('over');
		}, 
		function() {
			$(this).removeClass('over');
			}
		);

	$("div#ctRight ul.sideNav > li > .icn").hover(function() {
			$(this).find("img").addClass('ov');
		}, 
		function() {
			$(this).find("img").removeClass('ov');
			}
		);
	$("div#ctRight ul.sideNav > li > .icn").click(function(){
			var liNo = $(this).parent().index();
			$(this).parent().toggleClass('act');
			if(liNo == 1 || liNo == 3){
				$(this).parent().find("ul").slideToggle(500);
			}else{
				$(this).parent().find("ul").slideToggle(300);
			}
	});

	$("div#ctRight ul.sideNav ul.productNav > li > .sIcn").hover(function() {
			$(this).parent().addClass('sOv');
		}, 
		function() {
			$(this).parent().removeClass('sOv');
			}
		);
	$("div#ctRight ul.sideNav ul.productNav > li:lt(5) > .sIcn").click(function(){
			$(this).toggleClass('sIcnOv');
			$(this).parent().toggleClass('sAct');
			$(this).parent().find("div.detail").slideToggle(300);
	});
	
	$("div#ctRight ul.sideNav ul.policyNav > li > .sIcn").hover(function() {
			$(this).parent().addClass('sOv');
		}, 
		function() {
			$(this).parent().removeClass('sOv');
			}
		);
	$("div#ctRight ul.sideNav ul.policyNav > li:lt(5) > .sIcn").click(function(){
			$(this).toggleClass('sIcnOv');
			$(this).parent().toggleClass('sAct');
			$(this).parent().find("div.detail").slideToggle(300);
	});
	
});


//サイドナビ ページ設定

$(function(){

	$(".navNews div#ctRight ul.sideNav > li:nth-child(1)").addClass('act');
	$(".navNews div#ctRight ul.sideNav > li:nth-child(1) ul").show();
	$(".navProduct div#ctRight ul.sideNav > li:nth-child(2)").addClass('act');
	$(".navProduct div#ctRight ul.sideNav > li:nth-child(2) ul").show();
		$(".navJoint div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(1)").addClass('sAct');
		$(".navJoint div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(1) .sIcn").addClass('sIcnOv');
		$(".navJoint div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(1) .detail").show();
		$(".navIron div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(2)").addClass('sAct');
		$(".navIron div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(2) .sIcn").addClass('sIcnOv');
		$(".navIron div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(2) .detail").show();
		$(".navSheet div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(3)").addClass('sAct');
		$(".navSheet div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(3) .sIcn").addClass('sIcnOv');
		$(".navSheet div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(3) .detail").show();
		$(".navFilm div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(4)").addClass('sAct');
		$(".navFilm div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(4) .sIcn").addClass('sIcnOv');
		$(".navFilm div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(4) .detail").show();
		$(".navRoof div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(5)").addClass('sAct');
		$(".navRoof div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(5) .sIcn").addClass('sIcnOv');
		$(".navRoof div#ctRight ul.sideNav > li:nth-child(2) ul li:nth-child(5) .detail").show();
	$(".navPolicy div#ctRight ul.sideNav > li:nth-child(3)").addClass('act');
	$(".navPolicy div#ctRight ul.sideNav > li:nth-child(3) ul").show();
	$(".navCompany div#ctRight ul.sideNav > li:nth-child(4)").addClass('act');
	$(".navCompany div#ctRight ul.sideNav > li:nth-child(4) ul").show();
	$(".navRecruit div#ctRight ul.sideNav > li:nth-child(5)").addClass('act');
	$(".navRecruit div#ctRight ul.sideNav > li:nth-child(5) ul").show();

});


//ニュース

$(function(){
	 $("div#ctLeft ul.newsList > li").click(function(){
			 window.location=$(this).find("span a").attr("href");
			 return false;
	});
	 $("div#ctLeft ul.newsList > li > a").click(function(){
			 window.location=$(this).attr("href");
			 return false;
	});
	$("div#ctLeft ul.newsList > li").hover(function() {
			$(this).addClass('over');
			$(this).css("cursor","pointer");
		}, 
		function() {
			$(this).removeClass('over');
			$(this).css("cursor","default");
			}
		);
});


