// JavaScript Document

var myhash = location.hash;
var myurl = location.href;
var ua = navigator.userAgent;


//__________________ ドキュメントサイズを取得
//________________________________________________

function getWindowHeight() {
	if(ua.match("MSIE")) return document.documentElement.clientHeight || document.body.clientHeight;
	else return window.innerHeight;
}

function getDocumentHeight() {
	if(ua.match("MSIE")) return document.documentElement.scrollTop || document.body.scrollTop;
	else return window.pageYOffset;
}

function getDocumentHeight() {
	return document.documentElement.scrollHeight || document.body.scrollHeight;
}

function getWindowWidth() {
	if(ua.match("MSIE")) return document.documentElement.clientWidth || document.body.clientWidth;
	else return window.innerWidth;
}

function getScrollOffsetX() {
	if(ua.match("MSIE")) return document.documentElement.scrollLeft || document.body.scrollLeft;
	else return window.pageXOffset;
}

// footerの配置


//_____________________________________ setSWF



function setSwf(swf, sn, fv, bgc, boxid, w, h) {
	
	function __construct() {
		var so = new SWFObject(swf, sn, w, h, fv, bgc);
		so.addParam("wmode", "opaque");
		so.addParam("menu", "false");
		so.addParam("scale", "showall");
		so.addParam("salign", "lt");
		so.write(boxid);
	}
	__construct();
	
}



//_____________________________________________________
//                                    HTML書き出し

var lank = ""
var path = ""

function set_header(){
	switch(lank){
		case 1:
			path = "./";
			break;
		case 2:
			path = "../";
			break;
		default:
			break;
	};
	attach_header(path);
	attach_footer(path);
	set_nav_color();
	set_all_rollover();
}



//_____________________________________________________
//                                    ヘッダー書き出し

function set_nav_color(){
	if(myurl.match("/about")){
		$("#g_nav_about").html('<img src="../common/g_nav1.gif" alt="" width="123" height="41" />');		
	}else if(myurl.match("/works")){
		$("#g_nav_works").html('<img src="../common/g_nav2.gif" alt="" width="122" height="41" />');			
	}else if(myurl.match("/human")){
		$("#g_nav_person").html('<img src="../common/g_nav3.gif" alt="" width="122" height="41" />');			
	}else if(myurl.match("/career")){
		$("#g_nav_career").html('<img src="../common/g_nav4.gif" alt="" width="122" height="41" />');	
	}else if(myurl.match("/data")){
		$("#g_nav_data").html('<img src="../common/g_nav5.gif" alt="" width="122" height="41" />');				
	}else if(lank == 1){
		$("#catch_copy").html('<img src="./common/copy2.gif" alt="" width="223" height="49" />');
	}
}


function attach_header(pathsrc){
	var htmlsrc = "";
	htmlsrc +='<div id="header">'
	htmlsrc +='<div id="header_top">'
	htmlsrc +='<div id="btn_entry"><a href="https://mypage.100.i-web.jpn.com/misi2013/entry/entry.php?action_url=regulat" target="_blank"><img src="' + pathsrc +'common/g_nav_entry.gif" alt="entry" width="113" height="87" /></a></div>'
	htmlsrc +='<div id="btn_mypage"><a href="https://mypage.100.i-web.jpn.com/misi2013/" target="_black"><img src="' + pathsrc +'common/g_nav_mypage.gif" alt="mypage" width="113" height="87" /></a></div>'
	htmlsrc +='<table cellpadding="0" cellspacing="0" border="0" id="head_top">'
	htmlsrc +='<tr>'
	htmlsrc +='<td id="logo"><a href="' + pathsrc + 'index.html"><img src="' + pathsrc +'common/logo.gif" alt="MISI" width="110" height="51" /></a></td>'
	htmlsrc +='<td id="catch_copy"><img src="' + pathsrc +'common/copy.gif" alt="" width="376" height="56" /></td>'
	htmlsrc +='</tr>'
	htmlsrc +='</table>'
	htmlsrc +='<ul id="g_nav">'
	htmlsrc +='<li id="g_nav_about"><a href="' + pathsrc +'about/outline.html"><img src="' + pathsrc +'common/g_nav1_off.gif" alt="" width="123" height="41" /></a></li>'
	htmlsrc +='<li id="g_nav_works"><a href="' + pathsrc +'works/whats.html"><img src="' + pathsrc +'common/g_nav2_off.gif" alt="" width="122" height="41" /></a></li>'
	htmlsrc +='<li id="g_nav_person"><a href="' + pathsrc +'human/person.html"><img src="' + pathsrc +'common/g_nav3_off.gif" alt="" width="122" height="41" /></a></li>'
	htmlsrc +='<li id="g_nav_career"><a href="' + pathsrc +'career/manager.html"><img src="' + pathsrc +'common/g_nav4_off.gif" alt="" width="122" height="41" /></a></li>'
	htmlsrc +='<li id="g_nav_data"><a href="' + pathsrc +'data/concept.html"><img src="' + pathsrc +'common/g_nav5_off.gif" alt="" width="122" height="41" /></a></li>'
	htmlsrc +='</ul>'
	htmlsrc +='</div>'
	htmlsrc +='</div>'
	
	$("#header_bg").html(htmlsrc);
}


//_____________________________________________________
//                              トップヘッダーロールオーバー

function attach_top_subnav_base(){
	for(var i=1; i<6; i++){
		attach_top_subnav(i);
	}
}


function attach_top_subnav(e){
		$("#top_btn" + e).hover(function(){
			$("#top_sub" + e).css("display" , "block");	
			$("#top_sub" + e).hover(function(){
				$("#top_sub" + e).css("display" , "block");	
			},
			function(){
				$("#top_sub" + e).css("display" , "none");	
			}
			)
		},
		function(){
			$("#top_sub" + e).css("display" , "none");
		});
}





//_____________________________________________________
//                                    フッター書き出し

function attach_footer(pathsrc){
	var htmlsrc = "";	
	htmlsrc += '<table cellpadding="0" cellspacing="0" border="0" id="footer">'
	htmlsrc += '<tr>'
	htmlsrc += '<td id="copyright"><img src="' + pathsrc +'common/footer_copy.gif" alt="Copyright (C) 2011-2012 Marubeni-Itochu Steel Inc. All rights reserved." width="334" height="26" /></td>'
    htmlsrc += '<td id="f_corporate"><a href="http://www.benichu.com/top.html" target="_blank"><img src="' + pathsrc +'common/footer_btn_corporate_off.gif" alt="coporateHP" width="84" height="26" /></a></td>'
   	htmlsrc += '<td class="f_line"><img src="' + pathsrc +'common/footer_line.gif" alt="" width="23" height="26" /></td>'
	htmlsrc += '<td id="f_sitemap"><a href="' + pathsrc +'sitemap/index.html"><img src="' + pathsrc +'common/footer_btn_sitemap_off.gif" alt="sitemap" width="45" height="26" /></a></td>'
	htmlsrc += '<td class="f_line"><img src="' + pathsrc +'common/footer_line.gif" alt="" width="23" height="26" /></td>'
	htmlsrc += '<td id="f_faq"><a href="' + pathsrc + 'faq/index.html"><img src="' + pathsrc +'common/footer_btn_faq_off.gif" alt="faq" width="18" height="26" /></a></td>'
	htmlsrc += '</tr>'
	htmlsrc += '</table>'
	$("#footer_bg").html(htmlsrc);
}


    	
//_____________________________________________________
//                                    フィールドマップ

var com_top = ""
var com_left = "";
var com_width = ""
var com_heigth = ""
var com_array = new Array();
com_array = [3, 6, 9]

function set_map_base(){
	for(var i=1; i<12; i++){
		map_parts_roll(i);
	}
}

function map_parts_roll(e){
	for(var i=0; i<com_array.length; i++){
		if(e == com_array[i]){
			$("#fi_map" + e).hover(function(){
					set_field(e);
			},
			function(){
				set_field2();		
			});
		}
	}
}


function set_field(e){
	com_top = $("#fi_map" + e).position().top;
	com_left = $("#fi_map" + e).position().left;
	com_width = $("#fi_map" + e).width();
	com_heigth = $("#fi_map" + e).height();
	
	$("#fi_com").css("top" , com_top - com_heigth - 5);
	$("#fi_com").css("left" , com_left + com_width - 10);
	$("#fi_com").css("display" , "block");
}

function set_field2(){
	$("#fi_com").css("display" , "none");	
}




//_____________________________________________________
//                                   トップページスクロール	

function set_top_scroll(aa){
	$("html , body").animate({scrollTop : $(window).scrollTop() + aa} , {duration:0 , easing:"easeOutQuint" , queue:false});
}
        



//_____________________________________________________
//                                   駐在員レポート

function set_resident(){
	for(var i=1; i<12; i++){
		set_resident_base(i);
	}
}

function set_resident_base(e){
	$("#re_map_btn" + e).click(function(){
		if(e == 3 || e == 4 || e == 5 || e == 6 || e == 7 || e == 8 || e == 10 || e == 11){
		$("#re_cont_base").css("height" , $("#re_cont" + e).height() + 30);
		for(var i=1; i<12; i++){
			if(i == e){
				$("#re_cont" + i).css("display" , "block");
			}else{
				$("#re_cont" + i).css("display" , "none");
			}
		}
		}
		set_faq_move($("#re_cont" + e).offset().top - 10)
	});
}



function set_resident_load_event(){
	for(var i=1; i<12; i++){
		set_resident_load_event_base(i);
	}
}

function set_resident_load_event_base(e){
	if(myhash.match("#map" + e)){
		set_resident_load(e);
		set_faq_move($("#re_cont" + e).offset().top - 10)
	}
	set_resident();
}

var resident_flg = false

function set_resident_load(e){
	for(var i=1; i<12; i++){
		$("#re_cont_base").css("height" , $("#re_cont" + e).height() + 30);
		if(i == e){
			$("#re_cont" + i).css("display" , "block");
		}else{
			$("#re_cont" + i).css("display" , "none");
		}
	}
}

function set_set_resident_message(e){
		$("#re_cont_base").css("height" , $("#re_cont" + e).height() + 30);
		for(var i=1; i<12; i++){
			if(i == e){
				$("#re_cont" + i).css("display" , "block");
			}else{
				$("#re_cont" + i).css("display" , "none");
			}
		}
		set_faq_move($("#re_cont" + e +"_message").offset().top - 10)
}




//_____________________________________________________
//                                    座談会トップ

function set_talk_toproll(){
	$("#talk_topbtn1").hover(function(){
		$("#talk_topbtn1").attr("src" , "talk/top_btn1_b.jpg");
	},
	function(){
		$("#talk_topbtn1").attr("src" , "talk/top_btn1_a.jpg");
	});
}

$(document).ready(set_talk_toproll);


//_____________________________________________________
//                                    FAQ動き

function set_faq_move(posi){
	$("html,body").animate({scrollTop : posi} , {duration:500 , easing:"easeOutQuint" , queue:false});
	$("html , body").mousewheel(function(event, delta){
									   $("html , body").stop();
									   });
}



//_____________________________________________________
//                                    全体ロールオーバー

function set_all_rollover(){
    $("img[src*='_on']").addClass("current");
  
    $("img,input[type='image']").hover(function(){
        if ($(this).attr("src")){
            $(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
        }
    },function(){
        if ($(this).attr("src") && !$(this).hasClass("current") ){
            $(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
        }
    });
};

$(document).ready(set_all_rollover);




                    
                    
                
            
        





































