// JavaScript Document
jQuery(document).ready(function($){
	if($("#sidebar,#sidebar-categories").length) {
		if($("#sidebar,#sidebar-categories").height() < $("#content").innerHeight()) {
			$("#sidebar,#sidebar-categories").height($("#content").innerHeight());
		}
	}
	
	//
	$("table.table2 tr td:last-child").addClass("last");
	
	//
	$("#sidebar a,#sidebar-categories a").append('<span></span>');
	
	//
	//$(".comment-list li").addClass('row0');
	$(".comment-list ul li:odd, .questions ul li:odd").addClass('row1');
	$(".leaders ul li:last, .home .news ul li:last").addClass('last');
	$(".leaders ul li").each(function(i){
		$(this).prepend('<div class="st' + (i + 1) + '"></div>');
	});
	
	//
	if($(".table2").length) {
		var city = $("#sidebar ul li.active").text();
		$(".table2").each(function(i){
			var address = $("caption", this).text();
			$("tbody tr", this).each(function(j){
				var href = $("td:last a", this).attr("href");
				href += "?city=" + encodeURI(city);
				href += "&address=" + encodeURI(address);
				href += "&time=" + encodeURI($("td:eq(0)", this).text());
				href += "&type=" + encodeURI($("td:eq(1)", this).text());
				href += "&days=" + encodeURI($("td:eq(2)", this).text());
				href += "&begin=" + encodeURI($("td:eq(3)", this).text());
				href += "&category=" + encodeURI($.trim($("td:eq(4)", this).text().replace(/\/.*$/,'')));
				href += "&language=" + encodeURI($.trim($("td:eq(4)", this).text().replace(/^.*\//,'')));
				href += "&back=" + encodeURI(window.location.href);
				$("td:last a", this).attr("href", href);
			});
		});
	}
});
