// Scroll artist + designer list

function scroll_manuf_menu(current) {
	var boxsize = $("#designers_wrap").height(); 
	var listsize = $("#designers").height();
	var pos = parseInt( $("#designers").css("margin-top"));
	var line_h =  ($("#designers a:first").outerHeight());
	//var line_h = 14; 
	
	var max_offset = listsize - boxsize //Maximum allowed offset - place a minus before
	
	//Set initial offset (to place current item on top)
	var init_offset = line_h * current; 
	if (init_offset > max_offset) {
		init_offset = max_offset; 
	}; 
	//*DEBUG*/alert( "boxsize: "+boxsize+"; listsize: "+listsize+"; pos: "+pos+"; line height: "+line_h+"; offset: "+init_offset);
	
	if (listsize > boxsize) { 
		//Tries to place current item on top initiallly
		if ( init_offset > 0) {
			$("#designers").css({marginTop: -init_offset});	
			$("#des_arrow_up").css({visibility: "visible"});			
		}
		
		$("#des_arrow_dn").css({visibility: "visible"});
		$("#des_arrow_up").click(function(){
			$("#des_arrow_dn").css({visibility: "visible"});
			if (-boxsize > pos) {
				goal = pos + boxsize;
			} else {
				goal = 0; 
				$("#des_arrow_up").css({visibility: "hidden"}); 
			}
			$("#designers").animate({ marginTop: goal }, "slow");
			pos = goal; 
		}); 
	
		$("#des_arrow_dn").click(function(){
			$("#des_arrow_up").css({visibility: "visible"});
			if (2 * boxsize < listsize + pos) {
				goal = pos - boxsize;
				//alert("boxsize: "+boxsize+"; pos: "+pos+"; boxsize: "+boxsize+"; goal: "+goal); 
			} else {
				goal = -max_offset; 
				$("#des_arrow_dn").css({visibility: "hidden"});
				//alert("boxsize: "+boxsize+"; pos: "+pos+"; listsize: "+listsize+"; goal: "+goal); 
			}
			$("#designers").animate({ marginTop: goal }, "medium"); 
			pos = goal; 
		}); 
		
	}
}

function do_scroll_list() {
	//Scrolling homepage list
	lh = $("#sl1").height(); //list height
	ch = $("#scroll_list_wrap").height(); //container height; 
	v = 0.025; //real speed
	//v = 0.1; //test speed
	

	//$("#sl1").css('marginTop', ch+100);
	$("#sl1").animate( 
		{marginTop: 0}, 
		ch/v, 
		"linear"
	); 
	scroll_list(lh,v)

	
	function scroll_list(lh,v) {
		$("#sl1").css('marginTop', 0); 
		$("#sl1").animate( 
			{marginTop: -lh}, 
			lh/v, 
			"linear", 
			function () {scroll_list(lh,v);}
		);
	};
	
};

function home_ss() {
	$('#home_ss').fadeIn(4000); 
	$('#home_ss').innerfade({ 
		animationtype: 'fade', 
		speed: 2000, 
		timeout: 4000, 
		type: 'sequence' 
	}); 
}; 

function inject(url, target) {
	$(target).load(url);
}

