function ___getPageSize() {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}

var currentScrollX = 0;
var currentScrollY = 0;
	
if (window.scrollX && window.scrollY) {
	currentScrollX = window.scrollX;
	currentScrollY = window.scrollY;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,currentScrollX,currentScrollY);
return arrayPageSize;
};

function hidewidget () {
	$('#ajax_container').hide();
	$('.widget-overlay').hide();
		$('.widget-overlay').html('<img class="loadergif" id="loadergif" src="/i/loader.gif" />');
		$('#ajax_container').html('');
}

function showsubscribe (linkurl) {
	linkurl = escape(linkurl);
	$('.widget-overlay').show();
	var data = '';
	data += '<div class="invitation_card clearfix"><div class="caption_card clearfix"><p class="sm">Раздел доступен только зарегистрированным пользователям!</p><span><a id="close_link" href="#">Закрыть</a></span>';
	data += '</div><div class="ajax_element_text"><p>Для просмотра этого раздела сайта пожалуйста <a href="/auth.php?register=yes&amp;backurl=' + linkurl + '" style="color:#ff0000;">ЗАРЕГИСТРИРУЙТЕСЬ</a> или <a href="/auth.php?backurl=' + linkurl + '" style="color:#ff0000;">АВТОРИЗУЙТЕСЬ</a>. Это займет у вас не более1 минуты.</p>';
	data += '</div></div>'
			var arrPageSizes = ___getPageSize();
			var body_height = arrPageSizes[3];
			$('.widget-overlay').height(body_height);
			$('#loadergif').hide();
			$('#ajax_container').html(data);
			$('#ajax_container').width(780);
			$('#ajax_container').show();
			var marginleft = (arrPageSizes[0]-$('#ajax_container').width())/2 + 'px';
			if($.browser.msie && $.browser.version.substr(0,3)!="8.0" && $.browser.version.substr(0,3)!="9.0"){
				$('#ajax_container').css('left', marginleft);
			} else {
				$('#ajax_container').css('margin-left', marginleft);
			}
			var margintop = ((body_height-$('#ajax_container').height())/2) + arrPageSizes[5] + 'px';
			$('#ajax_container').css('margin-top', margintop);
			var imgpath = $(".elementbox:visible div.preview a.previewimages:first img").attr("src");
			$("#elementsrc").attr("value", imgpath);
			var eventid = $(".elementbox:visible a.favorite").attr("href");
			$("#elementid").attr("value", eventid);
			setTimeout(hidewidget, 5000);
			$('#close_link').live("click", function() {
				hidewidget();
				return false;
			});
	return false;
}

