jQuery(document).ready(function() {
	
	var myPix = new Array();
	
	var slider = $('#slidewidth');
	var i = 0;
	var a = 0;

	var kids = slider.children();
	
        kids.each(function() {
			var child = $(this);
			myPix[i] = child.find('img').attr("src");
			if(child.attr('id') === "active"){
				
				a = i;
				child.removeAttr("id")
				
			}
			i++;
		});
	
	
	var currentPos = a;
	

	if (currentPos >= myPix.length) {
		currentPos = 0;
	}

	

	if (currentPos <= -1) {
		currentPos = myPix.length -1;
	}

	
	var i = 0;
	kids.each(function() {
		var child = $(this);

		if(i == currentPos){
			child.removeClass('hide');
			child.attr('id',  "center");
			
		}
		i++;
	});
	
	var init = setTimeout(function(){ next();}, 7000);
	
	function next(){
		
		currentPos = currentPos + 1;
	
		if (currentPos >= myPix.length) {
			currentPos = 0;
		}
		
		if (currentPos <= -1) {
			currentPos = myPix.length -1;
		}
		
		
		
		$('#slidewidth').find('#center').fadeOut(400).fadeIn(200);
	
		
		setTimeout(function(){
		var i = 0;
			kids.each(function() {
				var child = $(this);
				child.removeAttr("id");
				child.attr('class', "inner");
				if(i == currentPos){
					child.removeClass('inner');
					child.attr('id',  "center");
					
				}
				i++;
			});
		}, 500);
		
		init = setTimeout(function(){ next();}, 6000);
		
	}
	
});
	
	
	   

