$(function() {

	$("ul.switchingTab li a").click(function(){ 
		var listNum = 0;
		$("div.tabUnitList").each(
			function(i) {
				var thisID = "#list_"+i;
				if($(thisID).css("display") == "block"){
					$(thisID).css("display","none");
					if(i == 1){
						listNum = 0;
					}else{
						listNum = 1;
					}
				}
			}
		);

		$("ul.switchingTab li a").removeClass("current");
		$(this).addClass("current");
		var tabTarget = $(this).attr("href");
		var tabTargetID = tabTarget;
		$(tabTargetID).css("display","block");

		var tabUnitHeight = document.getElementsByClassName("tabUnitList")[listNum].clientHeight + 60;
		$(".tabUnit").css("height", tabUnitHeight +"px");

		ResizeTab();
		return false;
	});

	$(".hitarea").click(function(){
		if(document.getElementsByClassName("tab_bg_color")[0].clientHeight == 0){
			var Height = document.getElementsByClassName("tab_bg_color")[1].clientHeight +65;
		}else{
			var Height = document.getElementsByClassName("tab_bg_color")[0].clientHeight +85;
		}
		$(".tabUnit").css("height", Height);
	});
});

function ResizeTab() {
	var articleBody = document.getElementsByClassName("articlehome");
	var tabUnitBody = document.getElementsByClassName("tabUnit")[0].clientWidth;
	var width = 930 - tabUnitBody;
	var margin = tabUnitBody - 280;

	articleBody[0].style.cssText = 'width: '+ width + 'px;';
	$(".cnt_section_list .text .info .pic li .iconList").css("margin-right", margin);
	$(".sankaku_left").css("margin-left", 54 + margin*0.5);
    $(".sankaku_right").css("margin-left", 179 + margin*0.5);

	if(tabUnitBody > 280){
		$(".no_m_right").css("margin-right", "25px");
	}else{
		$(".no_m_right").css("margin-right", "0px");
	}

	if(tabUnitBody >= 435){
		$(".cnt_section_list .text").css("width", "199px");
		$(".cnt_section_list .text").css("margin", "0 0 0 0");
		$(".cnt_section_list .text .info .pic li .iconList").css("margin-right", 0);
		$(".cnt_section_list .text .info .pic li .iconList").css("right", 0);
		$(".cnt_section_list .text .info .pic li .iconList").css("position", "relative");
		$(".cnt_section_list .text ul.pic li").css("height", 21);
	}else{
		$(".cnt_section_list .text").css("width", "300px");
		$(".cnt_section_list .text").css("margin", "0 0 0 25px");
		$(".cnt_section_list .text .info .pic li .iconList").css("right", -145);
		$(".cnt_section_list .text .info .pic li .iconList").css("position", "absolute");

	}

	if(193 + document.getElementsByClassName("sort_area")[0].clientWidth > articleBody[0].clientWidth){
		$(".tops p").css("top", "75px");
	}else{
		$(".tops p").css("top", "40px");
	}
  }