$(function(){
	
	/*--block_table_2 組み換え---*/
	
	function tableResize02(){
		$('.block_table_2 table').each(function(){
			var itemContent2 = '<tbody class="block_table_2_item">';
			var array2 =[];
			var cols2 = $(this).find('thead tr th, thead tr td').size();
			var rows2 = $(this).find('tr').size();
			for(i = 0; i < cols2; i++){
				itemContent2 += '<tr>';
				array2[i] = [];
				for(j = 0; j < rows2; j++){
					array2[i][j] = $(this).find('tr:eq('+j+') > *:eq('+i+')').html();
					if(j == 0){
						itemContent2 += '<th>'+array2[i][j]+'</th>';
					}else{
						itemContent2 += '<td>'+array2[i][j]+'</td>';
					}
				}
				itemContent2 += '</tr>';
			}
			itemContent2 += '</tbody>';
			if(window.innerWidth < 500){
				if(!$(this).children().is('tbody.block_table_2_item')){
					$(this).find('tbody').after(itemContent2);
				}
			}else{
				if($(this).children().is('tbody.block_table_2_item')){
					$(this).find('tbody.block_table_2_item').remove();
				}
			}
		});
	}
	tableResize02();
	$(window).on('resize', tableResize02);
	
	/*--block_table_3 組み換え---*/
	
	function tableResize03(){
		$('.block_table_3 table').each(function(){
			var array3 = [];
			var cols3 = $(this).find('thead tr th, thead tr td').size();
			for(i = 1; i <= cols3; i++){
				array3[i] = ($(this).find('thead tr > *:eq('+i+')').html());
			}
			$(this).find('tbody tr').each(function(){
				for(i = 0; i < cols3; i++){
					if(window.innerWidth < 500){
						if(!$(this).find('td:eq('+i+')').children().is('ul.block_table_3_item')){
							var itemContent3 = $(this).find('td:eq('+i+')').html();
							$(this).find('td:eq('+i+')').replaceWith('<td><ul class="block_table_3_item"><li>'+array3[i+1]+'</li><li>'+itemContent3+'</li></ul></td>');
						}
					}else{
						if($(this).find('td:eq('+i+')').children().is('ul.block_table_3_item')){
							var itemContent3 = $(this).find('td:eq('+i+') ul.block_table_3_item li:eq(1)').html();
							$(this).find('td:eq('+i+')').replaceWith('<td>'+itemContent3+'</td>');
						}
					}
				}
			});
		});
	}
	tableResize03();
	$(window).on('resize', tableResize03);
	
});

$(window).load(function(){
	
	/*--block_table_6,7---*/
	
	function tableResize07(){
		$('.block_table_6 table, .block_table_7 table').each(function(){
			var t7 = 0;
			t7 = $(this).find('tbody tr:eq(0)>*').length;
			if(t7 * 150 >= $(this).parents('.outer').width()){
				$(this).addClass('resp');
				if($(this).parents('.outer').width() > $(this).width()){
					$(this).css({width: '100%'});
				}else{
					$(this).css({width: 'auto'});
				}
			}else{
				$(this).removeClass('resp');
			}
		});
	}
	tableResize07();
	$(window).on('resize', tableResize07);

});