/* jQuery - Create tabs */
jQuery.fn.tabs = function()
{
	return this.each(function()
	{
		var tabContainers = $(this).children('div');
		tabContainers.hide().filter(window.location.hash).show();
		var tabLinks = $(this).children('ul').children('li').find('a');
		tabLinks.click(function()
		{
			window.location.hash = this.hash;
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			tabLinks.removeClass('active');
			$(this).addClass('active');
			return false;
		})
		.filter('[href=\"'+window.location.hash+'\"]').click();
	});
};

/* jQuery - Center in browser window or in div */
$.fn.center = function(div)
{
	/* Center object in the browser window */
	if (div == null)
	{
		div = window;
		var x = 0;
		var y = 0;
		this.css('position', 'fixed');
		this.css('left', x + ($(div).width()-this.width())/2 + $(div).scrollLeft() + 'px');
		//this.css('top', y + ($(div).height()-this.height())/2 + $(div).scrollTop() + 'px');
		this.css('top', y + ($(div).height()-this.height())/2 + 'px');
	}
	/* Center object in div */
	else
	{
		var position = $(div).position();
		var x0 = position.left;
		var y0 = position.top;
		var w = this.width()/2;
		var h = this.height()/2;
		this.css('position', 'fixed');
		this.css('left', x0 - w + $(div).width()/2 + 'px');
		this.css('top', y0 - h + $(div).height()/2 + 'px');
	}
	return this;
}

/* jQuery - Disable copy/paste function for text block */
$.extend($.fn.disableTextSelect = function()
{
	return this.each(function()
	{
		if ($.browser.mozilla) $(this).css('MozUserSelect','none');		// FF
		else if ($.browser.msie) $(this).bind('selectstart',function() { return false; });		// IE
		else $(this).mousedown(function() { return false; }); 	// Opera, etc.
	});
});

