//----------------------------------------------------------
// JQuery
//----------------------------------------------------------
// コンフリクトを回避
$j=jQuery.noConflict();

$j(function(){
	//ロールオーバー
	$j("img.swap").mouseover(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
	}).mouseout(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
	}).each(function(){
		$j("<img>").attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"));
	}).click(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/, "$1$2"));
	});
	//アンカーリンクスクロール
	if(location.href.indexOf("file")==0){
		var url = "file://" + location.hostname + location.pathname;
	}else if(location.href.indexOf("https")==0){
		var url = "https://" + location.hostname + location.pathname;
	}else{
		var url = "http://" + location.hostname + location.pathname;
	}
	$j("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') { 
				$j($j.browser.safari ? 'body' : 'html')  
					.animate({scrollTop: 0}, 500, "easeInOutCubic");
				return false;
			}else if(id != "#"){
				$j($j.browser.safari ? 'body' : 'html')  
					.animate({scrollTop: $j(hash).offset().top}, 500, "easeInOutCubic");
				return false;
			}
		}
	});
	//サイドバナー自動スクロール
    var $sidebar   = $j("#outsidearea"),
    $window    = $j(window),
    offset     = $sidebar.offset();
    $window.scroll(function() {
	    var maxOffset = $j("#inbox").height() - $sidebar.height();
		if($window.scrollTop() > maxOffset){
			offsetY = maxOffset;
		}else{
			offsetY = $window.scrollTop();
		}
        $sidebar.stop().animate({
                marginTop: offsetY
            },"slow");
    });
});

// スライドアップ・ダウン
var bSlideUP=false;
var bSlideUP2=false;

function SlideIt(slideId){
	bSlideUP=!bSlideUP;	
	if(bSlideUP){
		$j('#' + slideId).slideUp("fast");
		//$j('#news-edit').slideUp("fast");
	}else{
		//$j('#news-edit').slideDown();
		$j('#' + slideId).slideDown();
		
	}
}
function SlideIt2(slideId){
	bSlideUP2=!bSlideUP2;	
	if(bSlideUP2){
		$j('#' + slideId).slideUp("fast");
	}else{
		$j('#' + slideId).slideDown();
		
	}
}


// ニュースリリースのフィルタリング
function lcmenu_init(){
	$j('.lcmenu a').click(function(){
		initHideNEWS(this.id);
		return false;
	})
}
$j(document).ready(lcmenu_init);

function initHideNEWS(activeID) {
	var hideclass;
	
	$j("a",".lcmenu").each(function(i) {
		$j(this).removeAttr("class");
	})
	$j("#" + activeID).addClass("fix");
	switch(activeID){
		case "lcmenu0":
			hideclass="all";
		break;
		case "lcmenu1":
			hideclass="info";
		break;
		case "lcmenu2":
			hideclass="ir";
		break;
		case "lcmenu3":
			hideclass="event";
		break;
		case "lcmenu4":
			hideclass="recruit";
		break;
		case "lcmenu5":
			hideclass="news";
		break;
		case "lcmenu6":
			hideclass="csr";
		break;
	}
	$j("dt","#news-top").each(function(i) {
		if(hideclass == "all"){
			$j(this).css("display","block");
		}else{
			if(hideclass==($j(this).attr("class"))){
				$j(this).css("display","block");
			}else{
				$j(this).css("display","none");
			}
		}
	})
	$j("dd","#news-top").each(function(i) {
		if(hideclass == "all"){
			$j(this).css("display","block");
		}else{
			if(hideclass==($j(this).attr("class"))){
				$j(this).css("display","block");
			}else{
				$j(this).css("display","none");
			}
		}
	})
}