﻿var popupsuccessStatus = 0;

function loadpopupsuccess(){
	if(popupsuccessStatus==0){
		$("#backgroundpopupsuccess").css({
			"opacity": "0.7"
		});
		$("#backgroundpopupsuccess").fadeIn("slow");
		$("#popupsuccessCart").fadeIn("slow");
		popupsuccessStatus = 1;
	}
}

function disablepopupsuccess(){
	if(popupsuccessStatus==1){
		$("#backgroundpopupsuccess").fadeOut("slow");
		$("#popupsuccessCart").fadeOut("slow");
		popupsuccessStatus = 0;
	}
}

function centerpopupsuccess(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupsuccessHeight = $("#popupsuccessCart").height();
	var popupsuccessWidth = $("#popupsuccessCart").width();
	$("#popupsuccessCart").css({
		"position": "absolute",
		"top": windowHeight/2-popupsuccessHeight/2,
		"left": windowWidth/2-popupsuccessWidth/2
	});
	
	$("#backgroundpopupsuccess").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){
	
	$("#buttonsuccess").click(function(){
		centerpopupsuccess();
		loadpopupsuccess();
	});
	
	$("#buttonsuccess2").click(function(){
		centerpopupsuccess();
		loadpopupsuccess();
	});
				
	$("#popupsuccessCartClose").click(function(){
		disablepopupsuccess();
	});
	$("#backgroundpopupsuccess").click(function(){
		disablepopupsuccess();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupsuccessStatus==1){
			disablepopupsuccess();
		}
	});

});
