function initPage()
{
	var _page = document.getElementById("main");
	var _popup_table = document.getElementById("popup-table");
	_height =  _page.offsetHeight;
	_popup_table.style.height = _height  + "px";
}


if (window.addEventListener){
	window.addEventListener("resize", initPage, false);
	window.addEventListener("load", initPage, false);
}
else if (window.attachEvent){
	window.attachEvent("onresize", initPage);
	window.attachEvent("onload", initPage);
}
function hide_gallery(){
$('.popup-table').hide();
$('.big-diplom').hide();
}
function show_gallery(src){
var t=document.documentElement.scrollTop+100;
t=t*1;
if (t==100){t=document.body.scrollTop+100;}
$('.popup-table').show();
$('.big-diplom').css('top',t);
$('.big-diplom').show();
$('.big-diplom > div > img').attr('src','/content/images/popup-wrong-bg.png');
$('.big-diplom > div > img').attr('src',src);
}
		function positionWrong(){
				var scroll=document.documentElement.scrollTop || document.body.scrollTop;
				var windowY = $(window).height();
				var wrongY = $('div.popup-wrong').height();
				var windowX = $(window).width();
				var wrongX = $('div.popup-wrong').width();
				$('div.popup-wrong').css('top',windowY/2+scroll-wrongY/2);
				$('div.popup-wrong').css('left',windowX/2-wrongX/2);

		}
		function positionSubscribe(){
				var scroll=document.documentElement.scrollTop || document.body.scrollTop;
				var windowY = $(window).height();
				var wrongY = $('div#subscribe').height();
				var windowX = $(window).width();
				var wrongX = $('div#subscribe').width();
				$('div#subscribe').css('top',windowY/2+scroll-wrongY/2);
				$('div#subscribe').css('left',windowX/2-wrongX/2);

		}
		function positionOrderShop(){
				var scroll=document.documentElement.scrollTop || document.body.scrollTop;
				var windowY = $(window).height();
				var wrongY = $('div#popupRightShop').height();
				var windowX = $(window).width();
				var wrongX = $('div#popupRightShop').width();
				$('div#popupRightShop').css('top',windowY/2+scroll-wrongY/2);
				$('div#popupRightShop').css('left',windowX/2-wrongX/2);

		}
		function positionReg(){
				var scroll=document.documentElement.scrollTop || document.body.scrollTop;
				var windowY = $(window).height();
				var wrongY = $('div#reg').height();
				var windowX = $(window).width();
				var wrongX = $('div#reg').width();
				$('div#reg').css('top',windowY/2+scroll-wrongY/2);
				$('div#reg').css('left',windowX/2-wrongX/2);

		}
		function positionShop(){
				var scroll=document.documentElement.scrollTop || document.body.scrollTop;
				var windowY = $(window).height();
				var wrongY = $('div#JS_login_box').height();
				var windowX = $(window).width();
				var wrongX = $('div#JS_login_box').width();
				$('div#JS_login_box').css('top',windowY/2+scroll-wrongY/2);
				$('div#JS_login_box').css('left',windowX/2-wrongX/2);

		}		
		$(window).resize(function(){
			    positionWrong(); positionSubscribe();positionOrderShop();positionReg();positionShop();
		});
		$(document).ready(function(){
			$('a.addShopCard').click(function(){
			var countnode = 1;
			var qty = document.getElementById("qty"+$(this).attr('id'));
			if (qty!=null) {countnode = qty.value;}
			URL_addShopCard = $(this).attr('href')+'&countnode='+countnode+'&hide_template_display=1';
				$('#nodivload').load(URL_addShopCard,function(){
	                 positionWrong();$('div.popup-wrong').show();$('div.popup-table').show();
                     $('#end').load('/catalog/shop/add.html'); 
                     $('#cart-box').css('display','block');                    
				});
				return false;
			});
			$('#subscribe-link').click(function(){
				$('div.popup-table').show();
				$('#subscribe').show();
			});
			positionShop(); positionSubscribe(); positionReg();
		})

