/*****************************
**     Popup message
******************************/

//close pop-up box
function closePopup() {
   jQuery('#opaco').toggleClass('hidden').removeAttr('style');
   jQuery('#popup').toggleClass('hidden');
   return false;
}

//open pop-up
function showPopup( popup_url ) {
   if ( popup_url == '' || !popup_url ) {
	return false;
   }
   //when IE - fade immediately
   if(jQuery.browser.msie) {
	jQuery('#opaco').height(jQuery(document).height()).width(jQuery(window).width()).toggleClass('hidden');
   } else {
	//in all the rest browsers - fade slowly
	jQuery('#opaco').height(jQuery(document).height()).width(jQuery(window).width()).toggleClass('hidden').fadeTo('slow', 0.7);
   }

   jQuery('#popup')
	.load( popup_url, {}, function(){
		jQuery('#popup').alignCenter().toggleClass('hidden');
	});
//	.alignCenter()
//	.toggleClass('hidden');

//	.html(jQuery('#popup_bug').html())

   return false;
}

jQuery(document).ready(function() {
	//align element in the middle of the screen
	jQuery.fn.alignCenter = function() {
		//get margin left
		var marginLeft = Math.max(40, parseInt(jQuery(window).width()/2 - jQuery(this).width()/2)) + 'px';
		//get margin top
		var marginTop = Math.max(40, parseInt( jQuery(window).height()/2 - jQuery(this).height()/2 + jQuery(window).scrollTop() )) + 'px';
		//return updated element
		return jQuery(this).css({'margin-left':marginLeft, 'margin-top':marginTop});
	};

	function closePopup() {
		$('#opaco').toggleClass('hidden').removeAttr('style');
		$('#popup').toggleClass('hidden');
		return false;
	}


});

