
$(window).load(function() {
	if($('#slider')){
		$('#slider').nivoSlider({
			effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
			pauseTime:5000,
			directionNav:false, // Next & Prev navigation
			controlNav:true, // 1,2,3... navigation
			keyboardNav:true, // Use left & right arrows
			pauseOnHover:true // Stop animation while hovering
		});
	}

	var npint;
	$('#next').mouseover(function(){
		npint = setInterval("slide();",10);
	});
	$('#next').mouseout(function(){
		clearInterval(npint);
	});
	$('#prev').mouseover(function(){
		npint = setInterval("slideBack();",10);
	});
	$('#prev').mouseout(function(){
		clearInterval(npint);
	});
	
});


var lis = $('#logocontainer ul li');
var w=0;
for(var i=0; i<lis.length; i++){
	w = ((w-1)+1)+((($(lis).eq(i).css('width')).replace(/px/,'')-1)+1);
}
w = (w-927);
w = ((w-w)-w);
var append = 0
var prepend = $('#logocontainer ul li').length-1;
var ulw = $('#logocontainer ul').css("width").replace(/px/,'');
function slide(){
	var left = $('#logocontainer ul').css('marginLeft').replace(/px/,'');
	if(left <= (w+10)){
		var v = $('#logocontainer ul li');
		w = w - $(v).eq(append).css('width').replace(/px/,'');
		ulw = ((ulw-1)+1)+(($(v).eq(append).css('width').replace(/px/,'')-1)+1);
		$('#logocontainer ul').css("width",ulw+"px");
		$('#logocontainer ul').append("<li>"+$(v).eq(append).html()+"</li>");
		append = append+1;
	}
	if(left > w){
		$('#logocontainer ul').css('marginLeft',(left-1)+'px');
	}
}
function slideBack(){
	var left = $('#logocontainer ul').css('marginLeft').replace(/px/,'');
	if(left == 0){
		var v = $('#logocontainer ul li');
		w = w - $(v).eq(prepend).css('width').replace(/px/,'');
		ulw = ((ulw-1)+1)+(($(v).eq(prepend).css('width').replace(/px/,'')-1)+1);

		var left = left-$(v).eq(prepend).css('width').replace(/px/,'');
		$('#logocontainer ul').css("width",ulw+"px");
		$('#logocontainer ul').prepend("<li>"+$(v).eq(prepend).html()+"</li>");
	}

	
	if(left < 0){
		$('#logocontainer ul').css('marginLeft',((left-1)+2)+'px');
	}
}

function regLeft(ths){
	$.ajax({
		url: "/incl/jq/ml.php",
		data: ({ml : $('#logocontainer ul').css('marginLeft'), href : $(ths).attr('href')}),
		success: function(html){
			window.location = html;
		}
	});
	return false;
}
