$(document).ready(function(){

	var int_int = '';
	var int_fun = function(){
		$("#pageflip img , .msg_block").animate({ width: '90px',height: '93px'}, { duration:800, queue:false, complete:function(){
			$("#pageflip img , .msg_block").animate({ width: '70px',height: '72px'}, { duration:800, queue:false });
		}});
	}
	int_int = setInterval(int_fun, 1600);

	$("#pageflip").hover(function() {
			clearInterval(int_int);
			$("#pageflip img , .msg_block").stop().animate({ width: '500px', height: '517px' }, 500);
		} , function() {
			int_int = setInterval(int_fun, 1600);
			$("#pageflip img").stop().animate({ width: '50px', height: '52px' }, 220);
			$(".msg_block").stop().animate({ width: '50px', height: '50px' }, 200);
		}
	);

	var doc_width = $(document).width();
	var doc_height = $(document).height();
	if (doc_width < 1265){
		$('div.rekl_item_w1, div.rekl_item_w2').remove();
	}
	var marg = (doc_width - 950) / 2 - 150;
	$('div.rekl_item_w1').css('left',marg+'px');
	$('div.rekl_item_w2').css('right',marg+'px');

	$(document).scroll(function(){
		var from_top = $(window).scrollTop() + 98;
		$('div.rekl_item_w1, div.rekl_item_w2').animate({top:from_top+'px'}, { duration:500, queue:false });
	});


	$('.rekl_item_scroller').append('<a class="cl" onclick="return removeScroller();">[X]</a>');
	var top_html = $('div.rekl_item_toplayer').html();
	if (top_html != null){
		$.nmData( top_html, {closeOnClick: false} );
		setTimeout(function(){ $('.nyroModalCont').css('height','auto'); }, 1000);

		$('.nyroModalData').find('div').click(function(){
			$('.nyroModalBg').parent().remove();
		});
	}
});

function reklClick(url,id){
	window.open(url,'_blank','');
	$.post('/pl/reklama/click', {id:id});
	return false;
}

function removeScroller(){
	$('.rekl_item_scroller').remove();
	$.post('/pl/reklama/remove-scroller');
}
