/*

MARKUP


*/

(function( $ ){
	$.fn.pandaAlert = function( options ) {  
		var settings = {
			message:''
		};

		return this.each(function() {        
			if ( options ) { 
				$.extend( settings, options );
			}
			
			var $this = $(this);
			//alert(settings.message);
			var formattedMessage = '';
			$.each(settings.message, function(index, value){
				formattedMessage += value+'<br />';
			});
			
			$('html').css('height', '100%');
			$('body').css({'position': 'relative', 'width': '100%', 'min-height': '100%', 'display': 'block'});
			
			var windowHeight = $(window).height();
			var windowWidth = $(window).width();
			var docHeight = $(document).height();
			var docWidth = $(document).width();
			var scrollTop = $(window).scrollTop();
			
			$('body').append('<div class="panda-alert-overflow"><div class="panda-alert-bg"></div><div class="panda-alert-wrapper"><div class="panda-alert-container"><div class="panda-alert-text-wrapper"><p class="panda-alert-text">'+formattedMessage+'</p></div><div class="panda-alert-action-wrapper"><div class="panda-alert-action"><span class="panda-alert-ok-wrapper"><span class="panda-alert-ok">OK</span></span></div></div></div></div></div>');
			var $bg = $('.panda-alert-bg');
			var $overflow = $('.panda-alert-overflow');
			var $alertWrapper = $('.panda-alert-wrapper');
			var alertHeight = $('.panda-alert-container', $alertWrapper).height();
			var $ok = $('.panda-alert-ok');
			
//			$overflow.css({'height': docHeight, 'width':docWidth});
//			
			$alertWrapper.css('top', ((windowHeight/2) - (alertHeight/2)) + scrollTop);
//			
//			$(window).resize(function(){
//				docHeight = $(document).height();
//				docWidth = $(document).width();
//				scrollTop = $(window).scrollTop();
//				windowWidth = $(window).width();
//				windowHeight = $(window).height();
//				
//				$overflow.css({'height': windowHeight - scrollTop, 'width':windowWidth});
//				
//				$alertWrapper.css('top', ((windowHeight/2) - (alertHeight/2)) + scrollTop);
//			});
			
//			$(window).scroll(function(){
//				docHeight = $(document).height();
//				docWidth = $(document).width();
//				windowHeight = $(window).height();
//				scrollTop = $(window).scrollTop();
//				
//				$overflow.css({'height': windowHeight - scrollTop, 'width':windowWidth});
//				
//				$alertWrapper.css('top', ((windowHeight/2) - (alertHeight/2)) + scrollTop);
//			});
			
			$ok.click(function(){
				$('div').remove('.panda-alert-overflow');
			})
		});
	};
})( jQuery );
