function logosChanger(id,metoda,width) {

    $(document).ready(function() {
        $("ul#"+id).css({
            'position':'relative',
            'height': 320 + '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");
       

        setTimeout( function(){
           next(false,id,metoda,width)
        }, 6000);

    });
}


function next(clicked,id,metoda,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);
		
		if(metoda==1)
		{
			shiftIt(this,newLeft,500);
		}
		else if(metoda==2)
		{
			$(this).fadeOut().animate({'left':newLeft+'px'},0).fadeIn();
		}
    }); 
	
   if (!clicked) {
        setTimeout( function(){
            next(null,id,metoda,width)
        }, 8000);
    }
}
function shiftIt(object,newPosition,speed)
{
	$(object).animate({'left':newPosition+'px'},speed);
}


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));
}

