// optional
$(document).ready(function() {
	$(".text-content table").each(function(){
		if(!$(this).hasClass('no-format')) {
			var ths = $("th",this).length;
			var thWidth = 100/ths + "%";
			$("th",this).css("width",thWidth);
			$(this).css("table-layout","fixed");
		// $("td",this).filter(function() {
		//   return this.innerHTML.replace('&nbsp;','').match(/^[0-9\s\.,]+$/);
		// }).css('text-align','center');
		}
	});
});
function mycarousel_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
 
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});
 
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};
$(document).ready(function() {
	$('.grey-rounded div.equal-height').equalCols();
	if($('#carousel').length>0) {
		$('#carousel').jcarousel({
			// auto: 2,
			// wrap: 'last',
			// initCallback: mycarousel_initCallback
			});
	}
	// zebra
	$(".zebra li:odd,.zebra-2-cols-list li:nth-child(4n),.zebra-2-cols-list li:nth-child(4n+3),tr:odd").addClass("odd");
	$(".zebra-2-cols-list li:first").removeClass();
	
	// newx boxes
	$(".news-box h3").click(function () {
		$(this).next(".news-text").toggle();
		$(this).parent(".news-box").toggleClass("news-box-active");
		$(this).parent(".news-box").nextAll(".news-box").removeClass("news-box-active");
		$(this).parent(".news-box").prevAll(".news-box").removeClass("news-box-active");
		$(this).parent(".news-box").nextAll(".news-box").children(".news-text").hide();
		$(this).parent(".news-box").prevAll(".news-box").children(".news-text").hide();
		return false;
	});
	var logo = $('#header h1');
	var speed = 2.5;
	var min = 120;
	$(window).scroll(function(){
		var top = $(this).scrollTop();
		logo.css('top', Math.max(-min, -top/speed));
	});
	$("#f-call input[name=tel]").mask("+7 (999) 999-9999");
	$('#f-call #send').click(function(){
		data = $('#f-call').serialize();
		data.url = window.location.href;
		$.post(url_base + 'actions/contact/callrequest',data,function(r){
			if(r.status) {
				$('#f-call ul').remove();
				$('#f-call').append(r.html)
				} else {
				$('#f-call li.rem').remove();
				$('#f-call ul').prepend(r.html);
				$("#f-call input[name=tel]").mask("+7 (999) 999-9999");
			}
		},'json');
	return false;
	});

$('a.a-gallery').fancybox();
	});

