function activateCustomBox(Obj){	
	$('body').append('<div id="CustomBoxOverlay" class="hidden"></div>');
	$('body').append('<div id="CustomBoxPopup"><div id="CustomBoxContentPlace" class="loading"></div></div>');
	
	var windowObj		= $(window);
	var windowWidth 	= str2int(windowObj.width());
	var windowHeight 	= str2int(windowObj.height());
	
	var popupHeight		= getCompleteHeight($('#CustomBoxPopup'));
	var popupWidth		= getCompleteWidth($('#CustomBoxPopup'));
	
	var popupLeft		= str2int((windowWidth-popupWidth)/2);
	var popupTop		= str2int((windowHeight-popupHeight)/2);

	$('#CustomBoxOverlay').css({ 'opacity': 0, 'width': '100%', 'height': '100%'});
	$('#CustomBoxPopup').css({'opacity': 0, 'left': popupLeft+'px'});
	
	
	$('#CustomBoxOverlay').show();
	$('#CustomBoxOverlay').animate({ 'opacity': 0.8}, 500, 'linear', function(){
		$('#CustomBoxOverlay').click(function(){
			removeCustomBox();
		});
	});
	
	
	SetCustomBoxControlls(Obj);
		
	$('#CustomBoxPopup').animate({'opacity': 1}, 500, 'linear', function(){
		setTimeout(function(){														  
			SetCustomBoxContent(Obj);
		},200);
	});
}

function removeCustomBox(){
	$('#CustomBoxPopup').animate({ 'opacity': 0}, 200, 'linear', function(){
		$('#CustomBoxPopup').remove();	
	});
	$('#CustomBoxOverlay').animate({ 'opacity': 0}, 200, 'linear', function(){
		$('#CustomBoxOverlay').remove();	
	});

}


function SetCustomBoxControlls(Obj){
	$('#CustomBoxPopup').append('<div class="controls"></div>');
	$('#CustomBoxPopup .controls').append('<a href="#" class="close">X sluiten</a>');
	$('#CustomBoxPopup .controls .close').click(function(){
		removeCustomBox();
		return false;
	});
}

function SetCustomBoxContent(Obj){
	$.ajax({
		url: Obj.attr('href'),
		cache: false,
		success: function(result){
			var parentObj 	= $('#CustomBoxContentPlace');
			
			parentObj.append(result);
			
			var childObj		= parentObj.children('*:first');
			var childHeight		= getCompleteHeight(childObj);
			var childWidth		= getCompleteWidth(childObj);
			var parentWidth		= getCompleteWidth(parentObj);
			var pOffset 		= parentObj.offset();

			$('#CustomBoxPopup').animate({'left' : str2int(pOffset.left-((childWidth-parentWidth)/2)) +'px', 'width': childWidth+'px', 'height': childHeight+'px'}, 200, 'linear',
			function(){
				childObj.removeClass('hidden');
				parentObj.removeClass('loading');
			});
		}
	});
}
