var st=st||{};st.hash={};st.defineShapes={};st.defineSprites={};st.nsText="http://www.w3.org/2000/svg";st.init=function(){st.playList=data;st.initRoot();st.initDefs();st.initShapes();st.interval=Math.floor(1E3/data.FrameRate)};
st.initRoot=function(){st.root=document.createElementNS(st.nsText,"svg");var a=st.playList.FrameRect;st.root.setAttribute("width",a.xmax-a.xmin);st.root.setAttribute("height",a.ymax-a.ymin);st.root.setAttribute("viewBox",a.xmin+" "+a.ymin+" "+this.playList.FrameWidth+" "+this.playList.FrameHeight);st.scene=document.createElement("div");st.scene.style.position="relative";st.scene.style.left="0";st.scene.style.top="0";st.scene.appendChild(st.root);document.body.appendChild(st.scene)};
st.initDefs=function(){var a=document.createElementNS(st.nsText,"g"),b=document.createElementNS(st.nsText,"defs");a.appendChild(b);st.root.appendChild(a);st.defs=b};st.initShapes=function(){for(var a=st.playList.tags,b=0,d=a.length;b<d;b++){var c=a[b];switch(c.type){case 2:st.processShape(c);break;case 10:st.processFont(c);break;case 11:st.processText(c);break;case 39:st.processSprite(c);break;case 46:st.processMorphShape(c)}st.hash[c.id]=c}};
st.processMorphShape=function(a){var b=a.id,d=a.StartShape,a=a.EndShape;d.id=b+"_start";a.id=b+"_end";st.processShape(d);st.processShape(a)};
st.processFont=function(a){var b=document.createElementNS(st.nsText,"font");b.setAttribute("id","ft"+a.id);b.setAttribute("horiz-adv-x",1024);var d=document.createElementNS(st.nsText,"font-face");d.setAttribute("font-family","ft"+a.id);d.setAttribute("line-height","1.15");d.setAttribute("units-per-em",a.unitsperem);d.setAttribute("font-weight","bold");b.appendChild(d);for(var d=0,c=a.fonts.length;d<c;d++){var e=a.fonts[d],f=document.createElementNS(st.nsText,"glyph");f.setAttribute("d",e.data);f.setAttribute("unicode",
e.code);"advance"in e&&f.setAttribute("horiz-adv-x",e.advance);b.appendChild(f)}st.defs.appendChild(b)};
st.processText=function(a){for(var b=document.createElementNS(st.nsText,"g"),d=document.createElementNS(st.nsText,"defs"),c=document.createElementNS(st.nsText,"g"),e=0;a.records[e];e++){var f=a.records[e],g=document.createElementNS(st.nsText,"text");if(f.psd===!0){for(var o="",k=0,i=f.text.length;k<i;k++)o+="*";f.text=o}o=document.createTextNode(f.text);g.appendChild(o);f.bold&&g.setAttribute("font-weight","bold");g.setAttribute("font-size",f.height);f.fontid.toString().match(/\d/)?g.setAttribute("font-family",
"ft"+f.fontid):g.setAttribute("font-family",f.fontid);g.setAttribute("fill",f.color);g.setAttribute("x",f.x);g.setAttribute("y",f.y);g.setAttribute("fill-rule","nonzero");g.setAttribute("style","white-space:pre");g.setAttribute("transform",a.transform);c.appendChild(g)}b.appendChild(d);b.appendChild(c);b.setAttribute("type","text");st.defineShapes[a.id]=b};
st.processSprite=function(a){var b=document.createElementNS(st.nsText,"g"),d=document.createElementNS(st.nsText,"defs"),c=document.createElementNS(st.nsText,"g");b.setAttribute("type","sprite");b.appendChild(d);b.appendChild(c);st.defineShapes[a.id]=b};
st.processShape=function(){var a=function(a,b,e){if(document.getElementById(b))return b;var e=document.createElementNS(st.nsText,e),f;for(f in a)typeof a[f]=="object"||f=="type"||e.setAttribute(f,a[f]);a=a.stop;f=0;for(var g=a.length;f<g;f++){var o=a[f],k=document.createElementNS(st.nsText,"stop"),i;for(i in o)k.setAttribute(i,o[i]);e.appendChild(k)}e.setAttribute("id",b);st.defs.appendChild(e);return b},b=function(a,b){if(document.getElementById(b))return b;var e=document.createElementNS(st.nsText,
"pattern"),f;for(f in a)typeof a[f]=="object"||f=="type"||e.setAttribute(f,a[f]);var g=document.createElementNS(st.nsText,"image");for(f in a.image)f=="xlink:href"?g.setAttributeNS("http://www.w3.org/1999/xlink","href",a.image[f]):g.setAttribute(f,a.image[f]);e.appendChild(g);e.setAttribute("id",b);st.defs.appendChild(e);return b};return function(d){var c=document.createElementNS(st.nsText,"g"),e=document.createElementNS(st.nsText,"defs"),f=document.createElementNS(st.nsText,"g");c.appendChild(e);
c.appendChild(f);for(var e=d.paths,g=0,o=e.length;g<o;g++){var k=e[g],i=document.createElementNS(st.nsText,"path");i.setAttribute("d",k.data);if(typeof k.fill!=="undefined"){var h=d.FillStyles[k.fill],j=d.id,l=k.fill;if(h){var m=i,p=j,j=h.type;if(j==1)m.setAttribute("fill",h.color),m.setAttribute("fill-opacity",h["fill-opacity"]);else{l="f"+p+":"+l;p="";switch(j){case 2:p=a(h,l,"linearGradient");break;case 3:p=a(h,l,"radialGradient");break;case 4:case 5:p=b(h,l)}m.setAttribute("fill","url(#"+p+")")}}}if(typeof k.line!==
"undefined"){h=d.LineStyles[k.line];j=d.id;m=i;k=k.line;l=void 0;for(l in h)typeof h[l]!="object"&&m.setAttribute(l,h[l]);if("fill"in h){k="f"+j+":"+k;j="";switch(h.fill.type){case 2:j=a(h.fill,k,"linearGradient");break;case 3:j=a(h.fill,k,"radialGradient");break;case 4:case 5:j=b(h.fill,k)}m.setAttribute("stroke","url(#"+j+")")}m.setAttribute("fill","none")}f.appendChild(i)}c.setAttribute("type","shape");st.defineShapes[d.id]=c}}();
st.sprite=function(a,b){this.placeObjects=a.ShowFrame;this.sprites={};this.depths={};this.frame=this.arrayIndex=0;this.par=b;this.frames=[];for(var d=[],c=0,a=this.placeObjects.length;c<a;c++){var e=this.placeObjects[c];d.push(e);e.type==1&&(this.frames.push(d),d=[])}};st.sprite.getTagByNode=function(a){a=a.getAttribute("id").split(":");return st.hash[a[a.length-1]]};
st.sprite.prototype.showFrame=function(){var a=this.frames[this.frame],a=a[a.length-1];"action"in a&&this.action(a.action.aslist);this._showFrame();this.pause||this.frame++;if(this.frame==this.frames.length)this.frame=0};st.sprite.prototype._showFrame=function(){for(var a=this.frames[this.frame],b=0,d=a.length-1;b<d;b++){var c=a[b],e=this.renderShape(c);"opacity"in c&&this.changeOpacity(e,c.opacity);"cxform"in c&&this.colorTransform(e,c.cxform);this.lastDepth=c.depth}this.lastDepth=null};
st.sprite.prototype.action=function(a){for(var b=0,d=a.length;b<d;b++)switch(a[b].code){case 7:this.stop();break;case 129:this.gotoFrame(a[b].frame);break;case 6:this.play()}};st.sprite.prototype.stop=function(){this.pause=!0};st.sprite.prototype.gotoFrame=function(a){this.frame=a;this.pause=!0};st.sprite.prototype.play=function(){this.pause=!1};
st.sprite.prototype.renderShape=function(a){var b=null;a.replace&&a.replace==!0?b=this.replaceShape(a):a.remove&&a.remove==!0?this.removeShape(a.depth):b=a.ratio&&a.ratio>0?this.morphShape(a):this.getShape(a);b&&a.matrix&&(this.moveTag(b,a.matrix),b.getAttribute("type")=="sprite"&&(this.sprites[a.depth+":"+a.id]||(this.sprites[a.depth+":"+a.id]=new st.sprite(st.hash[a.id],b)),this.sprites[a.depth+":"+a.id].showFrame()));return b};st.sprite.prototype.getNode=function(a){return st.defineShapes[a.id].cloneNode(!0)};
st.sprite.prototype.morphShape=function(){function a(a,b){var e=[];e[0]=(b[0]+a.x)/2;e[1]=(b[1]+a.y)/2;e[2]=b[0];e[3]=b[1];return e}function b(a,b,e){return[[a[0]-e*(a[0]-b[0]),a[1]-e*(a[1]-b[1])],[a[2]-e*(a[2]-b[2]),a[3]-e*(a[3]-b[3])]]}return function(d){for(var c=this.par.getAttribute("id")+":"+d.depth+":"+d.id,c=document.getElementById(c),e=st.defineShapes[d.id+"_start"].cloneNode(!0),f=st.defineShapes[d.id+"_end"],g=0;g<e.childNodes.length;g++){for(var o=e.childNodes[g].getAttribute("d").match(/([a-zA-Z][0-9\- \.\,]+[^a-zA-Z])|(z|Z)/g),
k=f.childNodes[g].getAttribute("d").match(/([a-zA-Z][0-9\- \.\,]+[^a-zA-Z])|(z|Z)/g),i=d.ratio,h=[],j={},l={},m=0;o[m];m++)if(o[m]!="z"){var p=o[m][0],n=o[m].match(/([0-9\-\.]+)/g),s=k[m][0],q=k[m].match(/([0-9\-\.]+)/g),t;for(t in n)n[t]-=0;for(t in q)q[t]-=0;if(s==p)if(p=="M")var j={x:n[0],y:n[1]},l={x:q[0],y:q[1]},r=[j.x-i*(j.x-l.x),j.y-i*(j.y-l.y)],r="M"+r.join(" ");else s=[n[0]-i*(n[0]-q[0]),n[1]-i*(n[1]-q[1])],p=="L"?r="L"+s.join(" "):p=="Q"&&(n=[n[2]-i*(n[2]-q[2]),n[3]-i*(n[3]-q[3])],r="Q"+
s.join(" ")+" "+n.join(" "));else p=="L"?(r=a(j,n),r=b(r,q,i),j.x=n[0],j.y=n[1],l.x=q[2],l.y=q[3]):(r=a(l,q),r=b(n,r,i),l.x=q[0],l.y=q[1],j.x=n[2],j.y=n[3]),r="Q"+r[0].join(" ")+" "+r[1].join(" ");h.push(r)}h=h.join("");c.childNodes[g].setAttribute("d",h)}return c}}();
st.sprite.prototype.createShape=function(a){var b=this.getNode(a),d=this.par.getAttribute("id")+":"+a.depth+":"+a.id;"clipDepth"in a?(this.clipDepthId=d,this.clipDepth=a.clipDepth,this.clipDepthDepth=a.depth,b=this.createClip(b)):this.clipDepthId&&a.depth>this.clipDepthDepth&&a.depth<=this.clipDepth&&b.setAttribute("clip-path","url(#"+this.clipDepthId+")");b.setAttribute("id",d);return b};
st.sprite.prototype.createClip=function(a){for(var b=document.createElementNS(st.nsText,"clipPath"),a=a.firstChild.nextSibling.childNodes,d=0,c=a.length;d<c;d++){var e=a[d].cloneNode(!0);b.appendChild(e)}b.setAttribute("clippathunits","userSpaceOnUse");b.setAttribute("type","mask");return b};
st.sprite.prototype.replaceShape=function(a){var b=this.par.firstChild.nextSibling,d=this.createShape(a);if(this.depths[a.depth]){var c=this.par.getAttribute("id")+":"+a.depth+":"+this.depths[a.depth],e=document.getElementById(c);if(c==d.id)return e;b.replaceChild(d,e);this.sprites[a.depth+":"+this.depths[a.depth]]&&(this.sprites[a.depth+":"+this.depths[a.depth]]=null,delete this.sprites[a.depth+":"+this.depths[a.depth]])}else this.lastDepth?(c=this.par.getAttribute("id")+":"+this.lastDepth+":"+this.depths[this.lastDepth],
c=document.getElementById(c).nextSibling):c=b.firstChild,c?b.insertBefore(d,c):b.appendChild(d);this.depths[a.depth]=a.id;return d};st.sprite.prototype.removeShape=function(a){if(this.depths[a]){var b=this.depths[a],d=this.par.firstChild.nextSibling,b=this.par.getAttribute("id")+":"+a+":"+b,b=document.getElementById(b);d.removeChild(b);this.sprites[a+":"+this.depths[a]]&&(this.sprites[a+":"+this.depths[a]]=null,delete this.sprites[a+":"+this.depths[a]]);delete this.depths[a]}};
st.sprite.prototype.getShape=function(a){a=this.par.getAttribute("id")+":"+a.depth+":"+a.id;return document.getElementById(a)};st.sprite.concatMatrix=function(a,b){for(var d=[],a=a.split(","),b=b.split(","),c=0;a[c];c++)a[c]-=0,b[c]-=0;d.push(a[0]*b[0]+a[1]*b[1]);d.push(a[0]*b[1]+a[1]*b[3]);d.push(a[1]*b[0]+a[3]*b[1]);d.push(a[1]*b[1]+a[3]*b[3]);d.push(b[4]*a[0]+b[5]*a[1]+a[4]);d.push(b[4]*a[1]+b[5]*a[3]+a[5]);return d.join(",")};
st.sprite.prototype.moveTag=function(a,b){switch(a.getAttribute("type")){case "mask":case "shape":this.moveShape(a,b);break;case "text":this.moveText(a,b);break;case "sprite":this.moveSprite(a,b)}};st.sprite.prototype.moveShape=function(a,b){if(a.nodeName.toLowerCase()=="g")a.firstChild.nextSibling.setAttribute("transform","matrix("+b+")");else for(var d=a.childNodes,c=0,e=d.length;c<e;c++)d[c].setAttribute("transform","matrix("+b+")")};
st.sprite.prototype.moveText=function(a,b){for(var d=a.firstChild.nextSibling.childNodes,c=0;d[c];c++){var e=d[c].getAttribute("transform");d[c].oriMx=d[c].oriMx||e;e=d[c].oriMx.match(/matrix\(([^(]+)\)/)[1];e=st.sprite.concatMatrix(e,b);d[c].setAttribute("transform","matrix("+e+")")}};st.sprite.prototype.moveSprite=function(a,b){a.firstChild.nextSibling.setAttribute("transform","matrix("+b+")")};st.sprite.prototype.changeOpacity=function(a,b){a.setAttribute("opacity",b)};
st.sprite.prototype.colorTransform=function(){function a(a,d){var c=a.match(/rgb\(([^(]+)\)/)[1].split(","),e=c[1]-0,f=c[2]-0,c=Math.max(0,Math.min((c[0]-0)*d.RedMultTerm/256+d.RedAddTerm,255)),e=Math.max(0,Math.min(e*d.GreenMultTerm/256+d.GreenAddTerm,255)),f=Math.max(0,Math.min(f*d.BlueMultTerm/256+d.BlueAddTerm,255)),c=parseInt(c),e=parseInt(e),f=parseInt(f);return[c,e,f]}return function(b,d){var c=b.getAttribute("type");if(c=="shape"||c=="text")for(var c=b.firstChild.nextSibling,e=0,f=c.childNodes.length;e<
f;e++){var g=c.childNodes[e],o=d,k=g.hasAttribute("stroke")?"stroke":"fill",i=g.getAttribute(k);if(i)switch(i.match(/^\S{3}/)[0]){case "rgb":g.oriC=g.oriC||i;i=a(g.oriC,o);g.setAttribute(k,"rgb("+i[0]+","+i[1]+","+i[2]+")");break;case "url":var h=i,i=g,g=h.match(/url\(#([^(]+)\)/)[1],h=g.indexOf("f");h!==0&&(g=g.substr(h));h=document.getElementById(g);if(h.nodeName!="pattern"){var j=i.parentNode.previousSibling,g=i.parentNode.parentNode.getAttribute("id")+g;if(document.getElementById(g))var l=document.getElementById(g);
else l=h.cloneNode(!0),l.setAttribute("id",g),j.appendChild(l);for(var j=h.childNodes,l=l.childNodes,m=0,p=j.length;m<p;m++)h=j[m].getAttribute("stop-color"),h=a(h,o),l[m].setAttribute("stop-color","rgb("+h[0]+","+h[1]+","+h[2]+")");i.setAttribute(k,"url(#"+g+")")}}}else if(c=="sprite"){c=b.firstChild.nextSibling.childNodes;e=0;for(f=c.length;e<f;e++)this.colorTransform(c[e],d)}}}();
st.start=function(){st.setBackground(st.root);var a=document.createElementNS(st.nsText,"g");a.setAttribute("id","0");a.appendChild(document.createElementNS(st.nsText,"defs"));a.appendChild(document.createElementNS(st.nsText,"g"));st.root.appendChild(a);var b=new st.sprite(data.MainFrame,a);st.interval=setInterval(function(){b.showFrame()},st.interval)};
st.setBackground=function(a){var b=document.createElementNS(st.nsText,"rect"),d={x:data.FrameRect.xmin,y:data.FrameRect.ymin,width:data.FrameWidth,height:data.FrameHeight,fill:data.BackgroundColor},c;for(c in d)b.setAttribute(c,d[c]);a.appendChild(b)};st.init();st.start();
