var block_id = '#subs';
var top_offset = 81;
var tid = null;
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
function blockPop() {
	$(block_id).slideUp("normal");
	$(window).unbind("scroll");
	setCookie('pop', '1');
}
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) ) ) {
		setCookie('pop', '');
		showPop();
	}
}
function showPop() {
	var pop = getCookie('pop');
	if (pop) return;
	setTimeout(function() {
		//var win_w = $(window).width();
		//var win_h = document.getElementsByTagName('html')[0].clientHeight;
		//var pop_w = $(block_id).width();
		//var pop_h = $(block_id).outerHeight();
		var win_scrl = $(document).scrollTop();
		//var left =  parseInt(win_w / 2 - pop_w / 2);
		var top = parseInt(top_offset + win_scrl);
		$(block_id)./*css('left', left + 'px').*/css('top', top + 'px').slideDown("normal", function() {
			$(block_id + ' #close_bnt').unbind("click").click(function() {
				blockPop();
			});
			$(window).scroll(function() {
				//win_h = document.getElementsByTagName('html')[0].clientHeight;
				win_scrl = $(document).scrollTop();
				top = parseInt(top_offset + win_scrl);
				$(block_id).css('top', top + 'px');
			});
		});
	}, 1000);
}
$(document).ready(function() {
	showPop();
});
