$(document).ready(
function(){
	 
	if (screen.width>=1210) {
	$("body").css('width','1262px');
	$(".menu_right").css('left','1020px');
	} else if (screen.width>=1010) { 
	$("body").css('width','1007px');
	$(".menu_right").css('left','764px');
	}
	
	

	//$("strong").parent().addClass('collapse_closed').before("<a style='display:block' class='sh'>(+/-)</a>");
	
/* 	$(".collapse_open").parent().prepend("<a class='sh_open'>(+/-)</a>");
	$(".sh_open").click(function(){
		$(this).next().slideToggle("slow");
	});
	
	$(".collapse_closed").hide();
	$(".collapse_closed").parent().prepend("<a class='sh_closed'>(+/-)</a>");
	$(".sh_closed").click(function(){
		$(this).next().slideToggle("slow");
	}); */
	
	// $(".subSectionAndTours").each(
	// function(index){
	//	$(this).appendTo($(".subSectionAndToursContainer").eq(index/4));
	// }
	// );
	

	$(".sectionLink").click(function(){
		var id = "#i"+$(this).attr("id");
		var selected = $(this).hasClass("selected");
		$(".subSectionAndTours").slideUp("slow",function(){
			clear_children();
			});
		if(!selected){
			$(id).slideDown("slow",function(){
			clear_children();
			});
		}
		
		$(".sectionLink").removeClass("notSelected");
		
		$(this).not(".selected").addClass("notSelected");
		$(".sectionLink").removeClass("selected");
		$(this).filter(".notSelected").addClass("selected");
		
	}
	);
	
	$(".section p").click(function(){
		$(".section p").removeClass("selected");
		$(this).addClass("selected");
		//tb_init('a.thickbox, area.thickbox, input.thickbox');
	});


	$("table.table-header tr:first-child td").each(function() {
		var col = $(this).attr("colspan");
		if (col) {colspan=col;}else{colspan='';}
		//alert(colspan);
		if(colspan){
			$(this).replaceWith("<th colspan=" + colspan + ">" + $(this).html() + "</th>");
		}else{
			$(this).replaceWith("<th>" + $(this).html() + "</th>");
		}

	});
	$("table.table-header tr:first-child th")
	// $("table.table-header tr td:first-child").each(function() {
		// $(this).replaceWith("<th>" + $(this).text() + "</th>");
	// });
	$("table.table-header tr:first-child th").addClass("topHeader");
	//$("table.table-header tr th:first-child").addClass("leftHeader");
	//$("table.table-header th:first").addClass("empty");

	
	/*var htmlStr = $(".maintext").html();
	$(".maintext").html(htmlStr.substring(0,1000)).append("<a class='readon'>Читать далее</a>");
	

	$(".readon").toggle(
	  function(){
	  $(".maintext").html(htmlStr).append("<a class='readon'>Меньше текста</a>");
	  },
	  function(){
      $(".maintext").html(htmlStr.substring(0,1000)).append("<a class='readon'>Читать далее</a>");
	  }
	);
	  */
	  clear_children();
 }
 );


