$(document).ready(function() {

	$('.gallery').fancybox({
		'padding'		: 0,
		'opacity'		: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'	: 'inside',	// 'outside', 'inside' or 'over'
		'overlayColor'	: '#000',
		'overlayOpacity': 0.70
	});

	$(".gallery img").mouseover(function() {

		var $t = $(this);
		var p = $t.position();
		if($t.next("div").size > 0) return;

		var $div = $("<div></div>")
		.attr('class', 'gallery_border')
		.width($t.width()-4)
		.height($t.height()-4)
		.css({
			border: '2px solid #5e380f',
			position: 'absolute',
			top: p.top + 'px',
			left: p.left + 'px'

		}).mouseout(function(event) {
			$(this).remove();
		});

		$t.after($div)
		$div.fadeTo("slow", 0);

	});


	$.localScroll({
		onAfter: function(e) {
			$(e).addClass('on').fadeTo("fast", 0.1, function() {
				$(this).fadeTo("fast", 1);
			});
		}
	});


	$('.special_text_wrapper.bg').prepend('<span>топ<br />оферта</span>');
	$('.special_text_wrapper.en').prepend('<span>top<br />offer</span>');


	$('.prices_table tr').each(function() {
		$(this).find("th:first").addClass('first');
		$(this).find("td:first").addClass('first');

		$(this).find("th:last").addClass('last');
		$(this).find("td:last").addClass('last');
	});


	$("table").delegate('td','mouseover mouseleave', function(e) {
		if (e.type == 'mouseover') {
			$(this).parent().addClass("row_highlight");
		//$("colgroup").eq($(this).index()).addClass("hover");
		}
		else {
			$(this).parent().removeClass("row_highlight");
		//$("colgroup").eq($(this).index()).removeClass("hover");
		}
	});
});
