$(document).ready(function() {
	
	var sliderPlayed = false;

	$('#companies-slider .arr-right').click(function(){ 
		if (!sliderPlayed) {
			sliderPlayed = true
			$('#companies-slider .slider-panel').animate({'left':'-197px'}, function(){ 
				$('#companies-slider td:lt(2)').appendTo($('#companies-slider table tr'));
				sliderPlayed = false;
				$(this).css({'left':'0'});
			});
		}
	});
	
	$('#companies-slider .arr-left').click(function(){ 
		if (!sliderPlayed) {
			sliderPlayed = true
			$('#companies-slider td').slice(-2).prependTo($('#companies-slider table tr'));
			$('#companies-slider .slider-panel').css({'left':'-197px'}).animate({'left':'0'}, function(){ sliderPlayed = false });
		}
	});
	
	
	if ($('#altMenu td.active').length>0) {
		$('#altMenu td.active').next().addClass('pre').prev().prev().addClass('pre').next().addClass('default');
	}
	
	
	$('.slide-text-item .slide-text').hide();
	$('.slide-text-item').each(function(){ 
		$('.slide-header span', $(this)).toggle(function(){ 
			$(this).parent().next().slideDown();
		}, function(){ 
			$(this).parent().next().slideUp();
		});
	});	
	
	
	$('.img-gallery').imgGallery();
	
	$('.main-left-side.tp').css({'marginBottom': $('.main-left-side.tp .bottom-block').height()+30});
	
	$('.inner-news .body div').css({'fontFamily':'Georgia, sans', 'fontSize':'1.1em', 'lineHeight':'1.5'});
});

jQuery.fn.imgGallery = function(options){
	var options = jQuery.extend({
		defaultOpt: 'defaultVal'
	},options);

	return this.each(function() {
		var $this = $(this);
		$('.img-arr-r', $(this)).click(function(){ 
			$('.img-panel:not(:animated)', $this).animate({'left': '-204px'}, function(){ 
				$('.img-panel .img-size', $this).first().appendTo($('.img-panel', $this)).parent().css({'left':'0'});
			});
		});
		
		$('.img-arr-l', $(this)).click(function(){ 
			$('.img-panel:not(:animated) .img-size', $this).last().prependTo($('.img-panel', $this)).parent().css({'left':'-204px'}).animate({'left':'0'})
		});
	});
};
