
$(document).ready(function() {
	var modalCookie = 'overlayCookie';
	var cookieOptions = {expires: 0.01, path: '/'};

	$('.find_form').click(function() {
	  $('.vor_field').focus();
	});

	$("#pageflip").hover(function() {
		$(".fold_cover img").stop().css({display: "none"});
		$(".msg_block").stop().css({width: "100px",height: "100px"});
		$(".flipper img").stop().css({display: "block"})
			.animate({
				width: "500px",
				height: "500px"
			}, 500);
		$(".msg_block").stop()
			.animate({
			width: "500px",
			height: "500px"
		}, 500);
	},
	function() {
		$(".flipper img").stop()
			.animate({
				width: "250px",
				height: "250px"
			}, 500);
		$(".msg_block").stop()
			.animate({
				width: "250px",
				height: "250px"
			}, 500);
	});
	startFlip();

	/* Lightbox */

	$("#exitoverlay_sensor").mousemove(function() {
		if(!$.cookie("overlayCookie")) { // если нет куки с именем "overlayCookie"
			$(this).trigger("click"); // подсоединяем событие клика по ссылке
		}
	});

	$("#exitoverlay_sensor").click(function() { // клик по ссылке вызывает lightbox
		$(this).attr("rel","lightbox").colorbox();
		$.cookie(modalCookie, $(this).attr("rel"), cookieOptions);
	});
});

function startFlip() {
	$(".fold_cover img").pulse({
		width: [500,500],
		height: [500,500]
	},
	{
		times: 20,
		easing: "linear"
	});
	$(".msg_block").pulse({
		width: [250,250],
		height: [250,250]
	},
	{
		times: 20,
		easing: "linear"
	});
}

