jQuery.fn.delay = function(time, callback){
    jQuery.fx.step.delay = function(){};
    return this.animate({delay:1}, time, callback);
}

var $px = $(document.createElement('div')).css({
	position: 'absolute'
});

jQuery.fn.px = function(property) {
	var value;
	if(jQuery.browser.msie) {						
		$px
		.clone()
		.css('width', this.css(property))
		.appendTo(this[0])
		.each(function(){
			value = $(this).width();
		})
		.remove();
	} else {
		value = this.css(property);
	}
	return value;
}

// Spotlight scroller plugin
// v 1.0 - James Edmonds, james@threeamdesign.com.au 20/01/2010
// Usage $('.spotlight').spotlight(options);
// Returns a jQuery object

jQuery.fn.spotlight = function(options) {
	var settings = jQuery.extend({
		wrapper: '.spotlight-items',
		items: '.item',
		duration: 100,
		cycle: true,
		constant: false,
		jump: false,
		force: false,
		margin: true
	}, options);
	
	return this.each(function() {
		var target = $(this);
		var parent = target.parent();
		var wrapper = target.find(settings.wrapper).addClass('spotlight-items-wrapper');
		var items = target.find(settings.items);
		var total = items.length;
		
		settings.prev = settings.prev || parent.find('a.previous');
		settings.next = settings.next || parent.find('a.next');
		
		var first = $(items[0]).addClass('first');
		var last = $(items[total - 1]).addClass('last');
		
		target.trigger('onInit', [items]);
		
		var width = 0;
		items.each(function() { width += $(this).outerWidth(); });
		
		target.find(settings.wrapper).width(width);
		target.serialScroll(settings).addClass('spotlight-processed');
	});
};

// Texta text replacement plugin
// v 1.0 James Edmonds, james@threeamdesign.com.au 16/02/2010
// Usage $('.texta').texta(options)
// Returns a jQuery object

jQuery.fn.texta = function(options) {

	var settings = jQuery.extend({
		textaURL: '/texta.php'
	}, options);
	
	return this.each(function() {
		var target = $(this);
		
		var width = target.width();
		var height = target.height();
		var size = parseInt(target.css('fontSize')) || 23;
		
		var text = target.text() || target.val();
		
		var texta = settings.textaURL + '?t=' + encodeURIComponent(text) + '&w=' + width + '&s=' + size;
		
		target.fadeTo(0, 0);
		
		var preload = new Image();
		preload.src = texta;
		
		preload.onload = function() {
			var background = "url('" + texta + "')";
			target.css({
				textIndent:'-9999em',
				width: preload.width,
				height: preload.height,
				display: 'block',
				backgroundImage: background,
				backgroundPosition: '0 0',
				backgroundRepeat: 'no-repeat'
			}).attr('title', text).addClass('texta-processed');
			target.fadeTo('normal', 1);
		}
	});
};

// Fading elements plugin
// v 1.0 James Edmonds, james@threeamdesign.com.au 16/02/2010
// Usage $('.fading').fading(options)
// Returns a jQuery object

jQuery.fn.fading = function(options) {

	var settings = jQuery.extend({
		startOpacity: 1,
		endOpacity: 0.5,
		speed: 'normal'
	}, options);
	
	return this.each(function() {
		var target = $(this).fadeTo(0, settings.startOpacity);
		target.hover(
			function() { $(this).fadeTo(settings.speed, settings.endOpacity); },
			function() { $(this).fadeTo(settings.speed, settings.startOpacity); }
		);
	});
};