


(function ($) {
	
	var methods = {
		init : function( options ) { 
			
			var defaults = {
                bgColor : '#222',
				width : $(window).width(),
				height : $(window).height(),
				position : 'absolute',
				background : this.children('.modalBackground'),
				content : this.children('.modalContent'),
				bgOpacity : 0.9
            }
                 
            var options =  $.extend(defaults, options);
			
			return this.each(function(){
				var opts = options;
				$(this).data('opts',opts);
				//$(this).hide();
				$(this).css('position', opts.position);
				$(this).css('z-index', 99999);
				$(this).modal('resize');
				$(this).css('display', 'none');
				opts.background.css('position', opts.position);
				opts.background.css('opacity',opts.bgOpacity); 
				opts.background.css('filter','alpha(opacity=90)'); 
				opts.content.css('position', opts.position);
				var $this = $(this);
				
				opts.background.click(function(){
					$('#videoModal').modal('hide');
					return false;
				});
				
				$('#videoModalCloseBtn').click(function(){
					$('#videoModal').modal('hide');
					return false;
				});
				
				$('#videoModalLink').click(function(){
					$('#videoModal').modal('show');
					$('#videoModal').modal('resize');
					return false;
				});
			});
		},
	
		//-----------------------------------------------------------------------
		
		show : function() {
			var opts = this.data('opts');
			this.css('display', 'block');
			/*this.fadeIn('fast', function() {
				// Animation complete
			});*/
		},
	
		//-----------------------------------------------------------------------
		
		hide : function() { 
			var opts = this.data('opts');
			this.css('display', 'none');
			/*this.fadeOut('fast', function() {
				// Animation complete
				alert("hide");
			});*/
		},
	
		//-----------------------------------------------------------------------
		
		resize : function() { 
			var opts = this.data('opts');
			
			opts.background.css('width', $(window).width());
			opts.background.css('height', $(window).height());
			opts.background.css('background-color', opts.bgColor);
			
			var leftPos = ($(window).width() / 2) - (this.children('.modalContent').innerWidth() / 2);
			var topPos = ($(window).height() / 2) - (this.children('.modalContent').innerHeight() / 2);
			
			opts.content.css('left', leftPos).css('top', topPos);
		}
	};
	
	//-----------------------------------------------------------------------
	
	$.fn.extend({
		modal: function(method) {
			// Method calling logic
			if ( methods[method] ) {
				return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
			} else if ( typeof method === 'object' || ! method ) {
				return methods.init.apply( this, arguments );
			} else {
				$.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
			}
		}
	});
	


	// Initiallise all '.ContentSlider' elements
	
})(jQuery);
	



/********************************************************************************/
/* Events
/********************************************************************************/

(function ($) {
	
	$(window).resize(function() {
		$('#videoModal').modal('resize');
	});
	
	//-----------------------------------------------------------------------
	
	$(document).scroll(function() {
		$('#videoModal').modal('resize');
	});
	
	//-----------------------------------------------------
	
	$(document).ready(function() {
		$('#videoModal').modal();
	});
		
})(jQuery);






