﻿var popupuploadStatus = 0;

function loadpopupupload(){
	if(popupuploadStatus==0){
		$("#backgroundpopupupload").css({
			"opacity": "0.7"
		});
		$("#backgroundpopupupload").fadeIn("slow");
		$("#popupuploadCart").fadeIn("slow");
		popupuploadStatus = 1;
	}
}

function disablepopupupload(){
	if(popupuploadStatus==1){
		$("#backgroundpopupupload").fadeOut("slow");
		$("#popupuploadCart").fadeOut("slow");
		popupuploadStatus = 0;
	}
}

function centerpopupupload(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupuploadHeight = $("#popupuploadCart").height();
	var popupuploadWidth = $("#popupuploadCart").width();
	$("#popupuploadCart").css({
		"position": "absolute",
		"top": windowHeight/2-popupuploadHeight/2,
		"left": windowWidth/2-popupuploadWidth/2
	});
	
	$("#backgroundpopupupload").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){
	
	$("#buttonupload").click(function(){
		centerpopupupload();
		loadpopupupload();
	});
				
	$("#popupuploadCartClose").click(function(){
		disablepopupupload();
	});
	$("#backgroundpopupupload").click(function(){
		disablepopupupload();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupuploadStatus==1){
			disablepopupupload();
		}
	});

});
