$(function(){
		
		//サブナビ
		$("#subNav ul:first").addClass("sidemenu");
		//就職をお考えの皆さま
		$('#shushoku #subNav ul.sidemenu').prepend('<li><a href="/recruit/index.html" target="_blank">新卒社員募集</a></li>');
		
		//footer
		$("#footerNavi ul li:last").addClass("last");
		
		//カテゴリートップメニュー一覧
		$("#rightAreain .categoryIn:odd").addClass("f-right");
		$("#rightAreain .categoryIn:even").addClass("f-left");
		var wrapdivset = '<div class="category clearfix"></div>';
		$('#rightAreain div.categoryIn').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(1)').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(3)').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(5)').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(7)').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(9)').slice(0,2).wrapAll(wrapdivset);
		$('#rightAreain div.categoryIn:gt(11)').slice(0,2).wrapAll(wrapdivset);
		
		var categorycount = $('#rightAreain .categoryIn').length;
		if(categorycount%2 == 1){
			$('#rightAreain .category:last').removeClass('category').addClass('category1line');
		};
		
		$('#rightAreain .categoryIn').hover(function(){
			$(this).addClass('categoryhover');
			$(this).find('.categoryimg').addClass('categoryhoverimg');
			$(this).find('.categoryttl').addClass('categoryhoverttl');
		},function(){
			$(this).removeClass('categoryhover');
			$(this).find('.categoryimg').removeClass('categoryhoverimg');
			$(this).find('.categoryttl').removeClass('categoryhoverttl');
		});

		//マウスオーバー
		var postfix = '_on';
		$('#header a img,#glovalNavi a img,#rss a img,.topicpath 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.hover(
						function() {
								img.attr('src', src_on);
						},
						function() {
								img.attr('src', src);
				});
		});
//		$('#glovalNavi ul.globalDropNavi').each(function(){
//				var gnavimg = $(this).parent().find('li a img').not('[src*="'+ postfix +'."]');
//				var gnavsrc = $(this).parent().find('li a img').not('[src*="'+ postfix +'."]').attr('src');
//				var gnavsrc_on = gnavsrc.substr(0, gnavsrc.lastIndexOf('.'))
//						+ postfix
//						+ gnavsrc.substring(gnavsrc.lastIndexOf('.'));
//				$('<img>').attr('src', gnavsrc_on);
//				$(this).hover(
//						function(){
//							gnavimg.attr('src', gnavsrc_on);
//						},
//						function(){
//							gnavimg.attr('src', gnavsrc);
//				});
//		});
		
		//iframe 高さ調整
  $('iframe').load(function(){
    if (typeof $(this).attr('height') == 'undefined') {
      $(this).height(this.contentWindow.document.documentElement.scrollHeight+10);
    }
  });
  $('iframe').triggerHandler('load');
				
		//外部リンクアイコン
		$('#rightAreain a[href^="http"]:not(:has(img))').not('#search-results a').attr('target','_blank').after('<img src="/common/icon_win_on.gif" class="linkicon" title="外部リンク" alt="外部リンク" width="11" height="16" />');
		//PDFリンクアイコン
		$('#rightArea a[href$=".pdf"], #rightArea a[href$=".PDF"]').attr('target','_blank').after('<img src="/common/icon_pdf.gif" class="linkicon" alt"" width="19" height="16" />');

		//ページ下部リンク
		$("#rightAreain ul.list-banner").addClass("clearfix");
		$("#rightAreain ul.list-banner li:nth-child(3n)").addClass("spaceR");

		//ニュースリリースタブ
	$("div#newsBox div:not("+$("ul#tab li a.selected").attr("href")+")").hide();
	$("div#irNewsbox div:not("+$("ul#irTab li a.selected").attr("href")+")").hide();
	$("ul#tab li a,ul#irTab li a").click(function(){
		$("ul#tab li a,ul#irTab li a").removeClass("selected");
		$(this).addClass("selected");
		$("div#newsBox div, div#irNewsbox div").hide();
		$($(this).attr("href")).show();
		return false;
	});
	
	//easing scroll
	$("a[href*='#']").not("#newsRelease a, #ir #news a").easingScroll({
		easing: "easeOutCubic",
		duration: 700
	});


   $('#bannerIn').jcarousel({
        auto: 7,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
   
		//form required
		var required = '<strong class="font-red">※</strong>';
		$('#FormArea table th:contains("※")').each(function(){
				$(this).html($(this).html().replace(/※/g, required));
		});
		
		//glovalNavi drop down
		$('ul.globalDropNavi li:first-child').addClass('firstChild');
		$('ul.globalDropNavi li:last-child').addClass('lastChild');
		$('#glovalNavi ul li').each(function(){
			var maxheight = $(this).find('ul.globalDropNavi').height();
			$(this).hover(function(){
					if($(this).find('ul.globalDropNavi').css("display") == "none"){ $(this).find('ul.globalDropNavi').height(0);};
					$(this).find('ul.globalDropNavi').stop(true, false).animate({height: maxheight}, "fast").show();
			}, function(){
				$(this).find('ul.globalDropNavi').stop(true, false).slideUp("slow");
			});
		});


		//   fontsize
		//
	$(function(){
		fontsizeChange();
	});

	function fontsizeChange(){
		
		var changeArea = $("#main, #footer");			//フォントサイズ変更エリア
		var btnArea = $(".textresizer");		//フォントサイズ変更ボタンエリア
		var changeBtn = btnArea.find(".changeBtn");	//フォントサイズ変更ボタン
		var fontSize = [93,105,117];				//フォントサイズ（HTMLと同じ並び順、幾つでもOK、単位は％）
		var ovStr = "_ov";							//ロールオーバー画像ファイル末尾追加文字列（ロールオーバー画像を使用しない場合は値を空にする）
		var activeClass = "active";					//フォントサイズ変更ボタンのアクティブ時のクラス名
		var defaultSize = 0;						//初期フォントサイズ設定（HTMLと同じ並び順で0から数値を設定）
		var cookieExpires = 7;						//クッキー保存期間
		var sizeLen = fontSize.length;
		var useImg = ovStr!="" && changeBtn.is("[src]");
		

		//現在クッキー確認関数
		function nowCookie(){
			return $.cookie("fontsize");
		}

		//画像切替関数
		function imgChange(elm1,elm2,str1,str2){
			elm1.attr("src",elm2.attr("src").replace(new RegExp("^(\.+)"+str1+"(\\.[a-z]+)$"),"$1"+str2+"$2"));
		}

		//マウスアウト関数
		function mouseOut(){
			for(var i=0; i<sizeLen; i++){
				if(nowCookie()!=fontSize[i]){
					imgChange(changeBtn.eq(i),changeBtn.eq(i),ovStr,"");
				}
			}
		}

		//フォントサイズ設定関数
		function sizeChange(){
			changeArea.css({fontSize:nowCookie()+"%"});
		}

		//クッキー設定関数
		var cookieSet = function(index){
			$.cookie("fontsize",fontSize[index],{path:'/',expires:cookieExpires});
		}

		//初期表示
		if(nowCookie()){
			for(var i=0; i<sizeLen; i++){
				if(nowCookie()==fontSize[i]){
					sizeChange();
					var elm = changeBtn.eq(i);
					if(useImg){
						imgChange(elm,elm,"",ovStr);
						imgChange($("<img>"),elm,"",ovStr);
					}
					elm.addClass(activeClass);
					break;
				}
			}
		}
		else {
			cookieSet(defaultSize);
			sizeChange();
			var elm = changeBtn.eq(defaultSize);
			if(useImg){
				imgChange(elm,elm,"",ovStr);
			}
			else {
				elm.addClass(activeClass);
			}
		}

		//ホバーイベント（画像タイプ）
		if(useImg){
			changeBtn.each(function(i){

				var self = $(this);

				self.hover( //ホバーイベント
				function(){
					if(nowCookie()!=fontSize[i]){
					imgChange(self,self,"",ovStr);
					}
				},
				function(){
					mouseOut();
				})

			});

		}

		//クリックイベント
		changeBtn.click(function(){

			var index = changeBtn.index(this);
			var self = $(this);

			cookieSet(index);
			sizeChange();

			if(useImg){
				mouseOut();
			}
			if(!self.hasClass(activeClass)){
				changeBtn.not(this).removeClass(activeClass);
				self.addClass(activeClass);
			}

		});

	}

});


    //carousel banner
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

(function(){
  if(navigator.userAgent.indexOf("MSIE 6.0")==-1) return;
  var min_max_width = function(){
    var w = document.body.clientWidth;
    document.body.style.width = w < 982? "980px" : "auto";
  };

  attachEvent("onload" , min_max_width);
  attachEvent("onresize", min_max_width);
})();


