$(document).ready(function(){

$(".news li:last").css("marginRight","0");

$(".pravolink").click(function(){
							   $(".pravo").css("display","block").animate({opacity:"1"},1000);							   
							   });

$(".pravo span").click(function(){
							   $(".pravo").animate({opacity:"0"},1000).delay(1000).css("display","none");							   
							   });
							   




var block_id = '#sky';
var top_offset = 100;
var tid = null;

function getCookie(name) {
	var matches = document.cookie.match(new RegExp(
	  "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
	))
	return matches ? decodeURIComponent(matches[1]) : false; 
}
function setCookie(name, value, props) {
	props = props || {}
	var exp = props.expires
	if (typeof exp == "number" && exp) {
		var d = new Date()
		d.setTime(d.getTime() + exp*1000)
		exp = props.expires = d
	}
	if(exp && exp.toUTCString) { props.expires = exp.toUTCString() }

	value = encodeURIComponent(value)
	var updatedCookie = name + "=" + value
	for(var propName in props){
		updatedCookie += "; " + propName
		var propValue = props[propName]
		if(propValue !== true){ updatedCookie += "=" + propValue }
	}
	document.cookie = updatedCookie

}

function blockPop() {
	$(".black").delay(2000).fadeOut("1000");
	$("#sky").animate({marginTop:"-100000", top:"-1000"}, 2000);
	$(window).unbind("scroll");
	var exp = new Date();
	exp.setTime(exp.getTime() + (1000 * 86400 * 30));
	setCookie('pop', '1', {expires: exp, path: '/'});
}
document.onkeypress = func;
function func(event) {
	if (window.event) event = window.event;
	var key = event.keyCode ? event.keyCode : event.which ? event.which : null;
	if( (event.ctrlKey) && ( (key == 0xA) || (key == 0xD) ) ) {
		var exp = new Date();
		exp.setTime(exp.getTime() + (1000 * 86400 * 30));
		setCookie('pop', '', {expires: exp, path: '/'});
		showPop();
	}
}
function showPop() {
	var pop = getCookie('pop');
	if (pop) return;
	setTimeout(function() {
		var win_scrl = $(document).scrollTop();
		var top = parseInt(top_offset + win_scrl);
		$(block_id).delay(1000).animate({marginTop:"0"}, 2000)
		$(".black").fadeIn("2000");
		$(".closesky").click(function(){
			blockPop();
			$(window).scroll(function() {
				win_scrl = $(document).scrollTop();
				top = parseInt(top_offset + win_scrl);
				$(block_id).css('top', top + 'px');
			});
		});
	}, 1000);
}
$(document).ready(function() {
	showPop();
});
});

