// Used for maximum lengths in a textarea
function checkmaxlength(obj, maxlength)
{
	if (obj.value && obj.value.length > maxlength)
		obj.value = obj.value.substring(0, maxlength);
}

function setupGlow()
{
	var glow = $('img.glow, img.avatar');
	glow.css('opacity', 0.7);

	glow.bind('mouseenter', function() { $(this).stop().animate( { opacity: 1.0 }, 600 ); });
    glow.bind('mouseleave', function() { $(this).stop().animate( { opacity: 0.7 }, 300 ); });
}

//jQuery Plugin: Drop Shadow Text
(function($)
 {
	$.fn.textDropShadow = function()
	{
		$(this).map(function(){
			$(this).html('<span class="jq-shadow">'+$(this).html()+'</span><span class="normal">'+$(this).html()+'</span>');
			return $(this);
		});
	}
})(jQuery); 

function tabs( cache )
{
	$("#tabs ul#tablinks li a").each( function() {
		if( this.href.indexOf('#') == -1 )
			this.href += "?ajax=1";
	});

	if( typeof cache == 'undefined' )
		cache = true;

	$("#tabs").tabs( {
		'cache': cache,
		idPrefix: 'page-',

		select: function(event,ui) {
			$('#tabs ul li.loader').toggleClass('hide', false);
		},

		load: function(event,ui) {
			// Parse tooltips again
			$('.tTip', ui.panel).betterTooltip();
		},

		show: function(event,ui) {
			$('#tabs ul li.loader').toggleClass('hide', true);
		}
	} );
}

$(document).ready(function()
{
	setupGlow();
	
	$('.nav .innernav ul li a').textDropShadow();

	$('.tTip').betterTooltip();
});