// JavaScript Document

TextResizeDetector.TARGET_ELEMENT_ID = 'wrap'; 
TextResizeDetector.USER_INIT_FUNC = init; 

window.onresize = function (){
	disHeight();
};

$(window).scroll(function(){disHeight();});

function init(){
	var iBase = TextResizeDetector.addEventListener(onFontResize,null); //TextResizeDetector初期化
};

function onFontResize() {disHeight();};

function hyouji(){
	disHeight();
	$("#contents").css("visibility","visible");
};

function disHeight(){
	var window_height = parseInt($(window).height()); //現在のウインドウサイズ
	var contents_height = parseInt($("body").height()); //現在のコンテンツのサイズ
	var side_height = parseInt($("#tec_menu").height() + 120);
	var main_height = parseInt($("#tec_main").height());
	var scrool_height = $(window).scrollTop();
	
	var headparts_height = parseInt(($("#header").height()) + ($("#contents h3").height()) + ($("#contents h4").height()) );
	var pad_height = parseInt(window_height - headparts_height - side_height + scrool_height );
	
	if(pad_height < (main_height - side_height + 145) && pad_height > 60){
		$("#tec_menu").css("margin-top", pad_height + "px");
	};
};

$(function(){
	$("#contents").css("visibility","hidden");

	var window_height = parseInt($(window).height()); //現在のウインドウサイズ
	var contents_height = parseInt($("body").height()); //現在のコンテンツのサイズ
	var side_height = parseInt($("#tec_menu").height() + 120);
	var main_height = parseInt($("#tec_main").height());
	
	var init_window_height = window_height;
	var init_contents_height = contents_height;
	var init_side_height = side_height;
	var init_main_height = main_height;
	   

	$("#tec_menu dd").css("display","none");
	$("dl.open dd").slideDown("nomal",hyouji);
	var open_tgl = ($("dl.open").attr("id")).slice(5);
	$("img#" + open_tgl).attr("src","../images/side_" + open_tgl + "_on.gif");
	$("dl#menu_" + open_tgl).removeClass();
	

	var flg = 1;
	$("#tec_menu dt img").mouseover(function(){
		var btn_id = $(this).attr("id");
		function flgreset(){ flg = 1; };
		if (open_tgl != btn_id && flg == 1){
			flg = 0;
			$("img#" + open_tgl).attr("src","../images/side_" + open_tgl + ".gif");
			$("dl#menu_" + open_tgl + " dd,dl#menu_" + btn_id + " dd").slideToggle("nomal",flgreset);
			$("dl#menu_" + open_tgl + " dt img").attr("sec","../images/side_" + open_tgl + ".gif");
			$("dl#menu_" + btn_id + " dt img").attr("src","../images/side_" + btn_id + "_on.gif");
			open_tgl = btn_id;
		};
		
	});

										
});


