// JavaScript Document

function smartRollover() {
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."));
}
}
}
}
}

if(window.addEventListener) {
window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
window.attachEvent("onload", smartRollover);
}

$(function(){
$("a.btn_act").click(function(){
var connectCont = $("a.btn_act").index(this);
var showCont = connectCont+1;
$('.motion').css({display:'none'});
$('#motion_area'+(showCont)).slideDown('normal');

$('a.btn_act').removeClass('active');
$(this).addClass('active');
})
})



$(function () {
$('a#top').click(function () {
$(this).blur();

$('html,body').animate({ scrollTop: 0 }, 'slow');

return false;
});
});

$(function(){
$(".btnArea > input").hover(function(){
$(this).removeClass("form_btn");
$(this).addClass("form_btn_on");
},function(){
$(this).removeClass("form_btn_on");
$(this).addClass("form_btn");
})
})

jQuery(document).ready(function(){
    jQuery(".block").hover(
        function(){
            jQuery(".slidemeup").slideDown();
        },
        function(){
        jQuery(".slidemeup").slideUp('fast');
    });
});

function printDoc()
{
flag = confirm("印刷しますか？");
if (!flag) return;
window.print();
}

jQuery(function($){
$.fn.slideInformation=function(elm,leftPostion,linkElm,totalH,i){
var this_h=$(this).height();
var $slide=$(elm,this);
var slide_h=$slide.height();
var post_txt_h=$slide.find("dd").height();
var get_h=(this_h+slide_h)-(post_txt_h)-10;
$slide.css({
position:"absolute",
bottom:-3+"em",//-(post_txt_h)+"px",
left:leftPostion+"px"
});

/*
$slide.find("dt").css({
height:3+"em",
overflow:"hidden"
});

$slide.find("dd").css({
height:3+"em",
overflow:"hidden"
});
*/

$(this).css({
height:get_h+"px",
cursor:"pointer"
}).hover(function(){
$slide.stop(true,false).animate({
bottom:0+"px"
},300,"swing");
},function(){
$slide.stop(true,false).animate({
bottom:-3+"em"//-(post_txt_h)+"px"
},300,"swing");
}).click(function(){
var href=$(linkElm,this).find("a").attr("href");
window.open(href,"_self");
});

};

//高さ取得
function elementHeight(elm){
var $t=elm;
var maxH=new Array();
for(var st=0;st<$t.length;st++){
var h=$t.eq(st).height();
maxH.push(h);
}
var max_h=Math.max.apply(null,maxH);
$t.css({height:max_h+"px"});
}

//画像リサイズ
$.fn.re_size=function(){
var $t=$(this);
var w=$t.width();
var h=$t.height();
var s={
w:195,
h:146
}

if(w<=s.w){
$t.css({marginTop:-(h-s.h)/2+"px"});
}else if(h<=s.h){
$t.css({marginLeft:-(w-s.w)/2+"px"});
}

}

window.onload=function(){

//slideInformation読み込み
$("div.blog_top_box").each(function(i){
$(this).slideInformation("div.slide_info",8,"p.image");
$(this).getNewDay();
$("p.image",this).find("img").re_size();
});
elementHeight($("div.blog_top_box"));

};

//グローバルナビ プルダウン
$("ul#gnavi > li").each(function(){
$(this).find("ul").hide();
if($(this).attr("class")=="toggle"){
$(this).hover(function(){
$(">ul",this).stop(false,true).slideDown(300);
},function(){
$(">ul",this).stop(false,true).slideUp(300);
});
$(">a",this).click(function(){ return false; });
};
});

// 7日前まで「NEW」を表示
$.fn.getNewDay=function(){
var minDay=24*60*60*1000; //1日のミリ秒
var theDay=new Date();
theDay.setTime(theDay.getTime() - minDay*7);
var day={
y:theDay.getFullYear(),
m:theDay.getMonth()+1,
d:theDay.getDate()
};
if(day.m<10){ day.y=day.y*10; };
if(day.d<10){ day.m=day.m*10; };
var pastDay=day.y+""+day.m+""+day.d;

var $date=$("p.date",this);
var postDay=$date.text().replace(/^([\d]+)\.([\d]+)\.([\d]+)/,"$1$2$3");

if((pastDay-postDay)<=0){
$date.append('<span class="new">NEW</span>');
}
};

$("div.news_box").each(function(){
$(this).getNewDay();
});
$("div.news_datil").each(function(){
$(this).getNewDay();
});

// 採用情報 募集要項選択
$("select[name=youkou__i] option").each(function(){
var parm=location.search;
if(parm){
var id=parm.replace(/^\?recid=([\d\D]+)/,"$1");
$("#"+id).attr("selected",true);
}
});

});
