function flip() {
	this.$parent = $('.contentWrap');
	this.$a;
	this.$li;
	this.url;
	this.content;
	this.speed = 500;
	this.afterAll = function() {};
}

flip.prototype.init = function(anchor, callback) {
	this.$a = anchor;
	this.$li = this.$a.closest('li');
	this.url = this.$a.attr('href');
	this.afterAll = callback || function() {};
}

flip.prototype.run = function() {
	var that = this;
	this.getContent(function() {
		that.buildHtml();
		that.animate();
	});
}

flip.prototype.getContent = function(callback) {
	var that = this;
	$.ajax({
		url: this.url,
		type: 'get',
		dataType: 'html',
		success: function(r) {
			that.content = r;
			callback();
		},
		error: function(e) {
			this.error('Die URL '+this.url+' verursachte einen Fehler.');
		}
	});
}

flip.prototype.buildHtml = function() {
	inlinestyle = this.getInlinestyle();
	reloaded = $('<div></div>')
		.attr('class', 'clone content')
		.attr('style', inlinestyle)
		.html(this.content)
		.find('.inlinestyle').remove().end()
		//.hide();
	this.$parent.append(reloaded);
	//init the map
	if($('#openstreetmap').length == 1) {
		create_map();
	}
	Cufon.refresh();
}

flip.prototype.animate = function() {
	var that = this;
	var $content = this.$parent.find('#content').animate({top: '-450px'}, this.speed);
	var $clone = this.$parent.find('.clone').animate({top: '0px'}, this.speed);
	window.setTimeout(function() {
		$content.remove();
		$clone
			.removeClass('clone')
			.attr('id', 'content');
		that.afterAll();
	}, this.speed);
}

flip.prototype.getInlinestyle = function() {
	inlinestyle = $($(this.content).get(0)).text();
	return inlinestyle;
}

flip.prototype.error = function(msg) {
	alert('flip error: '+"\n"+msg);
}