/*!
 * Custom Script for 'Flora' by Norman Paschke
 * version: 1.0 (23-SEP-2010)
 * @requires jQuery v1.4.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
function switch_tabs(obj){
	jQuery("#tab_sidebar .widget").hide();
	jQuery("#tab_sidebar .tabs").find("a").removeClass("selected");
	var id=obj.attr("rel");
	jQuery("#"+id).fadeIn(500);
	obj.addClass("selected");
};
jQuery(document).ready(function($){
	$(".toplink").click(function(e){
		e.preventDefault();
		$("html,body").animate({scrollTop:'0px'},500);
	});
	$("#tab_sidebar").prepend('<ul class="tabs"></ul>');
	var widgettitle=jQuery("#tab_sidebar .widgettitle");
	var tabs=jQuery("#tab_sidebar .tabs");
	widgettitle.each(function(i){
		var parentid = $(this).parent(".widget").attr("id");
		$(this).appendTo(tabs).wrap(function(){
			return '<li><a href="#" rel="'+parentid+'">'+$(this).html()+'</a></li>';
		});
	});
	widgettitle.remove();
	tabs.find("a").click(function(e){
		e.preventDefault();
		switch_tabs($(this));
	});
	switch_tabs(tabs.find("li:first-child a"));
	var select = $('a[href$=".gif"],a[href$=".jpg"],a[href$=".jpeg"],a[href$=".png"],a[href$=".GIF"],a[href$=".JPG"],a[href$=".JPEG"],a[href$=".PNG"]');
	select.attr("rel","fancybox");
	select.fancybox();
});
