/*
	js.core
*/

$(document).ready(function(){

	function newSlider ()
		{
		if ($(".scroll").length)
			{
			// подгрузка плагинов
			$.getScript('/templates/js/jquery/jquery.mousewheel.js', function()
				{
				$.getScript('/templates/js/jquery/jquery.jscrollpane.min.js', function()
					{
					$('.scroll').jScrollPane({
						verticalDragMinHeight: 43,
						verticalDragMaxHeight: 43,
						horizontalDragMinWidth: 43,
						horizontalDragMaxWidth: 43
						});
					$('.scroll').css({'overflow': 'auto'});
					});
				});
			}
		}

	newSlider ();

	// разворачиваем каталожный скроллируемый блок
	if ($(".trademark-content").length)
		{
		// анимация
		$(".trademark-content").animate({'left' : '0px'}, 3000, function (){
//			newSlider ();
			});
		}
/*	else
		{
		newSlider ();
		}
*/
	// обфускация e_mail
	if ( $("span.mailme").length )
	{
	var at = / AT /;
	var dot = / DOT /g;
	$('span.mailme').each(function () {
		var addr = $(this).text().replace(at, '@').replace(dot, '.');
		$(this).after('<a class="mailme" href="mailto:' + addr + '">' + addr + '</a>');
		$(this).remove();
		});
	}

	// меняем поведение анонсника каталога при наведении мыши
	var time = 600;
	function addColor (a, time)
		{
		a.html(''); //чистим для ie7,6
		a.css({'background-position' : 'left top'}); // отключаем базовый css
		a.append('<span class="temp-trade" />');
		$(".temp-trade", a).css({'display': 'none', 'background-image': a.css('background-image')}).fadeIn(time);
		}

	function hideColor (time)
		{
		$(".temp-trade").stop().fadeOut(time, function(){
			$(this).remove();
			});
		}

	$("#trademark").bind('mouseleave', function(){
		if ($(".temp-trade").length)
			hideColor ();
		});

	$("#trademark a").bind('mouseenter', function(){
		a = $(this);
		// если уже есть подсвеченный пункт - гасим его
		if ($(".temp-trade").length)
			{
			hideColor (time);
			}

		addColor (a, time);
	});
});
