function Changer(id,width) {

    $(document).ready(function() {
        $("ul#"+id).css({
            'position':'relative',
            'height': 230 + 'px',
            'width': width + 'px',
            'overflow':'hidden'
        });

        $("ul#"+id+" li").each(function(i){
										
            $(this).css({
                'position':'absolute',
                'top':'0',
                'left':i*width +'px'
            });
            $(this).attr("title",i+1);
            $(this).children("a").after("<p>"+$(this).children("a").children("img").attr("alt")+"</p>");
        });

        $("ul#"+id+" li:first").addClass("selected");
        $("ul#"+id+" li:first").css("display", "block");
		
		$(".next").click(function() { 
			next(true, id, width);
		});
		
		$(".prev").click(function() { 
			prev(true, id, width);
		});
		
$(".prev").mousedown(function() {
left = parseInt($(this).css('left').replace(/px/i, ''));
 $(this).animate({'left': (left - 3) + 'px'}, 100).animate({'left': (left) +'px'}, 100);
 });
 
$(".next").mousedown(function() {
 right = parseInt($(this).css('right').replace(/px/i, ''));
 $(this).animate({'right': (right - 3 ) + 'px'}, 100).animate({'right': (right) +'px'}, 100);
 });

 $(".next").hover(function() {
top = parseInt($(this).css('top').replace(/px/i, ''));
bottom = parseInt($(this).css('bottom').replace(/px/i, ''));
 
 $(this).animate({'top': (top-2) + 'px', 'bottom': bottom + 'px'}, 100);
 }, function() {
 $(this).animate({'bottom': ( bottom -2 ) + 'px', 'top': top + 'px'}, 100);
 });

$(".prev").hover(function() {
top = parseInt($(this).css('top').replace(/px/i, ''));
bottom = parseInt($(this).css('bottom').replace(/px/i, ''));

 $(this).animate({'top': (top-2) + 'px', 'bottom': bottom + 'px'}, 100);
 }, function() {
 $(this).animate({'bottom': (bottom-2)+'px', 'top':  top + 'px'}, 100);
 }); 
       

        setTimeout( function(){
           next(false,id,width)
        }, 60000);

    });
}


function next(clicked,id,width) {  
    var i = parseInt($("ul#"+id+" li.selected").attr("title"));
	
    if (LastElement(i,id,width)){
        $("ul#"+id+" li[title='"+NextElement(i,id)+"']").css('left', width + 'px');
    }
    if (parseInt($("ul#"+id+" li[title='"+NextElement(i,id)+"']").css('left').replace(/px/i, '')) % width != 0) {
        $("ul#"+id+" li[title='"+NextElement(i,id)+"']").css('left', width + 'px');
    }
    $("ul#"+id+" li[title='"+i+"']").removeClass("selected");
    $("ul#"+id+" li[title='"+(NextElement(i,id))+"']").addClass("selected");
    $("ul#"+id+" li[title='"+(NextElement(i,id))+"']").css("display", "block");
    
	
     
	$("ul#"+id+" li").each(function(i)
	{
        var newLeft = parseInt( $(this).css("left").replace(/px/i, '') )-(width);	
		$(this).animate({'left':newLeft+'px'},300);		
    }); 
	
   if (!clicked) {
        setTimeout( function(){
            next(null,id,width)
        }, 60000);
    }
}

function prev(clicked,id,width) {  
    var i = parseInt($("ul#"+id+" li.selected").attr("title"));
	
    if (FirstElement(i,id,width)){	
        $("ul#"+id+" li[title='"+PrevElement(i,id)+"']").css('left', '-' + width + 'px');
    }
    if (parseInt($("ul#"+id+" li[title='"+PrevElement(i,id)+"']").css('left').replace(/px/i, '')) % width != 0) {
        $("ul#"+id+" li[title='"+PrevElement(i,id)+"']").css('left', '-' + width + 'px');
    }
    $("ul#"+id+" li[title='"+i+"']").removeClass("selected");
    $("ul#"+id+" li[title='"+(PrevElement(i,id))+"']").addClass("selected");
    $("ul#"+id+" li[title='"+(PrevElement(i,id))+"']").css("display", "block");
    
	
     
	$("ul#"+id+" li").each(function(i)
	{
        var newLeft = parseInt( $(this).css("left").replace(/px/i, '') )+(width);	
		$(this).animate({'left': newLeft+'px'},300);		
    }); 
	
   if (!clicked) {
        setTimeout( function(){
            next(null,id,width)
        }, 60000);
    }
}




function NextElement(index,id) {
    if(index < parseInt($("ul#"+id+" li:last").attr("title"))) {
        return index + 1;
    } else {
        return 1;
    }
}

function PrevElement(index,id) {
    if(index > parseInt($("ul#"+id+" li:first").attr("title"))) {
        return index - 1;
    } else {
        return parseInt($("ul#"+id+" li:last").attr("title"));
    }
}

function LastElement(index,id,width) {
    return (parseInt($("ul#"+id+" li[title='"+NextElement(index,id)+"']").css("left").replace(/px/i, '')) <= (1 - parseInt($("ul#"+id+" li:last").attr("title")))*(width));
}

function FirstElement(index,id,width) {   
    return (parseInt($("ul#"+id+" li[title='"+PrevElement(index,id)+"']").css("left").replace(/px/i, '')) >= (parseInt($("ul#"+id+" li:last").attr("title")) -1 )*(width));
}

