$(document).ready(function()
{
	$("a.catalog-image").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'      :	'easeOutQuint',
		'easingOut'     :	'easeInQuint',
		'speedIn'		:	600,
		'speedOut'		:	300,
		'overlayShow'	:	false,
		'hideOnContentClick': true,
		'titleShow'		: true,
		'titlePosition'	: 'inside',
		'centerOnScroll':	true
	});

});

function soundalarm()
{
	if (swfobject.hasFlashPlayerVersion('7'))
	{
		$('h1').append('<span id="soundalarm"></span>');
		swfobject.embedSWF('/ui/sound.swf?1', 'soundalarm', '0', '0', '7.0.0', '/res/ui/expressinstall.swf');
	}
}

var catmailtimer;

function catmailcheck_()
{
	$.ajax({
		url: '/?catmailcheck',
		cache: false,
		success: function(html){
			if (html != '')
			{
				if ((typeof catmailtimer != 'undefined'))
					window.clearInterval(catmailtimer);
				soundalarm();
				if (confirm('Новых заказов: ' + html + '.\r\nПерейти к заказам?'))
					redirect('/admin/catalog-ptic/orders/');
			}
		}
	});
}
function catmailcheck()
{
	catmailtimer = window.setInterval(function()
	{
		catmailcheck_();
	}, 600000);
	catmailcheck_();
}

function scroll_process()
{
	var y = $('html').scrollTop();
	if ($('body').scrollTop() > y)
		y = $('body').scrollTop();
	y = y - $('#TScontent0').offset().top;
	if (y < 0)
		y = 0;
	$('.cartblock').stop();
	$('.cartblock').animate({top: y}, 100);
}

$(function()
{
	$('.hint').tooltip({ position: 'bottom left', effect: 'slide', direction: 'down', relative: true});
	$(window).scroll(function() {
		scroll_process();
	});
	scroll_process();
	$('#toplink, #toplink-1, #toplink-2, #toplink-3, #toplink-mail').hover(
		function() {
			$(this).stop().css({opacity: 0}).animate({opacity: 0.7}).css('background', '#ffffff');
		},
		function() {
			$(this).stop().animate({opacity: 0});
		}
	);
});
