/* Begin: TragicMedia.com - jQuery Fade Script
/* created 1/10 by Rich Rudzinski
/*------------------------------------------*/
// opacitySpeed is how fast the item will fade in/out, the intervalSpeed is how often the items will change (in milliseconds), opacitySpeed is in reverse, the lower the number the slower the fade
// var constants = {container:"fadeCont", itemClass:"item", opacitySpeed:100, intervalSpeed:3000};
// var fade = new jFade(constants);
function jFade(values) {
	var obj = this;
	this.values = values;
	/* set default values if not filled in */
	this.container = jQuery('#'+values.container);					 
	if(this.values.opacitySpeed == undefined) this.values.opacitySpeed = 60;
	if(this.values.intervalSpeed == undefined) this.values.intervalSpeed = 90000;
	this.fadeItems = jQuery('.'+values.itemClass, '*', document);
	this.container.css('width', jQuery(this.fadeItems[0]).width() + 'px');
	this.container.css('height', jQuery(this.fadeItems[0]).height() + 'px');
	this.animate = false;
	this.orderItems();
	this.fadeInterval = setInterval(function() { 
		var that = obj ? obj : jQuery(obj);
		jQuery(that.fadeItems[0]).animate({
			opacity: 0
		}, that.values.opacitySpeed, function() {
			jQuery(that.fadeItems[0]).insertAfter(jQuery(that.fadeItems[that.fadeItems.length - 1]));
			that.orderItems();
		});
	}, this.values.intervalSpeed);
}	

// Sets container width, shifts elements if startPosition != 1			
jFade.prototype.orderItems = function() {
	this.fadeItems = jQuery('.'+this.values.itemClass);
	for(var i=0; i<this.fadeItems.length; i++) {
		var el = jQuery(this.fadeItems[i]);
		el.css('zIndex', this.fadeItems.length - i);
		el.css('opacity', 1);
		el.css('filter', 'alpha(opacity='+1*100+')'); 
	}
}
	
/*------------------------------- End Rich's jQuery Fade Script ---------------------------------------*/
