/* JavaScript Document
	@Description: Over Lightobx javascript.
	@Creation: 10/07/2008.
*/

(function($) {
	$.fn.oLightBox = function (settings) {
		settings = jQuery.extend({
			container : '',
			template: 'template_1',
      		callClose : null								 	
		},settings);
		
    	var $popup = $(this);	   
    
  		function _showOverlay (isShow) {
			if ( isShow ) {
				var w = $('body').width();
				var mh = $('body').height();
				var ih = $(document).height();
				
				if ( mh < ih ) mh = ih;
				$('select, object, embed', settings.container).css({ visibility:'hidden' });
				$('.overlay').css({ width: w + 'px', height: mh +'px' })
				$('.overlay').show();
			} else {
				$('select, object, embed', settings.container).css({ visibility:'visible' });
				$('.overlay').hide();
			}
		};
		
		function _showLightBox () {
			//console.log ($popup.height());
			var tPos = ( $(window).height() - $popup.height() )/2 + $(window).scrollTop();
			var lPos = ( $(window).width() - $popup.width() )/2;
			_showOverlay ( true );
			
			$popup
				.css({ top: tPos + 'px', left: lPos + 'px' });			
			
			$popup.find('.close').click ( function () {
				_closeLightBox ();
			});
		};
		
		//$popupContent[0]._closeLightBox = _closeLightBox;
				
		function _closeLightBox () {
			$popup.css({ top: '0px', left: '-2000px' });
			_showOverlay ( false );
		}
		
		_showLightBox ();
	}
})(jQuery); // Call and execute the function immediately passing the jQuery object


