var plg_timeline = {
	selectors: {
		hideButton: '.jQ_timeline .jQ_hide',
		showButton: '.jQ_timeline .jQ_show',
		toggleButton: '.jQ_timeline .jQ_toggle',
		swf: '.jQ_timeline .jQ_timelineSwf',
		img: '.jQ_timeline .jQ_timelineImg',
		rightContainer: ".column_right",
		wideContainer: ".column_wide_main"
	},
	init: function(){
		var self = this;
		$(this.selectors.hideButton).click(function(){
			self.hide();
			return false;
		});
		$(this.selectors.showButton).click(function(){
			self.show();
			return false;
		});
		$(this.selectors.toggleButton).click(function(){

			if( $(self.selectors.swf).is(':visible') ){
				self.hide();
			} else {
				self.show();
			}

			return false;
		});
	},
	hide: function(){
		var self = this;
		$(this.selectors.swf).hide();
		$(this.selectors.hideButton).hide();
		$(this.selectors.img).show();

		$(".jQ_timeline").addClass('fr').animate({
			width: '300px',height: '100%'
		}, function(){
			var $holder = $('<div class="jQ_timelineRightHolder"/>');
			$(self.selectors.rightContainer).prepend($holder);
			$holder.get(0).appendChild(this);
			$(this).removeClass('fr');
			$('.jQ_timelineWideHolder').remove();
		});
	},
	show: function(){
		var self = this;

		$(this.selectors.img).hide();
		var $mainHolder = $("<div class='jQ_timelineWideHolder'/>");
		$(".jQ_timeline").addClass('fr');
		$(this.selectors.wideContainer).prepend($mainHolder);
		$mainHolder.get(0).appendChild($(".jQ_timeline").get(0));
		$(".jQ_timeline").animate({
				width: '995px'
			}, function(){
				$(this).removeClass('fr');
				$(self.selectors.swf).show();
				$(self.selectors.hideButton).show();
				$(".jQ_timelineRightHolder").remove();
			});

	}
};

$(document).ready(function(){
	$('.jQ_hide').text('Zeitstrahl ausblenden');
	plg_timeline.init();
});
