var globalCounter = 14 ;
var globalAll = 0;
var globalH = 0;
var stoped = 0;
var globalSpeed = 20;
var margin = 40;
var allWidth;
var loopPoint = 0;

function pause()
{
	stoped=1;
}

function play(id)
{
	stoped=0;	
	setTimeout(function(){go_left(id)}, globalSpeed);
}

function bottomlogosChanger(id) {
	
    $(document).ready(function() {        
		var logoWidth = 0;
		allWidth = 0;
		var newPosition = 0;
        $("ul#"+id).css({
            'position':'relative',
            'height': 84 + 'px',
			'top':'5px',
            'overflow':'hidden'
        }); 
		
		loopPoint = parseInt($("ul#"+id+" li:first").width()) + margin;
		
        $("ul#"+id+" li").each(function(i){
			
            $(this).css({
                'position':'absolute',
                'top':'0',
                'left': allWidth+'px'
            });
			
			logoWidth = parseInt($(this).width());
			allWidth = parseInt(allWidth) + parseInt(logoWidth) + parseInt(margin);
			
        });
        allWidth = allWidth - loopPoint;
		
		//uzbrojenie w metody
		$("#logotypy").bind('mouseover', function(){pause();});
		$("#logotypy").bind('mouseleave', function(){play(id);});
		
		
		
		play(id);

    });
}
function go_left(id){
	if(stoped==0)
	{
			$("ul#"+id+" li").each(function() {
				var left = $(this).css('left');
				var new_position = parseInt(left)-1;
				//var width = parseInt($(this).width());
				if(new_position == -loopPoint)
				{
					var begining_position = allWidth;
					$(this).css({'left':begining_position+'px'});
				}
				else
				{
					$(this).css({'left':new_position+'px'});
				}
			});
			setTimeout(function(){go_left(id)}, globalSpeed);
	}
	
}


function logosHover()
{
$("ul.logos li").hover(function() { 
			var liWidth = parseInt($(this).width());
			var imgWidth = parseInt($(this).find("img").width());
			var margin = liWidth - imgWidth;
			margin = (margin/2)-1;
		
		var thumbOver = $(this).find("img").attr("src");
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat '+margin+'px -46px'});
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() 
		});
	} , function() { 
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});	
}





