(function($){
	$.fn.extend({
		modalPanel: function() {
		    
		    //Our function for hiding the modalbox
			function modalHide() {
				$(document).unbind("keydown", handleEscape);
				var remove = function() { $(this).remove(); };
				overlay.fadeOut(remove);
				modalWindow
					.fadeOut(remove)
					.empty();
			}
			$(document).modalHide = modalHide;
			
			//Our function that listens for escape key.
			function handleEscape(e) {
				if (e.keyCode == 27) {
					modalHide();
				}
			}
			
			//Create our overlay object
			var overlay = $("<div id='modal-overlay'></div>");
			//Create our modal window
			
			var modalWindow = $("<div id='modal-window'></div>");
			
	 
			
			return this.each(function() {
				//Listen for clicks on objects passed to the plugin
				$(this).click(function(e) {
					
					if (typeof document.body.style.maxHeight === "undefined") { //if IE 6
						$("body","html").css({height: "100%", width: "100%"});
					}
					
					//Append the overlay to the document body
					$("body").append(overlay.click(function() { modalHide(); }));
					//Add a loader to our page
					$("body").append("<div id='modal-load'></div>");
					
					//Set the css and fade in our overlay
					overlay.css("opacity", 0.8);
					overlay.show();
					
					//Prevent the anchor link from loading
					e.preventDefault();
					
					//Activate a listener 
					$(document).keydown(handleEscape);	
					
						
					$("body").append(modalWindow);
					modalWindow.append("<iframe width='800' height='750' frameborder='0' scrolling='no' allowtransparency='true' src='"+ this.href + "'></iframe>");		
					modalWindow.fadeIn(50);
	
				});
			});
		}
	});
})(jQuery);