function move (elementId, direction, roundTrip, marginStart)         
// round-trip : 1 = yes, 0 = no
// direction: negative = right to left
{                                                           			
	// element to move:
	var obj = $(elementId);
	if (!marginStart) marginStart=0;
	if(obj) {
		// width of the element
		var w = obj.offsetWidth;
		// move left: 0|marginStart then if start or obj.margin
		var margin = obj.margin || marginStart;
		// ((new property 'margin' assigned to 'obj': 'obj.margin' later in the script)
		// search the 'div' that contains the item
		var box = obj.parentNode;
		while( box.tagName != 'DIV') box = box.parentNode;
		// fixing of the container style (style attribute of the container)
		box.className = 'marquee';
		// width of the box :
		var W = box.offsetWidth;
		if(roundTrip == 1) {
			direction = obj.direction || direction;
			if( (margin >= (W-w) && direction>0) ||
			    (0 >= margin && direction<0) ) {
				obj.direction = (-1 * (direction));
			}
			direction = obj.direction || direction;
		}
		// increases 'margin' (with to direction)
		margin = margin + (direction);
		if(roundTrip != 1) {
		   	// correct 'margin' over the 'box'
		   	if(margin > W ) margin = -w;
		   	if(margin+w < 0 ) margin = W;
	   	}
		// Last element is moved
		obj.style.right = margin +'px';
		// and this direction is stored in the element (obj.margin)
		obj.margin = margin;
		$(elementId).style.visibility='visible';
	}
}

function marquee(container, element, delay) {		
	var elementWidth = 0;//$(element).scrollWidth + $(element).offsetWidth;/*padding last element*/
	$$('#'+container+' a').each(function(element,index) {
		elementWidth += element.scrollWidth + 40;
	});
	$(element).style.width=elementWidth+'px';
	move(element, 1, 0, -elementWidth);
	setInterval( function(){ move(element, 1, 0, 0); }, delay);	
}

