// jQuery_Auto 0.9
// Automatic functions for webpages (using the wonderful jQuery library)
// Copyright: (c) 2006, Michal Tatarynowicz (tatarynowicz@gmail.com)
// Licenced as Public Domain (http://creativecommons.org/licenses/publicdomain/)
// $Id: jquery_auto.js 426 2006-05-06 19:54:39Z Michał $

$(document).ready(function() {
	$(".secret").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".tab").css("display","none");
	$(".secret").click(function(){
		$(this).next().slideToggle("slow");
		});
});

// Initialization
$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);


// Auto-selected text in text fields after a label click
$.auto.select = {
	init: function() {
		$('label.fieldSelect').each(this.label_action);
		$('textarea.fieldSelect').bind('click', function(){ this.select(); });
		$('input.fieldSelect').bind('click', function(){ this.select(); });
	},

	label_action: function() {
		var field = $('#'+this.htmlFor).get(0);
		if (field && field.focus && field.select) {
			$(this).bind('click', function(){ field.focus(); field.select(); });
		}
	}
};


// Switches tabs on click
$.auto.tabs = {
	init: function() {
		$('.tabContainer').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.tab li, li.tab', group).each(function(){
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'Body').hide();
			}).filter(':first').trigger('click');
		});
	},

	click: function() {
		var tab = $('#'+this.id+'Body').get(0);
		$('.tab li, li.tab', this.group).each(function(){
			$(this).removeClass('active');
			$('#'+this.id+'Body').hide();
		});
		$(this).addClass('active');
		$(tab).show();
		this.blur();
		return false;
	}
};
