$(function(){
var $ = jQuery;
$.terabox = function(content){
var terabox = this.terabox, s = terabox.s;
!$("#terabox:visible").length && s.overlay.on && $("#terabox-overlay").css("opacity", 0).show().animate({ opacity: s.overlay.opacity }, s.speed * 0.8);
$("#terabox-content").html(content).css("max-height", $(window).height() - 175).parent().css("left", ($(window).width() / 2) - ($("#terabox").outerWidth() / 2)).show();
$().trigger("show.terabox");
$().bind("keydown.terabox", function(e){ e.keyCode === 27 && $.terabox.hide(); });
};
$.fn.terabox = function(){
$.terabox(this.html());
return this;
};
$.terabox.s = { speed: 600, overlay: { opacity: 0.8, on: true } };
$.terabox.hide = function(){ $().trigger("hide.terabox"); };
$(function(){
$("body").append(
'<div id="terabox" style="width: 500px; position: fixed; top: 50px; display: none; z-index: 999; background-color: white; padding: 10px; border: 10px solid #525252;' +
'-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;">' + // epic, epic fail
'<div id="terabox-content" style="overflow: auto;"></div><br>' +
'<div id="terabox-footer" style="text-align: right; border-top: 1px solid #D6D7FF;">' +
'<a href="#" style="font-size: 20px; font-family: Tahoma,Helvetica,Arial,sans-serif; font-weight: bold; color: #7A7A7A; text-decoration: none;' +
'background: none;">CLOSE</a>' +
'</div>' +
'</div>' +
'<div id="terabox-overlay" style="top: 0; left: 0; width: 100%; height: 100%; position: fixed; display: none; z-index: 998; background-color: black"></div>'
);
$().bind("hide.terabox", function(){
$("#terabox").fadeOut($.terabox.s.speed, function(){ $("#terabox-overlay").fadeOut($.terabox.s.speed * 0.8); });
});
$("#terabox-footer a, #terabox-overlay").click(function(){ $.terabox.hide(); return false; });
});
});