// JavaScript Document

function ge(id){
	return document.getElementById(id);
}


$(document).ready(function(){

	productsScrollsInitialize();

});

function productsScrollsInitialize() {	$(".products-scroll").each(function(){
		var skey = $(this).find(".products-scroll-arrow").attr('key');
		var productScrollList = $("ul[key="+skey+"]");
        var sheight = productScrollList.height();
        var ilasth = productScrollList.children("li:first").height();

        var ilast = productScrollList.children("li:last").html();

        $("ul[key="+skey+"]").prepend('<li>'+ilast+'</li>');

        productScrollList.children("li:last").remove();

        $("ul[key="+skey+"]").css({'top':-ilasth-30});


        /// SCROLL BUTTONS FUNCTIONS
        $(this).find(".products-scroll-down-arrow .enabled").click(function(){        	productScrollList.animate({"top": "-=" + (productScrollList.children("li").height() + 30) + "px"},"normal",function(){        		 	$("ul[key="+skey+"]").append('<li>'+productScrollList.children("li:first").html()+'</li>');
        		 	productScrollList.children("li:first").remove();
        		 	$("ul[key="+skey+"]").css({'top':-ilasth-30});
        	});
        });

        $(this).find(".products-scroll-up-arrow .enabled").click(function(){
        	productScrollList.animate({"top": "+=" + (productScrollList.children("li").height() + 30) + "px"},"normal",function(){
        		 	$("ul[key="+skey+"]").prepend('<li>'+productScrollList.children("li:last").html()+'</li>');
        		 	$("ul[key="+skey+"]").css({'top':-ilasth-30});
        		 	productScrollList.children("li:last").remove();
        	});
        });



 		});
 };

function productsScrollsInitialize_old() {

	$(".products-scroll").each(
		function() {

			productsScrollsCount++;

			var productScrollName = "productScroll" + productsScrollsCount;
			var productScrollList = $(this).find(".products-scroll-list");

			$(this).attr("id", productScrollName);
			productsScrollsInformation[productScrollName] = {

				count: productScrollList.find("ul li").size(), // количество
				seeCount: Math.floor(productScrollList.height() / productScrollList.find("ul li").height()), // умещаются в блок
				currentPosition: 0

			};
//			alert()
//			productsScrollArrowsCheck(productScrollName);



		}
	);
}