//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).

Fp.Marquee={animHandlers:{},addAnimatedString:function(g){if(!g||!g.element||typeof g.text!=="string"){return;}var f=g.element,b=document.createElement("div");f.style.whiteSpace="nowrap";f.innerHTML="";f.innerHTML=g.text.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;");f.title=f.innerHTML;if(f.parentNode.className.indexOf("scroll-panel")!=-1){return;}b.className="scroll-panel "+f.id;f.parentNode.insertBefore(b,f);b.appendChild(f);if(!g.clickelement||!g.clickelement.id){new Fp.Utils.addTapEvent({element:f,onEvent:function(h){Fp.Marquee.animateString(h.target);}});}else{var a=g.clickelement.id;if(!this.animHandlers[a]){this.animHandlers[a]=[];}var d=this.animHandlers[a],e,c;d.push(function(){Fp.Marquee.animateString(f);});new Fp.Utils.addTapEvent({element:g.clickelement,onEvent:function(){for(e=0,c=d.length;e<c;e++){if(d[e]){d[e]();}}}});}Fp.Marquee.addStringEllipsis(f);},addStringEllipsis:function(b){var d=b.title,a=d.length,c=Math.round(a/2);b.innerHTML=b.title;b.parentNode.scrollLeft=0;if(b.parentNode.scrollWidth<=b.offsetWidth){return false;}while(c>1){if(b.parentNode.scrollWidth<=b.offsetWidth){a+=c;}else{a-=c;}c=Math.round(c/2);b.innerHTML=d.substring(0,a)+"###";}b.innerHTML=b.innerHTML.replace(/#+$/,"...");return true;},animateString:function(c){if(c.interval){return;}var d=3,a=c.parentNode,b=Fp.Lang.isRTL?a.offsetWidth-a.scrollWidth:0;c.innerHTML=c.title+"&nbsp;&nbsp;&nbsp;&nbsp;";a.scrollLeft=b;if(c.interval){clearInterval(c.interval);}c.interval=setInterval(function(){c.lastPos=a.scrollLeft;a.scrollLeft+=d;if(a.scrollLeft==c.lastPos){clearInterval(c.interval);delete c.interval;setTimeout(function(){a.scrollLeft=b;Fp.Marquee.addStringEllipsis(c);},1000);}},50);}};