(function(a){a.fn.ScrollNews=function(c){var e={size:a(this)[0].style.height+"px",timeout:5000,speed:"fast",direction:"up",onmouseover:"continue"};var b=a.extend(e,c);if(b.speed<=30){b.speed=30}switch(b.speed){case"fast":b.speed=30;break;case"medium":b.speed=50;break;case"slow":b.speed=100;break;default:b.speed=30;break}var d=parseInt(a(this).children("div").length-parseInt(1));if(d>0){for(i=0;i<=d;i++){a(this).children("div")[i].style.height=b.size;a(this).children("div")[i].style.overflow="hidden";a(this).children("div")[i].style.marginTop="0px"}switch(b.direction){case"up":a(this)[0].style.height=b.size;a(this)[0].style.overflow="hidden";break;case"down":a(a(this).children("div")[d]).hide();a(this).prepend(a(this).children("div")[d]);a(this).children("div")[0].style.marginTop="-"+b.size;a(a(this).children("div")[0]).show();a(this)[0].style.height=b.size;a(this)[0].style.overflow="hidden";break}a(this)[0].VarControllo=0;a(this)[0].array=b;if(b.onmouseover=="stop"){a(this)[0].onmouseover=function(){a.fn.ScrollNews.StopScroll({id:a(this)[0].id})};a(this)[0].onmouseout=function(){a.fn.ScrollNews.ContinueScroll({id:a(this)[0].id})}}switch(b.direction){case"up":a(this)[0].contatore=0;setTimeout('$("#'+this[0].id+"\").ScrollNews.ScrollUp({id : '"+this[0].id+"',contatore : "+a(this)[0].contatore+",numerofigli :"+d+"})",b.timeout);break;case"down":a(this)[0].contatore=parseFloat("-"+b.size);setTimeout('$("#'+this[0].id+"\").ScrollNews.ScrollDown({id : '"+this[0].id+"',contatore : "+a(this)[0].contatore+",numerofigli :"+d+"})",b.timeout);break}}};a.fn.ScrollNews.ScrollUp=function(f){var d=a("#"+f.id);var b=a(d).children("div")[0];var e=f.numerofigli;var c=d[0].array;a(d)[0].i=setInterval(function(){if(a(d)[0].VarControllo==0){a(d)[0].contatore=a(d)[0].contatore-1;b.style.marginTop=(parseInt(a(d)[0].contatore)-parseInt(1))+"px";if(parseFloat(a(d)[0].contatore)=="-"+parseInt(c.size)){clearInterval(a(d)[0].i);a(b).hide();a(b).remove();a(d).append(b);a(d).children("div")[e].style.marginTop="0px";a(a(d).children("div")[e]).show();a(d)[0].contatore=0;setTimeout('$("#'+f.id+"\").ScrollNews.ScrollUp({id : '"+f.id+"',contatore : "+a(d)[0].contatore+",numerofigli :"+e+"})",c.timeout)}}},c.speed)};a.fn.ScrollNews.ScrollDown=function(g){var d=a("#"+g.id);var b=a(d).children("div")[0];var e=a(d).children("div")[g.numerofigli];var f=g.numerofigli;var c=d[0].array;a(d)[0].i=setInterval(function(){if(a(d)[0].VarControllo==1){}else{a(d)[0].contatore=a(d)[0].contatore+1;b.style.marginTop=(parseInt(a(d)[0].contatore)+parseInt(1))+"px";if(parseFloat(a(d)[0].contatore)==parseInt(0)){clearInterval(a(d)[0].i);a(a(d).children("div")[f]).hide();a(a(d).children("div")[f]).remove();a(d).prepend(e);a(d).children("div")[0].style.marginTop="-"+c.size;a(a(d).children("div")[0]).show();a(d)[0].contatore=parseFloat("-"+c.size);setTimeout('$("#'+g.id+"\").ScrollNews.ScrollDown({id : '"+g.id+"',contatore : "+a(d)[0].contatore+",numerofigli :"+f+"})",c.timeout)}}},c.speed)};a.fn.ScrollNews.StopScroll=function(b){a("#"+b.id)[0].VarControllo=1};a.fn.ScrollNews.ContinueScroll=function(b){a("#"+b.id)[0].VarControllo=0}})(jQuery);
