//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).
Fp.Utils.Marquee={animHandlers:{},addAnimatedString:function(h){if(!h||!h.element||typeof h.text!=="string"){return false;}var g=h.element;g.innerHTML=h.text.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;");g.title=g.innerHTML;if(g.interval){clearInterval(g.interval);delete g.interval;}if(g.parentNode.className.indexOf("scroll-panel")!=-1){return true;}g.style.whiteSpace="nowrap";var b=document.createElement("div");b.className="scroll-panel "+g.id;g.parentNode.insertBefore(b,g);b.appendChild(g);if(true===Fp.Lang.isRTL){b.style.direction="rtl";}if(!h.clickelement||!h.clickelement.id){new Fp.Utils.Events.addTapEvent({element:g,onEvent:function(i){Fp.Utils.Marquee.animateString(i.target);}});Fp.addListener("onResize",Fp.Utils.bind(Fp.Utils.Marquee.animateString,this,g));}else{var a=h.clickelement.id;if(!this.animHandlers[a]){this.animHandlers[a]=[];}var d=this.animHandlers[a],e,c;d.push(function(){Fp.Utils.Marquee.animateString(g);});var f=function(){for(e=0,c=d.length;e<c;e++){if(d[e]){d[e]();}}};new Fp.Utils.Events.addTapEvent({element:h.clickelement,onEvent:f});}Fp.addListener("onResize",f);Fp.Utils.Marquee.addStringEllipsis(g);},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(true===Fp.Lang.isRTL){Fp.Utils.Marquee.addStringEllipsis(c);return;}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.Utils.Marquee.addStringEllipsis(c);},1000);}},50);},clearAnimation:function(a){if(a){a.parentNode.scrollLeft=0;clearInterval(a.interval);delete a.interval;}}};