Slidefolio = new Class({
	
	initialize : function(xmlData){
		this.count = 0;
		this.num = 0;
		this.xItems = xmlData.selectNodes( "//slides/img");
		this.length = this.xItems.length;
	},

	start: function(){
		this.insert();
		this.periodicalTimer = this.update.periodical(8000, this);
	},
	
	update : function(){
	
		if(this.count < this.length-1) this.count++;
		else this.count = 0;

		this.insert();
		
		img = document.getElementById('div_center_header').getElementsByTagName('img')[0];
		
		var myFx = new Fx.Slide(img , {
		    duration: 1500,
			mode: 'vertical',
			transition: 'circ:out',
		    onComplete: function(){ 
				document.getElementById('div_center_header').removeChild(document.getElementById('div_center_header').getElementsByTagName("div")[0]);
				$clear(this.periodicalSlide);
				this.num = 0;
				this.periodicalSlide = this.slide.periodical(3050, this);
			}.bind(this)
		});
		
		myFx.slideOut();
		
		/*
		img.set('slide', {duration: 1500, mode: 'vertical', transition: 'circ:out', 
						onComplete: function(){ 
						
							document.getElementById('div_center_header').removeChild(document.getElementById('div_center_header').getChildren()[1]);
							$clear(this.periodicalSlide);
							this.num = 0;
							this.periodicalSlide = this.slide.periodical(3050, this);
						}.bind(this)
		})
		
		img.slide('out');*/
		
	
	},
	
	insert : function(){
		
		img = document.createElement('img');
		
		
		img.src = this.xItems[this.count].getAttribute('src');

		document.getElementById('div_center_header').appendChild(img);
		
	
	},
	
	slide : function(){

		var img = document.getElementById('div_center_header').getElementsByTagName('img')[0];
	
		if(this.num >= this.xItems[this.count].getElementsByTagName('img').length){
			this.num = 0;
		}

		if(this.xItems[this.count].getElementsByTagName('img').length > 1){
			img.set('tween', {duration: 180,
				onComplete: function(){
					
				
					
					img = document.getElementById('div_center_header').getElementsByTagName('img')[0];
					
					if(typeof(this.xItems[this.count].getElementsByTagName('img')[this.num]) != 'undefined'){
						img.src = this.xItems[this.count].getElementsByTagName('img')[this.num].getAttribute('src');
						
						img.set('tween', {duration: 250});
						img.fade('in');
					}
				}.bind(this)
			});
			
			img.fade(.1);
		}
	

		this.num++;
		
	}
});