$(function() {
	
		// マウスオーバー
		var postfix = '_on';
		$('#header a img, #rss a img, .topicpath a img, #footer .linkdetail img, #footerContact a img, #sosial a img, #productSearch a img, #main a.btnCatalogDL img, #productIntro a img').not('[src*="'+ postfix +'."]').each(function() {
				var img = $(this);
				var src = img.attr('src');
				var src_on = src.substr(0, src.lastIndexOf('.'))
						+ postfix
						+ src.substring(src.lastIndexOf('.'));
				// $('<img>').attr('src', src_on);
				img.preload = new Image();
				$(this.preload).attr('src', src_on);
				  $(this).mouseover(function() {
					  $(this).stop(true,true).attr('src', src_on).fadeTo(0,0.3).fadeTo(600,1);
				  }).mouseout(function() {
					  $(this).stop(true,true).attr('src', src);
				  });
		});
		
		$('#banner a img, #productBotLink a img').mouseover(function() {
				$(this).stop(true,true).fadeTo(600,0.7);
			}).mouseout(function() {
				$(this).stop(true,true).fadeTo(300,1);
			});

		// 外部リンクアイコン
		$('#content a[href^="http"]:not(:has(img))').not('[href^="http://'+location.hostname+'"]').not('.social-bar a').attr('target','_blank').after('<img src="/common/icn_win.gif" class="linkicon" title="外部リンク" alt="外部リンク" width="13" height="10" />');
		
		// PDFリンクアイコン
		$('#content a[href$=".pdf"], #rightArea a[href$=".PDF"]').not('#catalogList a').attr('target','_blank').after('<img src="/common/icn_pdf.gif" class="pdficon" alt="PDFファイル" width="18" height="18" />');


		// ニュースリリースタブ
		$("#home #newsBox div:not("+$("ul#tab li a.selected").attr("href")+")").hide();
		$("ul#tab li a").click(function(){
			$("ul#tab li a").removeClass("selected");
			$(this).addClass("selected");
			$("#home #newsBox div").hide();
			$($(this).attr("href")).show();
			return false;
		});
		$('#newsBox div ul li:last-child').addClass('last');
	
		// Enterでsubmitしない
		$("#mail_form input").keypress(function (e) {
			if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
				return false;
			} else {
				return true;
			}
		});
		
		// 資料請求開閉
		// 初期状態
		if($('#catalogPanel dd.catalogGroup input:checked').length){//checkされたradioボタンが含まれる場合は展開
			$('#catalogPanel dd.catalogGroup:not(:has(:checked))').css('display','none');
			$('#catalogPanel dd.catalogGroup:has(:checked)').prev().addClass('close');
		}else{
			$('#catalogPanel dd.catalogGroup:not(:first)').css('display','none');
			$('#catalogPanel dt:first').addClass('close');
		};
		// クリック時
		$('#catalogPanel dt').click(function(){
			if($('+dd',this).css('display')=='none'){
				$('#catalogPanel dt').removeClass('close');
				$('dd.catalogGroup').slideUp('slow');
				$('+dd',this).slideDown('slow');
				$(this).addClass('close');
			};
		});
	
	
		// 社長ブログ略歴開閉
		$('#blog #profileDetail h4').toggle(function(){
			$(this).addClass('open');
			$('#blog #profileDetail div').fadeIn();
			return false;
		},function(){
			$(this).removeClass('open');
			$('#blog #profileDetail div').fadeOut();
			return false;
		});
		
		// カタログリスト MTでクラス付けれたらなくす
		$('#catalogList .cataloggroup .catalogcolumn:first-child').addClass('first');
		$('#catalogList .cataloggroup .catalogcolumn').find('.catalogbox:even').addClass('f-left');
		$('#catalogList .cataloggroup .catalogcolumn').find('.catalogbox:odd').addClass('f-right');
		
		// 製品名一覧
		$('#products #productItemList .productcolumn:not(:has(".f-right"))').addClass('noRightColumn');
		$('#products #productItemList .productcolumnIn .f-left').hover(function(){
			$(this).closest(".productcolumnIn").addClass('column_on');
		},function(){
			$(this).closest(".productcolumnIn").removeClass('column_on');
		});
		$('#products #productItemList .productcolumn .f-right').hover(function(){
				$(this).closest(".productcolumn").addClass('column_on');
		},function(){
			$(this).closest(".productcolumn").removeClass('column_on');
		});
		
		// easing scroll
		$("a[href*='#']").not("#header a, #newsTop a, #catalogPanel dt").easingScroll({
			easing: "easeOutCubic",
			duration: 700
		});
 
});
