function centerThis(element) {
	var windowHeight = $(window).height();
	var windowWidth = $(window).width();
	var elementHeight = $(element).height();
	var elementWidth = $(element).width();

	var elementTop, elementLeft;

	if (windowHeight <= elementHeight) {
		elementTop = $(window).scrollTop();
	} else {
		elementTop = ((windowHeight - elementHeight) / 2) + $(window).scrollTop();
	}

	if (windowWidth <= elementWidth) {
		elementLeft = $(window).scrollLeft();
	} else {
		elementLeft = ((windowWidth - elementWidth) / 2) + $(window).scrollLeft();
	}

	$(element).css({
		'top': elementTop,
		'left': elementLeft
	});
}

function maxThis(element) {
	$(element).css({
		'height': $(window).height(),
		'width': $(window).width(),
		'opacity': 0.5
	});
}



jQuery(document).ready(function(){
		$(window).bind('resize', function()
		{
	  centerThis('#popuptarifs');
	   maxThis('#blackscreen');
		});

       centerThis('#popuptarifs');
	   maxThis('#blackscreen');
			   $('#blackscreen').click(function(){
				  $('#blackscreen').remove();
				  $('#popuptarifs').remove();
												});
			   $('#closeid').click(function(){
				  $('#blackscreen').remove();
				  $('#popuptarifs').remove();
												});
			   
});


jQuery(window).load(
	function(){
		jQuery('#popuptarifs').fadeIn('slow');
	}
);

