﻿var popupsuiteStatus = 0;

function loadpopupsuite(){
	if(popupsuiteStatus==0){
		$("#backgroundpopupsuite").css({
			"opacity": "0.7"
		});
		$("#backgroundpopupsuite").fadeIn("slow");
		$("#popupsuiteCart").fadeIn("slow");
		popupsuiteStatus = 1;
	}
}

function disablepopupsuite(){
	if(popupsuiteStatus==1){
		$("#backgroundpopupsuite").fadeOut("slow");
		$("#popupsuiteCart").fadeOut("slow");
		popupsuiteStatus = 0;
	}
}

function centerpopupsuite(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupsuiteHeight = $("#popupsuiteCart").height();
	var popupsuiteWidth = $("#popupsuiteCart").width();
	$("#popupsuiteCart").css({
		"position": "absolute",
		"top": windowHeight/2-popupsuiteHeight/2,
		"left": windowWidth/2-popupsuiteWidth/2
	});
	
	$("#backgroundpopupsuite").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){
	
	$("#buttonsuite").click(function(){
		centerpopupsuite();
		loadpopupsuite();
	});
				
	$("#popupsuiteCartClose").click(function(){
		disablepopupsuite();
	});
	$("#backgroundpopupsuite").click(function(){
		disablepopupsuite();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupsuiteStatus==1){
			disablepopupsuite();
		}
	});

});
