var statscro = 0;
var clonex1 = {};
var clonex2 = {};
var t = 0;
function autoScroller(contentDiv, speed)
{	
    contentDiv = "#"+contentDiv;
    var scrollSpeed = (speed==null) ? 5 : parseInt(speed);
    
    // double make sure the autoScroller-container has the correct css position and overflow property
    jQuery(contentDiv).parent().css({position:'relative',overflow:'hidden'});
    
    // set contentDiv style
    jQuery(contentDiv).css({position:'absolute',top:0});
    // get contentDiv height
    contentDivHeight = jQuery(contentDiv).height();
	contentBoxHeight = jQuery(contentDiv).parent().height();        
    
	   clonex1 = jQuery(contentDiv).clone();
		clonex1.appendTo(jQuery(contentDiv).parent());
	   	clonex1.attr("id","clonex1");
		clonex1.css({position:'absolute',top:0});
		//clonex1.css("background","#0f0");
    clonex2 = jQuery(contentDiv).clone();
		clonex2.appendTo(jQuery(contentDiv).parent());
	   	clonex2.attr("id","clonex2");
		clonex2.css({position:'absolute',top:0});
		//clonex2.css("background","#f00");
    
   // call periodical
   jQuery(contentDiv).everyTime(100, function(i){
        if ( (parseInt(jQuery(contentDiv).css('top')) - contentBoxHeight) > (contentDivHeight*(-1)+8))
        {	
            // move scroller upwards
            offset = parseInt(jQuery(contentDiv).css('top')) - scrollSpeed + "px";
            coffset1 = parseInt(jQuery(contentDiv).css('top')) + parseInt(jQuery(contentDiv).height()) - scrollSpeed + "px";
            coffset2 = parseInt(jQuery(contentDiv).css('top')) - parseInt(jQuery(contentDiv).height()) - scrollSpeed + "px";
				
            jQuery(contentDiv).css({'top':offset});
            clonex1.css("top",coffset1);
            clonex2.css("top",coffset2);
        }
        // reset to original position
        else
        {
            // reset to original position
            offset = parseInt(jQuery(contentDiv).parent().height())+8+"px";
            jQuery(contentDiv).css({'top':offset});         
        }
    });
    
    // on mouse over event, pause the scroller
    jQuery(contentDiv).mouseover(function ()
    {
        speed = scrollSpeed;
        scrollSpeed = 0;       
    });
    
    // on mouse out event, start the scroller
    jQuery(contentDiv).mouseout(function ()
    {
        scrollSpeed = speed;
    });
}
