var Lightbox = function(options) {
	
	var that = this;
	
	if (window.lightbox) {
		window.lightbox.hide();
	}
	
	this.options = {
		'header': '',
		'content': '',
		'class_name': '',
		'close_callback': function(){}
	};
	$.extend(this.options, options);
	
	this.scroll_options = {
		showArrows: true
	};
	this.body = $(document.body);
	this.layer_darken = $('<div></div>').addClass('lightbox_darken').hide();
	this.wrapper = $('<div></div>').addClass('lightbox_wrapper').hide();
	this.header = $('<div></div>').addClass('lightbox_header');
	this.content = $('<div></div>').addClass('lightbox_content');
	this.content_inner = $('<div></div>').addClass('lightbox_content_inner');
	this.close = $('<span>Schließen</span>').addClass('lightbox_close');
	this.close.click(function() {
		that.hide();
	});

	this.wrapper.append(this.close);
	this.content.append(this.content_inner);
	this.wrapper.append(this.header).append(this.content);
	this.body.append(this.layer_darken).append(this.wrapper);
	this.is_open = false;

	if (this.options.class_name && $.type(this.options.class_name) === 'string') {
		this.wrapper.addClass(this.options.class_name);
	}

	this.header.html(this.options.header);
	this.setContent(this.options.content);
	this.show();
	window.lightbox = this;
	return this;
};

Lightbox.prototype.setContent = function(content) {
	this.content.empty();
	this.content_inner = $('<div></div>').addClass('lightbox_content_inner');
	this.content_inner.html(content);
	this.content.append(this.content_inner);
};

Lightbox.prototype.show = function(){
	this.layer_darken.height($(document).height());
	this.wrapper.fadeIn();
	this.layer_darken.fadeIn();
	this.is_open = true;
};

Lightbox.prototype.hide = function() {
	window.lightbox = null;
	this.wrapper.hide();
	this.layer_darken.hide();
	this.close.unbind('click');
	this.is_open = false;
	if (this.options.close_callback && $.type(this.options.close_callback) === 'function') {
		this.options.close_callback();
	}
	this.wrapper.empty().detach();
	this.layer_darken.empty().detach();
};
