var myWidth;
$(document).ready(function(){
	getResolution();
	$("#popup").css("marginLeft", (myWidth-931)/2);
	$.ajax({
		url: '/popup/popup.php',
		type: 'post',
		success: function(data){
			if(data == 0){
				openPopup();
			}
		}
	});
	
	$("#closePopup").click(function(){
		closePopup();
		return false;	
	});
	
	$("#emedlas").click(function(){
		closePopup();
	});
});

function openPopup(){
	$("#bg").css("display", "block").animate({opacity: 0.7}, 300);	
	setTimeout(function(){
		$("#popup").css("display", "block").animate({opacity: 1},300);	
	}, 200);
}

function closePopup(){
	$("#popup").css("display", "block").animate({opacity: 0},300);		
	setTimeout(function(){
		$("#bg").css("display", "block").animate({opacity: 0}, 300);
	}, 200);
}
function getResolution() {
	if (typeof(window.innerWidth) == 'number') {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
}
