//init popup
function initPopUp(elemId){
	$('.'+elemId).click(function(){
		$('#'+elemId).togglePopup();
		return false;
	});
}

$(document).ready(function(){

//additional properties for jQuery object

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

	//open or close pop-up
	$.fn.togglePopup = function(){

		//detect whether popup is visible or not
		if($('#popup').hasClass('hidden')){	//hidden - then display
			if($.browser.msie){	//when IE - fade immediately
				$('#opaco').height($(document).height()).toggleClass('hidden')
					.click(function(){$(this).togglePopup();});
			} else {	//in all the rest browsers - fade slowly
				$('#opaco').height($(document).height()).toggleClass('hidden').fadeTo('slow', 0.7)
					.click(function(){$(this).togglePopup();});
			};
			$('#popup')
				.html($(this).html())
				.alignCenter()
				.toggleClass('hidden');
		} else {	//visible - then hide
			$('#opaco').toggleClass('hidden').removeAttr('style').unbind('click');
			$('#popup').toggleClass('hidden');
		}
	};
	//\open or close pop-up

//\additional properties for jQuery object

});

