var xFader = {
	  'count' : 0,
	  'type' : 'img',
	  'parentEl' : '',
  	  'firstImg' : '',
	  'curImg' : '',
	  'lastImg' : 0,
	  'delay' : 2500,
	  'timer' : false,
	  'transitionTime' : 700,
	  
	  
	  'init' : function(data) {
		  this.parentEl = data;		  
		  this.gallLength = $('#'+ this.parentEl + ' img').length;
		  this.setup();
	  },
	  
	  'check' : function() {
		  alert(this.gallLength);
	  },
	  
	  'setup' : function() {
			var count = this.count;
			$('#'+this.parentEl+ ' img').each(function() {
				$(this).attr('rel', count);
				$(this).css('position', 'absolute');
				count++;			
			});	
			this.count = count;
			this.firstImg = count -1;
			this.curImg = this.firstImg * 1;
			this.start();
		},
		
		'setDelay' : function (data) {
			this.delay = data;
		},
		
		'start' : function() {

			$('#' + this.parentEl + ' img').fadeTo(0,0);	
			$('#'+ this.parentEl +' img[rel='+this.firstImg+']').fadeTo(0,1);
//			this.animate();		
			var _this = this;
			this.timer = setInterval(function(){_this.animate();},this.delay); 
		},
		
		'animate' : function() {
			$('#'+this.parentEl+ ' img[rel='+this.curImg+']').fadeTo(this.transitionTime,0);			
			this.curImg--;
			$('#'+this.parentEl+ ' img[rel='+this.curImg+']').fadeTo(this.transitionTime,1);
			if(this.curImg == this.lastImg) { this.curImg = this.firstImg + 1; }
		}	  
	  
	}// JavaScript Document	
