// price update
eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('u G(){o.1H="";o.1w=F;o.2m="";o.1I=0;o.1J=F}G.2n=0;G.Z=D T();G.J.2J=u(){r a=2o.3i("3j");o.1w=a;G.Z[G.Z.q]=o;a.2p("3k","3l/3m");a.2p("3n","3o-8");a.2p("3p",o.2m);2o.2K("2L").2M(0).3q(a)};G.J.2q=u(){p(o.1w!=F){2o.2K("2L").2M(0).3r(o.1w);o.1w=F;t(i=0;i<G.Z.q;i++){p(o==G.Z[i]){G.Z[i]=G.Z[G.Z.q-1];G.Z.q-=1;z}}}};G.2N=u(){r a=D G();a.1H=""+G.2n;G.2n++;H a};G.1q=u(a){r i;t(i=0;i<G.Z.q;i++){r b=G.Z[i];p((b.1I!=0)&&(a>b.1I)&&(b.1J!=F)){b.1J(b)}}};G.2O=u(a){r i;t(i=0;i<G.Z.q;i++){r b=G.Z[i];p(b.1H==a){H b}}H F};u 1p(a,b,c){o.1i=a;o.W=b.1j();p(c!=F)o.1f=c.1j();M o.1f=F}1p.1K=u(a,b){r c=1x;2P{p(a.1i!=b.1i)z;p(a.W!=b.W)z;p(a.1f==b.1f){c=1y;z}}2Q(0);H c};u 1z(){o.K="";o.1c="";o.1A="";o.1L="";o.1r=0.0;o.1M=0.0;o.1N=0.0;o.1O=0.0;o.1P=0.0;o.1Q=0.0;o.1R=0.0;o.1S=0.0;o.1T="";o.X="U";o.1U="";o.1V=0.0;o.1W=0.0;o.1X=0.0;o.1Y=0.0;o.1Z=0;o.23=0;o.24="";o.25="";o.26="";o.27="";o.1k="";o.x=0;o.1d=0;o.1l="";o.Y=D T()}1z.J.2r=u(a,b){o.1r=a.1r;o.1r=a.1r;o.1M=a.1M;o.1N=a.1N;o.1O=a.1O;o.1P=a.1P;o.1Q=a.1Q;o.1R=a.1R;o.1S=a.1S;o.1T=a.1T;o.X=a.X;o.1U=a.1U;o.1V=a.1V;o.1W=a.1W;o.1X=a.1X;o.1Y=a.1Y;o.1Z=a.1Z;o.23=a.23;o.24=a.24;o.25=a.25;o.26=a.26;o.27=a.27;o.1k=a.1k;o.1d=b;t(r j=0;j<o.Y.q;j++)o.Y[j].28.2R=b};1z.J.2S=u(a){r b=1x;p(a.1i==s.2T){p(o.1L==a.W)b=1y}M p(a.1i==s.2s){p((o.K==a.W)&&(o.1c==a.1f))b=1y}M{p((o.K==a.W)&&(o.1A==a.1f))b=1y}H b};u 2U(a,b){o.29=a;o.2a=b;o.Q=D T();o.2b=0;o.2c=0;o.2R=0}u 2V(a){o.1a=D 1p(a.1i,a.W,a.1f);o.x=0;o.2t=0;o.R=D T();o.1l=""}u 1s(a,b){o.1a=D 1p(a.1i,a.W,a.1f);o.28=b;o.x=1;o.1B=0;o.1b=F}1s.J.3s=u(){p((o.x==0)||(o.x==1))H-1;H o.1B};1s.J.3t=u(){H o.1a};1s.J.3u=u(){p(o.x==1)H F;H o.1b};1s.J.2W=u(a){p(o.x==1)H 1x;p(o.x==2){r b=o.1b;p(b.x==1)H 1x}H 1y};u s(){o.1t=0;o.N=D T();o.L=D T();o.O=D T();o.1d=0;o.V=5*2d;o.2u=o.V*1;o.2v=o.V*12;o.2w=o.V*12;o.2x=o.V*3v;o.2e=0;o.1C=3w;o.1u="3x://3y.3z.3A/3B/3C.3D?"}s.2s=1;s.2T=2;s.2X=3;s.J.2Y=u(a,b,c){r i,j,w,v,E,y;r d=D 1D().1E();t(i=0;i<b.q;i++){E=b[i];p(E.x!=1)1m;p(0==a){r e=0;r f=E.1a;t(j=0;j<c.q;j++){v=c[j];r g;p(E.1l.1j()==v.1l.1j()){e=1;z}}p(0==e){E.x=-2;t(j=0;j<E.R.q;j++){y=E.R[j];y.x=-1;y.1B=-3;y.1b=F}}M{E.x=2;t(j=0;j<o.O.q;j++){p((o.O[j].K==v.K)&&(o.O[j].1c==v.1c)){w=o.O[j];z}}p(j==o.O.q){w=D 1z();w.K=v.K;w.1c=v.1c;w.1A=v.1A;w.1L=v.1L;p(w.1c=="2Z"){p(w.K=="30")w.K="31";p(w.K=="32")w.K="33";p(w.K=="2f")w.K="$2f"}w.x=2;o.O[o.O.q]=w}t(j=0;j<E.R.q;j++){y=E.R[j];y.x=2;y.1b=w;w.Y[w.Y.q]=y}w.2r(v,d)}}M p(-1==a){E.2t++;p(E.2t>=3){E.x=-1;t(j=0;j<E.R.q;j++){y=E.R[j];y.x=-1;y.1B=-2;y.1b=F}}M{E.x=0}}M{E.x=-2;t(j=0;j<E.R.q;j++){y=E.R[j];y.x=-1;y.1B=-1;y.1b=F}}p(E.x!=0){t(j=0;j<o.L.q;j++){p(E==o.L[j]){o.L[j]=o.L[o.L.q-1];o.L.q-=1;z}}}}};s.J.34=u(a,b,c){r i,j,1F;r d,v,1n;p(0==a){1n=D 1D().1E();t(i=b.q-1;i>=0;i--){d=b[i];p(d.x!=1)1m;1F=0;t(j=c.q-1;j>=0;j--){v=c[j];p((d.K.1j()==v.K.1j())&&(d.1c.1j()==v.1c.1j())){1F=1;z}p(d.1c=="2Z"){p(((d.K=="31")&&(v.K=="30"))||((d.K=="33")&&(v.K=="32"))||((d.K=="$2f")&&(v.K=="2f"))){1F=1;z}}}p(0==1F){d.x=-1}M{d.x=2;d.2r(v,1n);p(j!=c.q-1)c[j]=c[c.q-1];c.q-=1}}}M{t(i=0;i<b.q;i++){d=b[i];p(d.x!=1)1m;d.x=-2}}};s.J.2y=u(a,b){r c=0;r d=F;p(b==0){35{d=s.36(a.2z.3E)}37(38){c=-2}}M{c=-1}p(a.39==1)o.2Y(c,a.2A,d);M o.34(c,a.2A,d)};s.36=u(a){r i=0;r b=D T();r c,I,v,1g;t(i=0;i<a.q;i++){c=a[i];I=c.2g("|");v=D 1z();v.K=I[0];v.1c=I[1];v.1A=I[2];v.1r=1e(I[4]);v.1M=1e(I[5]);v.1N=1e(I[6]);v.1O=1e(I[7]);v.1P=1e(I[8]);v.1Q=1e(I[9]);v.1R=1e(I[10]);v.1S=1e(I[11]);v.1T=I[12];v.X=I[13];v.1l=I[14];v.1U=I[15];v.1V=1e(I[16]);1g=I[17].2g(",");v.1W=1e(1g[0]);v.1X=1e(1g[1]);v.1Y=1e(1g[2]);1g=I[18].2g(",");v.1Z=3a(1g[0]);v.23=3a(1g[1]);v.24=I[19];v.25=I[20];1g=I[21].2g(",");v.26=1g[0];v.27=1g[1];v.1k=I[22];b[b.q]=v}H b};s.3b=u(a){a.2q();a.2B.2y(a,-1)};s.3c=u(a){35{r b=a.3F;r c=G.2O(b);c.2z=a;c.2q();c.2B.2y(c,0)}37(38){}};s.J.1G=u(a,b,c){r d=G.2N();d.2B=o;d.39=a;d.2A=c;d.2z=F;d.2m=b+"&3G="+d.1H+"&3H=s.3c";d.1I=D 1D().1E()+4*2d;d.1J=s.3b;d.2J()};s.J.3d=u(){r i,j;r a=D T();r b=D T();r c=D T();r d;p(o.L.q==0)H;t(i=0;i<o.L.q;i++){E=o.L[i];p(0==E.x){S=E.1a;p(S.1i==s.2X){a[a.q]=E}M p(S.1i==s.2s){b[b.q]=E}M{c[c.q]=E}}}p(0!=b.q){i=0;t(;;){r e=0;r f="2C=";r g=D T();t(;i<b.q;i++){g[g.q]=b[i];S=b[i].1a;e++;p(e!=1)f+=",";b[i].1l=S.1f+":"+S.W;f+=S.1f+":"+S.W;p(e==o.1C)z}p(0==e)z;r h=o.1u;h+=f;t(r k=0;k<g.q;k++){g[k].x=1}o.1G(1,h,g)}}p(0!=c.q){i=0;t(;;){r e=0;r f="3I=";r g=D T();t(;i<c.q;i++){g[g.q]=c[i];S=c[i].1a;e++;p(e!=1)f+=",";c[i].1l=S.W;f+=S.W;p(e==o.1C)z}p(0==e)z;r h=o.1u;h+=f;t(r k=0;k<g.q;k++){g[k].x=1}o.1G(1,h,g)}}p(0!=a.q){r l=D T(),2h;r m;t(i=0;i<a.q;i++){S=a[i].1a;m=S.1f;t(j=0;j<l.q;j++){p(l[j][0]==m){2h=l[j][1];2h[2h.q]=a[i];z}}p(j==l.q){l[l.q]=[m,[a[i]]]}}t(j=0;j<l.q;j++){i=0;t(;;){r e=0;r f="3J="+l[j][0]+"&2C=";r g=D T();r n=l[j][1];t(;i<n.q;i++){g[g.q]=n[i];S=n[i].1a;e++;p(e!=1)f+=",";n[i].1l=S.W;f+=S.W;p(e==o.1C)z}p(0==e)z;r h=o.1u;h+=f;t(r k=0;k<g.q;k++){g[k].x=1}o.1G(1,h,g)}}}};s.J.3e=u(){r i=0;r a=o.O,w;r b=D 1D().1E();t(;;){r c=0;r d="2C=";r e=D T();t(;i<a.q;i++){w=a[i];p(w.x==1)1m;p(0!=w.1d){p((w.1k=="3K")||(w.1k=="3L")||(w.1k=="3M")||(w.1k=="3N")){1o=0;p(o.2e==0){p(w.X=="C")1o=1}M{p((w.X=="C")||(w.X=="P")||(w.X=="A")||(w.X=="U"))1o=1}p(1o==1){p((b+o.V)<(w.1d+o.2v))1m}M{p((b+o.V)<(w.1d+o.2u))1m}}M{1o=0;p(o.2e==0){p(w.X=="C")1o=1}M{p((w.X=="C")||(w.X=="P")||(w.X=="A")||(w.X=="U"))1o=1}p(1o==1){p((b+o.V)<(w.1d+o.2x))1m}M{p((b+o.V)<(w.1d+o.2w))1m}}}e[e.q]=w;c++;p(c!=1)d+=",";d+=w.1c+":"+w.K;p(c==o.1C)z}p(0==c)z;r f=o.1u;f+=d;t(r g=0;g<e.q;g++){e[g].x=1}o.1G(2,f,e)}};s.J.3f=u(){r i,j,B,y,2i=1,2j;2P{p(1!=o.1t)z;2i=0;t(i=0;i<o.N.q;i++){B=o.N[i];p((B.2b==1)||(B.2c==1)){2j=1;t(j=0;j<B.Q.q;j++){y=B.Q[j];p(1x==y.2W()){2j=0;z}}p(2j==1){B.2b=0;B.2c=0;B.29(B.2a,B.Q);2i=1;z}}}}2Q(2i)};s.J.1q=u(){r i,1n,3O=0;p(1!=o.1t)H;1n=D 1D().1E();G.1q(1n);o.3d();p((o.1d==0)||((1n-o.1d)>=o.V)){o.1d=1n;o.3e();t(i=0;i<o.N.q;i++){o.N[i].2c=1}}o.3f()};s.J.2D=u(a,b,c){r d=F,y=F;t(i=0;i<o.N.q;i++){d=o.N[i];p((d.29==b)&&(d.2a==c)){t(j=0;j<d.Q.q;j++){y=d.Q[j];p(1p.1K(y.1a,a))z}p(j==d.Q.q)y=F;z}}H y};s.J.2k=u(a,b,c){r d,i,j,B=F,y;t(i=0;i<o.N.q;i++){B=o.N[i];p((B.29==b)&&(B.2a==c)){t(j=0;j<B.Q.q;j++){y=B.Q[j];p(1p.1K(y.1a,a))H[-1,F]}z}}p(i==o.N.q){B=D 2U(b,c);o.N[o.N.q]=B}y=D 1s(a,B);B.Q[B.Q.q]=y;B.2b=1;t(i=0;i<o.O.q;i++){r e=o.O[i];p(e.2S(S)){y.x=2;y.1b=e;e.Y[e.Y.q]=y}}p(i==o.O.q){r f;t(i=0;i<o.L.q;i++){f=o.L[i];p(1p.1K(f.1a,y.1a)){z}}p(i==o.L.q){f=D 2V(a);o.L[o.L.q]=f}y.x=1;y.1b=f;f.R[f.R.q]=y}H[0,y]};s.J.2E=u(a){r i,a,B;p(a.x!=0){p(a.1b!=F){p(a.x==1){r b=a.1b;t(i=0;i<b.R.q;i++){p(b.R[i]==a){b.R[i]=b.R[b.R.q-1];b.R.q-=1;z}}p(b.R.q==0){b.x=0;t(i=0;i<o.L.q;i++){p(b==o.L[i]){o.L[i]=o.L[o.L.q-1];o.L.q-=1;z}}}}M{r c=a.1b;t(i=0;i<c.Y.q;i++){p(c.Y[i]==a){c.Y[i]=c.Y[c.Y.q-1];c.Y.q-=1;z}}p(c.Y.q==0){t(i=0;i<o.O.q;i++){p(c==o.O[i]){o.O[i]=o.O[o.O.q-1];o.O.q-=1;c.x=0;z}}}}a.1b=F}B=a.28;t(i=0;i<B.Q.q;i++){p(a==B.Q[i]){B.Q[i]=B.Q[B.Q.q-1];B.Q.q-=1;z}}p(0==B.Q.q){t(i=0;i<o.N.q;i++){p(B==o.N[i]){o.N[i]=o.N[o.N.q-1];o.N.q-=1;z}}}a.28=F;a.x=0}H};s.J.2F=u(a,b){r c=0;3P(a){2G 1:o.1u=b;z;2G 2:o.V=b[0]*2d;o.2u=o.V*b[1];o.2v=o.V*b[2];o.2w=o.V*b[3];o.2x=o.V*b[4];z;2G 3:o.2e=b;z;3Q:c=-1}H c};s.J.2H=u(){o.1t=0;o.N.q=0;o.L.q=0;o.O.q=0;o.1d=0};s.J.2I=u(){o.1t=1};s.J.2l=u(){o.1t=0};s.3g=D s();s.1v=F;s.1h=u(){H s.3g};s.1q=u(){s.1h().1q()};s.2D=u(a,b,c){H s.1h().2D(a,b,c)};s.2k=u(a,b,c){H s.1h().2k(a,b,c)};s.3R=u(a,b,c){r d=s.1h();t(r i=0;i<a.q;i++){d.2k(a[i],b,c)}};s.2E=u(a){s.1h().2E(a)};s.2F=u(a,b){H s.1h().2F(a,b)};s.2I=u(){p(s.1v==F){s.1h().2I();s.1v=3h.3S(s.1q,2d)}};s.2l=u(){p(s.1v!=F){3h.3T(s.1v);s.1h().2l();s.1v=F}};s.2H=u(){s.2l();s.1h().2H()};', 62, 242, '||||||||||||||||||||||||this|if|length|var|QU|for|function|pSecurityRecord|pSecurity|m_state|pTickQuery|break||pCbObj||new|pTickPendingReq|null|QUWebRequest|return|dataArray|prototype|m_tick|m_TickPendingReqArray|else|m_cbObjArray|m_securityArray||m_tickQueryArray|m_TickQueryArray|szTickId|Array||m_securityRefreshIntervalBase|m_tickId1|m_MarketPhase|m_queryArray|PendingReqestArray|||||||||||m_queryId|m_puSecurity|m_exchange|m_lastRefreshTime|parseFloat|m_tickId2|tempArray|Instance|m_tickIdType|toUpperCase|m_securityType|m_queryStr|continue|curTime|isInCloseStatus|QUSZTickId|TimeCheck|m_lastPrice|QUSZTickQuery|m_running|m_webServerUrl|TimerId|m_scriptObj|false|true|QUSZSecurityRecord|m_region|m_errorNum|m_webServiceSecurityMaxLimit|Date|getTime|iFind|SendRequest|m_id|m_timeExpire|m_pfOnTimeOut|isEqual|m_Pid|m_volume|m_open|m_yestClose|m_dayHigh|m_dayLow|m_52WeekHigh|m_52WeekLow|m_Currency|m_TradeTime|m_ExtHourPrice|m_MidPrice|m_MidHigh|m_MidLow|m_BuyVol||||m_SellVol|m_ActivityTime|m_Timezone|m_Bid|m_Ask|m_pCbObj|m_pfCallBack|m_pvContext|m_havePendingTickQuery|m_needRefreshCb|1000|m_isStatusPAUClose|INDU|split|regionQueryGroup|iLoop|iReady|AddSymbol|Stop|m_fullUrl|ReqestNextID|document|setAttribute|Dispose|UpdatePriceInfo|TICKIDTYPE_TICKANDEXCHANGE|m_failReqCount|m_IntervalStockOpen|m_IntervalStockClose|m_IntervalFundOpen|m_IntervalFundClose|ProcessRequestCbEvent|e_jsonObject|e_pvContext|e_pqu|ticker|GetTickQuery|RemoveSymbol|SetOption|case|Reset|Start|Send|getElementsByTagName|head|item|CreateRequest|FindRequestById|do|while|m_lastSecurityRefreshTime|isMatchTickId|TICKIDTYPE_PID|QUSZCBObj|QUSZTickPendingReq|isPriceInfoReady|TICKIDTYPE_TICKANDREGION|ProcessHttpResponseForTick|IXUS|COMPX|COMP|INX|SPX|ProcessHttpResponseForSecuritys|try|ParseSimpleQuoteResult|catch|ae|e_type|parseInt|ProcessTimeOut|ProcessResponse|TimeCheckSendTickPendingReqs|TimeCheckRefreshSecurity|TimeCheckCbObj|SingleInstance|window|createElement|script|type|text|javascript|charset|utf|src|appendChild|removeChild|getErrorNum|getTickId|getSecurityRecord|60|50|http|quote|morningstar|com|quoteservice|sq|ashx|Results|JsonID|jid|cb|id|reg|E0|ST|FC|FE|iRefresh|switch|default|AddSymbolArray|setInterval|clearInterval'.split('|'), 0, {}));
// auto-complete
// cjacb + hjacb.js, do not shrink variable.
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 6F=40;9 6G=v H();9 2d=10;9 1U=12;9 1w=v H();9 1K=\',\';9 6H=1;9 1V=6I;9 4n=1V*2;m 2A(16){a=16.3e(/^\\s+/,\'\');n a}m 1f(2B,1L){h.2B=2B;h.3f=\'&3f=\'+(v 6J()).6K();h.3g=F.6L("6M").6N(0);h.3h=1L}1f.3i=1;1f.2C.4o=m(){h.1M=F.4p("6O");h.1M.2D("I","6P/6Q");h.1M.2D("6R","6S-8");h.1M.2D("6T",h.2B+h.3f);h.1M.2D("1W",h.3h)};1f.2C.4q=m(){h.3g.6U(h.1M)};1f.2C.4r=m(){h.3g.4s(h.1M)};m 4t(4u,4v,4w,11){h.k=4u;h.3j=4v;h.3k=4w;h.11=11}m 4x(14,W,4y,1W,4z,I,2e,4A,o,19,4B){h.1x=14;h.1N=W;h.1X=4A;h.6V=1W;h.6W=4z;h.1Y=I;h.6X=2e;h.1g=4y;h.4C=o;h.4D=19;h.6Y=4B}m 4E(k,1y){h.4F=k;h.3l=1y}m 17(4G,4H,1O,4I,4J){9 4K="}]";9 4L="[|";9 4M=";";9 2f=4;9 S="";9 3m=4N;9 1P=4G;9 1Z=4H;9 4O=50;9 2E=\'#4P\';9 2F=\'4Q\';9 3n=\':\';9 1h=w;9 1Q=w;9 J=h;9 3o=K;h.2g=4I;9 3p=4J;h.G=0;h.1i=v H(1U);9 1g=\'3q\';9 20=\'3r\';9 21=\'\';h.2G=f;h.2H=\'//6Z.4R.4S\';9 2I=1O;h.3s=h.2H+"/4T/4U.4V?4W=17.3t"+2I+"&4X=j";9 2J=v H(1,2,0);9 22=v H(1,2,0);(m(){9 4Y="17.3t"+2I+" = m(p){J.4Z(p);}";2K(4Y)})();h.3u=m(2L){h.2H=2L;h.3s=h.2H+"/4T/4U.4V?4W=17.3t"+2I+"&4X=j"};h.3v=m(1R,3w,3x){d(1R==f||3w==f||3x==f){n}d(1g!=1R){1g=1R.51();3y(1g){1a\'70\':1a\'3q\':2J=v H(1,2,0);22=v H(1,2,0);1j;1a\'52\':2J=v H(1,0,2);22=v H(1,0,2);1j;3z:22=v H(1,0,2);22=v H(0,1,2);1j}}20=3w.51();21=3x;S=\'\'};m 53(2M){9 k;9 z;9 O=0;1k{z=2M;O=z.54(1K);d(O>=z.q){k=\'\'}r{O++;k=z.1S(O);k=2A(k)}}1l(3A){k=\'\'}n k}m 2N(k){9 2h=v 4E(k,J.1i);d(3p!=f){3p.2O(2h)}r d(J.2g!=f){d(J.G===0){2h.3l=f}d(1z(J.2g=="3B")){9 55=J.2g+\'(2h);\';2K(55)}r{J.2g(2h)}}}h.56=m(2M){9 k=\'\';9 l=w;k=53(2M);k=k.2i();d(k==S){2N(k);n l}d(k.q===0){S="";1A();2N(k);n l}S=k;9 3C=1;9 Z=1g+\'71\'+21;d(1P[Z]!=f&&1z(1P[Z])!="57"){9 1B=1P[Z];N(9 i=0;i<2d;i++){3C=17.3D(k,1B[i]);d(3C===0){J.3E(1B[i]);n l}}}9 1L=\'72\'+1f.3i;1f.3i++;9 23=J.3s+\'&1R=\'+1g+\'&k=\'+73(k)+\'&74=\'+1L+\'&2P=\'+21;9 1b=f;d(h.2G==f){1b=v 1f(23,1L)}r{1b=v 1f(h.2G(23),1L)}1b.4o();1w[1w.q]=1b;1b.4r();n l};m 1A(){N(9 i=0;i<1U;i++){J.1i[i]=f}J.G=0}J.3E=m(u){1k{1A();d(u!=f){2Q(S,u)}2N(S)}1l(e){58(e)}};m 2Q(k,u){d(u.11==f){n}9 D=u.11.q;d(D==0){n}9 1C="";9 59="";N(9 i=0;i<D;i++){2R(k,u.11[i]);d(J.G>=1U){1j}}}m 5a(k,1m,I){9 l=v H(3);l[0]=-1;l[1]=\'\';l[2]=\'\';d(1m.q===0){n l}9 D=1m.q;9 o=-1;d(D>=3){5b(k,1m,I,l)}n l}m 5b(k,1m,I,P){9 2S;9 2j=\'\';9 o=-1;9 2k=-1;9 1D=3F;9 2l=3F;9 i,T;d(I==\'5c\'||I==\'3G\'||I==\'5d\'||I==\'5e\'){2S=2J}r{2S=22}N(i=0;i<3;i++){9 2m=1m[2S[i]];T=2m.2i();d(2m!==\'\'){d(2j===\'\'){2j=2m}o=T.1n(k,0);d(o>=0){d((o==0&&o<1D)||(T.q<2l)){P[1]=2m;2l=T.q;1D=o;2k=i}}}}9 D=1m.q;N(i=3;i<D;i++){T=1m[i].2i();o=T.1n(k,0);d(o>=0){d((o==0&&o<1D)||(T.q<2l)){P[2]=1m[i];2l=T.q;1D=o;2k=i;75=K}}}d(2k>2){P[1]=2j}d(1D<3F){d(2k<3)P[0]=1D;r P[0]=1D+1V}r{P[0]=-1;P[1]=2j}}m 2R(k,E){9 l="";9 U=E.2n(4L);9 24=w;9 T;9 o;9 5f=7;9 5g=6;9 5h=7;9 76=1;9 77=2;9 5i=5;9 3H=3;9 78=w;9 14=\'\';9 2T=\'\';9 19=\'\';d(U.q>=5f){9 1E=U[5g].2n(4M);9 3I=U[5h];9 2o=5a(k,1E,U[3H]);d(2o[0]>=0){24=K;o=2o[0]}14=2o[1];19=2o[2];d(1g==\'3q\'&&14!=1E[1]){d(19==\'\'){19=14}d(1E[1]==\'\'){14=U[0]}r 14=1E[1];o+=1V}1E=1E.79(0,3);d(!24){9 P=5j(k,20,3I);d(P[0]>=0){24=K;o=P[0]+4n;2T=P[1]}}r{2T=5k(20,3I)}d(24){d(14===\'\'){d(19===\'\'||U[2]==\'52\'){14=U[0]}r{14=19;19=\'\'}}9 2e=U[5i];9 I=U[3H];d(I==\'3G\'||I==\'5d\'||I==\'5e\'){2e+=(\',\'+U[0])}J.1i[J.G]=v 4x(14,2T,U[2],U[0],U[4],I,2e,U[1],o,19,1E);J.G++}}n l}h.5l=m(P){9 u;9 1o=P.2n(4K);u=v 4t("",0,\'K\',f);d(1o.q>=2f){u.k=1o[0];9 5m=1o[1];u.3j=1o[2];u.3k=1o[3];u.11=f;9 D=1o.q-2f;d(D>0){u.11=v H(D);N(9 i=2f;i<1o.q;i++){u.11[i-2f]=1o[i]}}9 Z=5m;d(u.11!=f){d(1P[Z]==f){1P[Z]=17.5n();1Z[Z]=0}9 1B=1P[Z];1B[1Z[Z]]=u;1Z[Z]++;d(1Z[Z]==2d){1Z[Z]=0}}9 5o=17.3D(S,u);d(5o===0){J.3E(u)}}};1A()}17.2C.4Z=m(5p){9 2U=5p.7a;d(2U.P.q>0){h.5l(2U.P)}9 1b=f;N(9 i=0;i<1w.q;i++){d(1w[i]!=f){d(1w[i].3h==2U.1L){1b=1w[i];1j}}}d(1b!=f){1w.7b(i,1);1b.4q()}};17.3D=m(k,u){9 o;d(u==f){n 1}d(k.q>=u.k.q){d(k==u.k){n 0}o=k.1n(u.k);d(o===0){d(u.3k==1){n 0}n 1}n 1}r{d(k.q<u.3j){n 1}o=u.k.1n(k);d(o===0){n 0}n 1}};17.5n=m(){9 1B=v H(2d);N(9 c=0;c<2d;c++){1B[c]=f}n 1B};m 5q(5r,16){h.3J=5r;h.3K=16}m 3L(1c){9 5s=\';\';9 5t=\'[\';9 l=v H();9 3M=1c.2n(5s);9 D=3M.q;N(9 i=0;i<D;i++){9 X=3M[i].2n(5t);d(X.q==2){9 5u=v 5q(X[0],X[1]);l.7c(5u)}}n l}m 5k(15,2V){9 2W=\'3r\';9 25=2p(15);9 1F=f;9 1G=f;9 1H=f;9 1c=3L(2V);9 D=1c.q;N(9 i=0;i<D;i++){9 1d=1c[i].3J;9 W=1c[i].3K;d(1d==15){n W}r d(1d==25){1F=W}r d(1d==2W){1H=W}r{9 2X=2p(1d);d(2X==25){1G=W}}}d(1F!=f){n 1F}d(1G!=f){n 1G}d(1H!=f){n 1H}n\'\'}m 5j(k,15,2V){9 2W=\'3r\';9 25=2p(15);9 24=w;9 7d=\'\';9 1F=f;9 1G=f;9 1H=f;9 3N=-1;9 3O=-1;9 3P=-1;9 l=v H(2);l[0]=-1;l[1]=\'\';9 1c=3L(2V);9 D=1c.q;N(9 i=0;i<D;i++){9 1d=1c[i].3J;9 W=1c[i].3K;9 X=5v(k,W);d(X[0]<0){7e}d(1d==15){l[0]=X[0];l[1]=X[1];n l}r d(1d==25){3N=X[0];1F=X[1]}r d(1d==2W){3P=X[0];1H=X[1]}r{9 2X=2p(1d);d(2X==25){3O=X[0];1G=X[1]}}}d(1F!=f){l[0]=3N;l[1]=1F}r d(1G!=f){l[0]=3O;l[1]=1G}r d(1H!=f){l[0]=3P;l[1]=1H}n l}m 5v(k,W){9 l=v H(2);l[0]=-1;l[1]=\'\';9 o;d(W!=f){T=W.2i();o=T.1n(k,0);d(o<0){T=T.3e(/\\./g,\'\');o=T.1n(k,0);d(o>=0){l[1]=W.3e(/\\./g,\'\')}}r{l[0]=o;l[1]=W}n l}}m 2p(15){d(15.q==2){n 15}d(15.q<2){n\'\'}9 l=15.1S(0,2);d(l==\'26\'){3y(15){1a"26-7f":1a"26-7g":1a"26-7h":l=\'26-7i\';1j;3z:l=\'26-7j\';1j}}n l}9 2Y=w;9 2Z=w;9 5w=w;9 1i=v H(1U);9 1K=\',\';9 3n=\':\';m 7k(3Q,30){N(9 i=0;i<3Q.q;i++){3Q[i]=f;30[i]=0}}m 7l(){9 27=7m.7n;d(27!=f){9 O=27.1n("7o/");d(O>0){2Z=K;9 5x=27.1S(O+12,3);d(5x<7p){2Y=K}}r{O=27.1n("7q 7r");d(O>0){O=27.1n("7s");d(O>0){5w=K}}}}}m V(3R,5y,31,5z,30,5A){9 3m=4N;9 4O=50;9 2E=\'#4P\';9 2F=\'4Q\';9 1h=w;9 1Q=w;9 G=0;9 B=-1;9 S=\'\';9 28="7t";9 3S=28.q;9 32=f;9 33=3R;9 t=h;9 3o=K;9 3T=\'7u://3U.4R.4S/3U/3U.7v?7w=\';9 5B={\'3V\':\'3V\',\'7x\':\'3V\',\'7y\':\'5C\',\'7z\':\'5C\',\'7A\':\'5D\',\'7B\':\'5D\',\'7C\':\'5E\',\'7D\':\'5E\',\'3W\':\'3W\',\'7E\':\'3W\',\'7F\':\'7G\',\'7H\':\'5F\',\'7I\':\'5F\',\'3X\':\'3X 5G\',\'7J\':\'3X 5G\',\'7K\':\'7L\',\'7M\':\'34 3Y\',\'7N\':\'34 5H\',\'7O\':\'34 35\',\'7P\':\'34 7Q\',\'5I\':\'5I 3Y\',\'7R\':\'7S\',\'7T\':\'7U 7V\',\'5J\':\'5J 5K\',\'5L\':\'5L 35\',\'5M\':\'5M 35\',\'5N\':\'5N 5H\',\'5O\':\'5O 35\',\'7W\':\'7X 7Y\',\'5P\':\'5P 5K\',\'7Z\':\'80\',\'5Q\':\'5Q 3Y\',\'81\':\'82\',\'83\':\'84\',\'85\':\'5R\',\'5S\':\'5S 5R\',\'86\':\'87\',\'88\':\'89\',\'8a\':\'8b\',\'5T\':\'5U\',\'5V\':\'5U (8c)\',\'5c\':\'8d\',\'5W\':\'8e\',\'3G\':\'8f\',\'8g\':\'8h\'};9 36=5B;h.8i=m(37){d(37!=f){9 k;N(k 8j 37){36[k]=37[k]}}};d(31!=f&&31.q!==0){3T=31}h.1p=3R;h.5X=5y;h.5Y=5A;h.2q=f;h.2r=f;h.2s=f;h.5Z=\'#8k\';h.60=\'#8l\';h.3Z=f;h.61=\'\';h.62=w;h.63=w;9 1T=v 17(5z,30,33,f,h);h.3u=m(2L){d(1T!==f){1T.3u(2L)}};h.8m=m(64){d(1T!==f){1T.2G=64}};m 65(33){1k{9 A=F.Y(33);V.1I(A,"8n",66);V.1I(A,"8o",t.67);V.1I(A,"8p",68);V.1I(A,"69",6a);d(32!=f){V.1I(F.Y(32),"8q",t.39)}}1l(3A){}}m 6a(){9 A=F.Y(t.1p);d(t.2s!=f){d(A!=f){d(A.18==t.2s){A.18=\'\'}}}d(A!=f){A.Q.1q=t.60}}h.67=m(){9 k=\'\';9 l=w;d(1h){1h=w;n l}d(1Q){1Q=w;n l}9 A=F.Y(t.1p);k=A.18;k=k.2i();d(k==S){n l}d(k.q===0){S="";t.2O(f);B=-1;n l}S=k;1T.56(k);n l};m 68(8r){6b.8s(29,3m);9 A=F.Y(t.1p);d(A!=f){A.Q.1q=t.5Z;d(t.2s!=f){9 2t=A.18;d(2t!=f){2t=2A(2t)}d(2t.q===0){A.18=t.2s}}}}m 66(2u){9 l=K;9 6c=(6b.8t)?2u.8u:2u.6d?2u.6d:2u.8v;1h=w;1Q=w;3y(6c){1a 13:d(32==f){t.39();1h=K;n w}n l;1a 38:t.41(-1);l=w;1h=K;d(2Y){1Q=K}n l;1a 40:t.41(1);l=w;1h=K;d(2Y){1Q=K}n l;1a 8w:1h=K;l=K;n l;3z:1j}n l}h.41=m(42){9 R=B;d(42>0){R++}r d(42<0){R--}d(R<0){d(B==-1){R=G-1}r{R=-1}}r d(R>=G){d(B==G-1){R=-1}r{R=0}}43(28+R)();44(R);d(2Z){6e(1p)}};m 44(R){9 z;9 O=0;9 1r=\'\';9 3a=(t.63)?\'\':1K;1k{9 A=F.Y(t.1p);z=A.18;z=45(z);O=z.54(1K);d(O>0){1r=z.1S(0,O)+1K}d(R==-1){z=1r+S;A.18=z}r d(R>=0&&R<G){9 L=1i[R];d(L.1x!=f&&L.1x.q>0){d(L.1X!==\'\'&&L.1g!=t.61){z=1r+L.1X+3n+L.1x+3a}r{z=1r+L.1x+3a}A.18=z}r d(L.1N!=f&&L.1N.q>0){z=1r+L.1N+3a;A.18=z}}}1l(3A){}}m 45(z){d(z==f){n f}d(z.q>0){9 o=z.q-1;d(z.8x(o)==1K){z=z.1S(0,o)}}n z}m 29(){d(S.q!==0){S="";t.2O(f)}}m 1A(){N(9 i=0;i<1U;i++){1i[i]=f}G=0}h.2O=m(u){9 1e=f;1k{1e=F.Y(t.5X);d(1e!=f){d(u==f){1e.46="";B=-1;d(G>0){1A()}}r{1A();B=-1;1e.46=2Q(u.4F,u.3l)}d(1e.46.q===0){1e.Q.6f=\'6g\';d(1z 6h==\'m\'){6h()}}r{d(1z 6i==\'m\'){6i()}d(t.5Y){9 3b=F.Y(t.1p);d(3b!=f){9 47=V.6j(3b);1e.Q.48=47[0]+\'6k\';1e.Q.6l=47[1]+2+3b.8y+\'6k\'}}1e.Q.6f=\'8z\';B=-1;N(9 i=0;i<G;i++){9 2v=28+i;V.1I(F.Y(2v),"8A",43(2v));V.1I(F.Y(2v),"49",6m(2v))}}}}1l(e){58(e)}};m 2Q(k,1y){9 1s="";9 D=0;d(1y==f){n 1s}D=1y.q;d(D===0){n 1s}9 1C="";9 59="";N(9 i=0;i<D;i++){d(1y[i]!=f){1C+=2R(k,28+i,1y[i]);6n(1y[i])}}d(1C.q>0){d(t.3Z!=f){1C+="<2a><C 8B=3 1t=\'1u\' Q=\'4a: 6o 4b 4b 4b;1q:4c;\'><a 4d=\'"+t.3Z+k+"\'>8C 8D N \\""+k+"\\" ...</a></C></2a>"}1s+="<3c 6p=8E><2a><C Q=\'6p-Q:6g; 4a: 6o 6q 8F 6q;\'><3c 1t=\'1u\'>"+1C+"</3c></C></2a></3c>"}n 1s}m 2R(k,1W,E){9 l="";9 6r=1W;l="<2a 1W=\'"+6r+"\' >";d(E==f){n l}9 2w=\'\';9 o=E.4C;9 4e=8G.8H(o/1V);o=o%1V;d(4e===0){l+=V.3d(E.1x,k,o,2w,w);l+="<C></C>";l+="<C 1t=\'1u\'>"+E.1N+"</C>"}r d(4e==1){l+="<C 1t=\'1u\'>"+2w+E.1x+"</C>";l+=V.3d(E.4D,k,o,2w,K);l+="<C 1t=\'1u\'>"+E.1N+"</C>"}r{l+="<C 1t=\'1u\'>"+2w+E.1x+"</C>";l+="<C></C>";l+=V.3d(E.1N,k,o,\'\',w)}9 1v=\'\';d(E.1Y==\'5T\'||E.1Y==\'5V\'||E.1Y==\'5W\'){1v=36[E.1Y];d(1v==f){1v=E.1Y}}r d(E.1X!=f){1v=36[E.1X];d(1v==f){1v=E.1X}}9 4f=\'\';d(1v.q>0){4f=\'4a-48:6;\'}l+="<C 1t=\'1u\'"+"8I=8J Q=\'1q:4c;"+4f+"\' >"+1v+"</C>";l+="</2a>";n l}m 6n(11){1i[G]=11;G++}m 6m(1O){n m(){9 2b=1O.1S(3S);B=2b;t.39()}}m 43(1O){n m(){9 L;9 2b=1O.1S(3S);d(2b!=B&&B>=0&&B<G){9 4g=F.Y(28+B);d(4g!=f){4g.Q.6s=2F}}d(2b>=0){L=F.Y(1O);d(L!=f){L.Q.6s=2E}}B=2b}}h.39=m(){d(B<0&&t.62&&G>=0){B=0}d(B>=0&&B<G){44(B);d(t.2r!=f){9 L=1i[B];d(1z(t.2r)=="3B"){9 6t=t.2r+\'(L)\';29();1k{2K(6t)}1l(e){}}r{1k{t.2r(L)}1l(e){}}29();n w}}r{B=-1}9 4h=F.Y(t.1p);d(4h!=f){9 2c=4h.18;2c=45(2c);d(2c!=f){9 16=2A(2c);d(16!=\'\'){6u(3T,2c)}}}29();n w};m 6u(6v,1s){d(t.2q!=f){d(1z(t.2q)=="3B"){9 1C=t.2q+"(\'"+1s+"\')";1k{2K(1C)}1l(e){}}r{1k{t.2q(1s)}1l(e){}}29()}r{6w(6v+8K(1s))}}m 6w(23){9 2x=F.4p("a");d(1z(2x.49)==\'57\'){8L.4d=23}r{2x.4d=23;F.6x.4s(2x);2x.49()}}h.8M=m(1q){2E=1q};h.8N=m(1q){2F=1q};h.8O=m(6y){3o=6y};h.3v=m(1R,20,21){1T.3v(1R,20,21)};1A();65(t.1p)}V.1I=m(M,I,4i){d(M.6z){M.6z("8P"+I,4i)}r d(M.6A){M.6A(I,4i,w)}};V.6j=m(M){9 2y=2z=0;d(2Z&&1z(M.4j)===\'m\'){2y=M.4j().48;2z=F.6x.8Q+M.4j().6l}r{d(M.4k){8R(1){2y+=M.8S;2z+=M.8T;d(!M.4k){1j}M=M.4k}}r d(M.x){2y=M.x;2z=M.y}}n[2y,2z]};V.3d=m(16,k,o,6B,6C){9 1r=6B;9 4l="";d(o>0){1r+=16.4m(0,o)}d(o+k.q<16.q){4l=16.4m(o+k.q)}9 Q="<C 1t=\'1u\'>";d(6C){Q="<C 1t=\'1u\' Q=\'1q:4c;\'>"}9 l=Q+1r+"<b>"+16.4m(o,o+k.q)+"</b>"+4l+"</C>";n l};m 6e(6D){9 1J=F.Y(6D);d(1J==f){n}9 o=1J.18.q;d(1J.6E){9 2P=1J.6E();2P.8U("8V",o);2P.8W()}r d(1J.8X){1J.69();1J.8Y(o,o)}}',62,557,'|||||||||var||||if||null||this|||key|ret|function|return|pos||length|else||self|record|new|false|||wholekey|input_box|SelectedIndex|td|size|row|document|NumShownEntries|Array|type|ac_self|true|entry|pElement|for|start|result|style|idx|Current_Value|tmp|cells|AutoCompleteBox|name|fields|getElementById|sc_str||data|||symbol|lang|str|AutoCompleteOracle|value|key2|case|Req|allNames|cul|dropdown|JSONscriptRequest|Region|IgnoreFuncKey|ShownEntries|break|try|catch|symbols|indexOf|rows|ACINPUT_ID|color|prefix|content|class|ACDropDownStyle|exch_display|JRequests|Symbol|values|typeof|resetShownEntries|Cache|tmpstr|match_pos|all_symbols|parent_result|sibling_result|default_result|addListener|obj|KEY_DELIMITER|jsid|scriptObj|Name|myID|AllCache|IgnoreAppleArrowKey|reg|substr|Oracle|MAX_SHOWN|IDX_BASE|id|Exchange|Type|NextCachePos|PreferredLanguage|SecurityType|LocalOtherSymbolPref|url|found_match|my_parent|ZH|agent|DataPrefix|delayedHideDropDown|tr|sid|line|CACHE_SIZE|info|HEADER_ROWS|DisplayCallback|callback_result|toLowerCase|backup|match_idx|match_length|cur_symbol|split|key_result|GetParentCulture|SubmitCallback|EntryChosenCallback|IdleDisplayMsg|tmp_str|kp|trId|exch_prefix|fakeLink|curleft|curtop|leftTrim|fullUrl|prototype|setAttribute|ENTRY_SELECT_COLOR|ENTRY_COLOR|ProxyWrap|ACQ_SERVER|boxID|LocalStockSymbolPref|eval|server|myKey|SendResult|ProcessResult|range|generateContentFromRecord|generateContentForRow|idxes|final_name|jdata|allNameStr|default_lang|tmp_parent|DoubleEvtForArrow|UseAppleWebKit|MyNextCachePos|MyQuoteServer|FormId|boxId|Euronext|Brussels|myDictionary|dict||trySubmit|end|txt_box|table|generateMatchTd|replace|noCacheIE|headLoc|scriptId|scriptCounter|startPos|isLeaf|Values|HIDE_DELAY_MS|EXCH_DELIMITER|IsSubmit|Owner|USA|EN|ACQHandlerURL|FCallBack|SetACQServer|SetPreference|language|sec_type|switch|default|ae|string|cache_hit|isRecordHit|displayRecord|4096|ST|TYPE_POS|names|Culture|Data|MakeNameArrayWithLanguage|tmp_names|parent_pos|sibling_pos|default_pos|m_cache|InputBoxId|DPLen|QUOTE_SERVER|quote|NYSE|OTC|TSX|Paris|ShowAll||moveArrow|delta|ACDSelectEntry|replaceCurrentKey|removeLastDelimiter|innerHTML|coords|left|click|padding|0px|gray|href|match_col|width_str|cur_entry|quoteInput|fn|getBoundingClientRect|offsetParent|suffix|substring|NAME_IDX_BASE|buildScriptTag|createElement|removeScriptTag|addScriptTag|appendChild|Record|rkey|rpos|leaf|DataEntry|region|cfid|exchange|primaryKeys|MatchPos|Key2|ACQResult|Key|myCache|myCachePos|myDisplayCallback|myOwner|ACQ_ROW_DELIMITER|ACQ_COL_DELIMITER|ACQ_SYMBOL_DELIMITER|200|REFOCUS_DELAY_MS|B1D9F0|white|morningstar|com|gidindex|acq|ashx|callback|out|funcString|j_callback||toUpperCase|CHN|getCurrentKey|lastIndexOf|funcstr|SendQuery|undefined|alert|partial|checkKeyMatch|checkAllKeys|FE|E0|E1|MAX_MATCH_IDX|SYMBOL_POS|NAME_POS|INFO_POS|FindMatchingName|FindName|processResult|sc|createCacheForScope|hit|resultset|StringWithCulture|culture|NAME_DELIMITER|FIELD_DELIMITER|swc|searchKeyInName|FireFoxOnMac|awk_ver|DropdownId|MyCache|useAutoPosition|defaultDictionary|Nasdaq|Amex|OTCBB|Toronto|Venture|Lisbon|XMLI|ALXA|Amsterdam|TNLB|ALXB|WQXL|MLXB|TNLA|ALXP|Madrid|XLAT|FO|Fund|FC|XI|ACDROPDOWN_ID|AutoPosition|IdleMsgColor|FocusMsgColor|LocalRegion|AlwaysTryFirstResult|SuppressAutoDelimiter|proxy|initInputBox|checkFuncKey|j_sendQuery|loseFocus|focus|getFocus|window|keyID|which|setCaretToEnd|display|none|showalldrops|hidealldrops|findPosition|px|top|clickEntry|AddNewShownEntry|9px|border|5px|myid|backgroundColor|func_str|commonSearch|actionURL|navigateWithReferrer|body|isSub|attachEvent|addEventListener|exch|secondary|objid|createTextRange|SCOPE_SIZE|ExchDisplayArray|LOCAL_SYMBOL_TICKER_POS|1024|Date|getTime|getElementsByTagName|head|item|script|text|javascript|charset|utf|src|removeChild|ID|CFID|Info|PrimaryKeys|qt|CAN|_|JD|encodeURIComponent|js|match|EXCH_POS|REGION_POS|replaced|slice|ResultSet|splice|push|cur_match_name|continue|TW|HK|MO|HANT|HANS|initCache|CheckOSBrowser|navigator|userAgent|AppleWebKit|500|Mac|OS|Firefox|ACDEntry_|http|aspx|ticker|XNYS|NAS|XNAS|ASE|XASE|OTUS|XOTC|PINX|XLON|LSE|TSE|XTSE|XTSX|XETR|Xetra|XPAR|XLIS|XBRU|XAMS|Amesterdam|XSWX|SWX|XHKG|Hong|Kong|IXUS|US|Indices|XMOD|Montreal|XFRA|Frankfurt|XMIL|Milan|XMCE|XSHG|Shanghai|XSHE|Shenzhen|XSIM|Singapore|CEF|ETF|Index|Stock|BD|Bond|UpdateDictionary|in|CCCCCC|333333|SetProxyWrap|keydown|keyup|blur|submit|ev|setTimeout|event|keyCode|charCode|188|charAt|offsetHeight|block|mouseover|colspan|more|results|1px|7px|Math|floor|align|right|escape|location|set_ENTRY_SELECT_COLOR|set_ENTRY_COLOR|set_IsSubmit|on|scrollTop|while|offsetLeft|offsetTop|move|character|select|selectionStart|setSelectionRange'.split('|'),0,{}))


function initBoxQuote(d, b) {
	CheckOSBrowser();
	var f = new Array();
	var e = new Array();
	initCache(f, e);
	var c = "http://quote.morningstar.com/switch.html?ticker=";
	var a = new AutoCompleteBox(d, b, c, f, e, true);
	return a
}
function srchTerm(a) {
	if (a == "search") {
		document.searchForm.SrchTerm.value = document.searchForm.sSrchTerm.value;
		document.searchForm.action = "http://search.morningstar.com/MstarSrch/MstarSrch2.aspx";
		document.searchForm.submit()
	} else {
		if (a == "searchFooter") {
			document.searchFormFooter.SrchTerm.value = document.searchFormFooter.sSrchTerm.value;
			document.searchFormFooter.action = "http://search.morningstar.com/MstarSrch/MstarSrch2.aspx";
			document.searchFormFooter.submit()
		}
	}
}
function ClearSearchBox(a) {
	if (a == "search") {
		document.searchForm.sSrchTerm.color = "#FFFFFF";
		document.searchForm.sSrchTerm.value = ""
	} else {
		document.searchFormFooter.sSrchTerm.color = "#FFFFFF";
		document.searchFormFooter.sSrchTerm.value = ""
	}
}
function GetXmlHttpObject() {
	var a = null;
	try {
		a = new XMLHttpRequest()
	} catch (b) {
		try {
			a = new ActiveXObject("Msxml2.XMLHTTP")
		} catch (b) {
			a = new ActiveXObject("Microsoft.XMLHTTP")
		}
	}
	return a
}
function getSiteFooter(d, c) {
	var b = GetXmlHttpObject();
	if (b == null) {
		alert("Your browser does not support AJAX!");
		return
	}
	var a = contextPath + "/trading/footer-sitemap.action?site=" + d;
	b.open("GET", a, true);
	b.onreadystatechange = function() {
		if (b.readyState == 4) {
			var e = b.responseText;
			if (d == "siteDirectoryContent") {
				var f = document.getElementById("siteDirectoryContent")
			} else {
				if (d == "siteMapContent") {
					var f = document.getElementById("siteMapContent")
				} else {
					if (d == "productsContent") {
						var f = document.getElementById("productsContent")
					}
				}
			}
			f.innerHTML = e
		}
	};
	b.send(null);
	swapout(d, c)
}
function swapout(b, a) {
	idlookup(b);
	activate(a)
}
var linkIDs = new Array("nav1", "nav2", "nav3");
function turnofflinks(a) {
	document.getElementById(a).className = "f_sdirtab"
}
function offalllinks() {
	for ( var a = 0; a < linkIDs.length; a++) {
		turnofflinks(linkIDs[a])
	}
}
function activate(a) {
	if (a.className == "f_sdirtab") {
		offalllinks(a);
		a.className = "f_sdirtabOn"
	}
}
function idlookup(a) {
	if (document.getElementById(a).style.display != "block") {
		doton(a)
	}
}
function turnoffimages(a) {
	document.getElementById(a).style.display = "none"
}
function offallimages() {
	for ( var a = 0; a < imageIDs.length; a++) {
		turnoffimages(imageIDs[a])
	}
}
function doton(a) {
	offallimages();
	document.getElementById(a).style.display = "block"
}
function turnon(b) {
	for ( var a = 1; a <= 12; a++) {
		document.getElementById("Tabmenu" + a).className = "sdir_menu";
		document.getElementById("menu" + a).style.display = "none"
	}
	document.getElementById("Tab" + b).className = "sdir_menuOn";
	document.getElementById(b).style.display = "block"
}
function showDropdown(a, b) {
	if (b == null) {
		b = document.ulEle
	}
	var c = b.getElementsByTagName("UL")[0].style.display;
	if (c == "none" || c == "") {
		b.style.position = "relative";
		b.getElementsByTagName("UL")[0].style.display = "block";
		if (b.setCapture) {
			b.setCapture(false)
		} else {
			document.addEventListener("click", showDropdown, true);
			window.captureEvents(Event.CLICK)
		}
		document.ulEle = b
	} else {
		b.style.position = "";
		b.getElementsByTagName("UL")[0].style.display = "none";
		if (b.setCapture) {
			b.releaseCapture()
		} else {
			document.removeEventListener("click", showDropdown, true);
			window.releaseEvents(Event.CLICK);
			a.cancelBubble = true
		}
	}
}
function GHF_Nav(c, b) {
	var a = document.getElementById("MH_tab" + c);
	if (a != null) {
		a.className += "On"
	}
}
function FFQTRedirect() {
	var a = document.ffqtlist.ffqtselect.options[document.ffqtlist.ffqtselect.selectedIndex].value;
	if ((a != "^") && (a != "")) {
		window.location = a
	}
}
String.prototype.Trim = function() {
	return this.replace(/^\s*|\s*$/g, "")
};
Array.prototype.contains = function(b) {
	for ( var a = 0; a < this.length; a++) {
		if (b.Trim().toUpperCase() == this[a].Trim().toUpperCase()) {
			return true
		}
	}
	return false
};
Array.prototype.unique = function() {
	var a = [];
	for ( var b = 0; b < this.length; b++) {
		if (!a.contains(this[b])) {
			a.push(this[b])
		}
	}
	return a
};
function readWSCookie(f) {
	var a = f + "=";
	var d = document.cookie.split(";");
	for ( var b = 0; b < d.length; b++) {
		var e = d[b];
		while (e.charAt(0) == " ") {
			e = e.substring(1, e.length)
		}
		if (e.indexOf(a) == 0) {
			return unescape(e.substring(a.length, e.length))
		}
	}
	return null
}
function setMSCookie(a, b) {
	var c = new Date();
	c.setTime(c.getTime() + 365 * 24 * 60 * 60 * 1000);
	document.cookie = a + "=" + escape(b) + "; expires=" + c.toGMTString()
			+ "; path=/; domain=.morningstar.com"
}
function readWSCNameCookie(a) {
	if (window.cName) {
		a = a + escape(window.cName)
	}
	return readWSCookie(a)
}
function setMSCNameCookie(a, b) {
	if (window.cName) {
		a = a + escape(window.cName)
	}
	setMSCookie(a, b)
}
function FindCtrlPosition(d) {
	var a = d;
	var b = 0;
	var c = 0;
	while (a) {
		b += a.offsetTop;
		c += a.offsetLeft;
		a = a.offsetParent
	}
	return {
		top : b,
		left : c
	}
}
function AddJRequest(c) {
	var b = "JD" + JSONscriptRequest.scriptCounter;
	JSONscriptRequest.scriptCounter++;
	c = c + "&JID=" + b;
	var a = new JSONscriptRequest(c, b);
	a.buildScriptTag();
	JRequests[JRequests.length] = a;
	a.addScriptTag()
}
function RemoveJRequestTag(c) {
	var a = null;
	for ( var b = 0; b < JRequests.length; b++) {
		if (JRequests[b] != null) {
			if (c.hasOwnProperty("jsid")) {
				if (JRequests[b].scriptId == c.jsid) {
					a = JRequests[b];
					break
				}
			} else {
				if (c.hasOwnProperty("JsonID")) {
					if (JRequests[b].scriptId == c.JsonID) {
						a = JRequests[b];
						break
					}
				}
			}
		}
	}
	if (a != null) {
		JRequests.splice(b, 1);
		a.removeScriptTag()
	}
}
function EncodeQuote(a) {
	return a.replace(/'/g, "\\'")
}
function TickerTape(c, a, b) {
	this._varName = c;
	this._tickerCountForOnce = 5;
	this._tickersArr = new Array();
	this._marketTickersArr = new Array("COMP", "SPX", "$INDU");
	this._marketTickerNames = new Array("Nasdaq", "S&P 500", "DJIA");
	this._portfolioWebserviceUrl = "http://www.morningstar.com/GetPortfolio";
	this._loginStatus = true;
	this._portfolioTickersArr = new Array();
	this._commodityPricesArr = new Array();
	this._tickerPricesArr = new Array();
	this._mstarCookie = null;
	this.curTickerIndex = 0;
	this._QUSZTickIdArr = new Array();
	this._QUSZcbList = new Array();
	this._isFirstCallBack = false;
	this._zeroOut = false;
	this._dtNow = new Date();
	this._dt6am = new Date(this._dtNow.getFullYear(), this._dtNow.getMonth(),
			this._dtNow.getDate(), 6, 0);
	this._mCommodityState = 1;
	this._mCurrentTime = new Date().getTime();
	this._mScrollUI = '<div class="TickerWrap" id="pricesPanel">            <div  class="TickerTableContain">            <div style="height:24px;width:921px;overflow:hidden;">                <div id="tpc">                    <div id="tcPrices1" style="height:24px;width:921px;"></div>                    <div id="tcPrices2" style="height:24px;width:921px;"></div>                </div>            </div>        </div>       <a class="TTButtEdit" onclick="javascript:'
			+ c
			+ ".HideShowTickerTape('pricesPanel','settingsPanel');\"></a>    </div>";
	this._mEditUI = '<div class="TickerWrap" style="display:none" id="settingsPanel">        <div  class="TickerTableContain2">            <div class="TTControl">                <div class="TTControlText">&nbsp;&nbsp;Display Settings:</div>            </div>            <div class="TTForm1">               <input name="markets" id="markets" type="checkbox" checked />            </div>            <div class="TTControlText">Markets</div>            <div class="TTForm"></div>            <div class="TTForm3">            <div class="menucont_h" style="margin-top:3px;">                    <ul id="nav">                        <li><a href="javascript:void(0);" onclick='
			+ c
			+ '.DropDownPortfolioList(event);return false; " class="headerlink3" id="pfSelect">Select a Portfolio</a><a href="javascript:void(0);" onclick='
			+ c
			+ '.DropDownPortfolioList(event);return false;" class="arrow_h"></a>                        </li>                     </ul>                </div>             </div>             <div class="TTForm" style="z-index:50">                <input name="newTickers" id="newTickers" type="checkbox" />             </div>             <div class="TTForm2"><input name="newTickerInput" id="newTickerInput" type="text" value="Enter Tickers" size="15" class="headerlink2" onclick="if(this.value==\'Enter Tickers\') this.value=\'\';" onkeyup="if(event.keyCode==13 && this.value!=\'\') {'
			+ c
			+ '.SelectNewTicker(this.value);this.value=\'\'}"/></div>              <div class="TTForm">               <input name="rtQuote" id="rtQuote" type="checkbox"/>             </div><div class="TTControlText">Recent Quotes</div>             <div class="TTForm">                <input name="hideTape" id="hideTape" type="checkbox" onclick="this.checked=false;'
			+ c
			+ ".HideTickerButtonClick('pricesPanel','settingsPanel','expandBtnPanel');\"/>              </div><div class=\"TTControlText\">Hide Ticker Tape</div>            </div>            <a class=\"TTButtSave\" href=\"javascript:"
			+ c
			+ '.SaveOptions();"></a>          </div>          <div class="AutoCompleteDropDownQuote" style="position: absolute; float: left; left: 304px; background-color: rgb(255, 255, 255); top: 119px;z-index:1000" id="AutoCompleteDropDownQuote"></div>           <div class="menucont_h" style="margin-top:3px;float: left;font-size:10px; background-color:White; position:absolute;display:none" id="pfDropDownList" onmouseout="this.style.display=\'none\';" onmouseover="this.style.display=\'\';"></div>';
	this._mHiddenUI = '<div id="expandBtnPanel" style="display:none;z-index:500"><a href="javascript:'
			+ this._varName
			+ ".ShowTickerButtonClick('pricesPanel','settingsPanel','expandBtnPanel');\" class=\"TickerExpand\"></a></div>";
	if (b) {
		window.cName = b
	} else {
		window.cName = ""
	}
	if (document.getElementById(a)) {
		document.getElementById(a).innerHTML = this._mScrollUI + this._mEditUI
				+ this._mHiddenUI
	} else {
		document.write("<div id=" + a + "></div>");
		document.getElementById(a).innerHTML = this._mScrollUI + this._mEditUI
				+ this._mEditUI
	}
	this.Init()
}
TickerTape.prototype.Init = function() {
	var c = readWSCNameCookie("hiddenTickerTape");
	if (c) {
		if (c == "1") {
			this.HideTickerButtonClick("pricesPanel", "settingsPanel",
					"expandBtnPanel");
			return
		}
	}
	this._tickersArr = this._GetTickers();
	this._mstarCookie = readWSCookie("mstar");
	this._IsWeekendHoliday();
	this._InitTaperOptions();
	this.GetCommodityPrices(true);
	this._InitPortfolios();
	this._GetPortfolioTickers();
	var a = this._varName + ".GetCommodityPrices()";
	var b = this._varName + ".TweenPrices()";
	setInterval(a, 60000);
	setInterval(b, 6000)
};
TickerTape.prototype._IsWeekendHoliday = function() {
	var a = "http://www.morningstar.com/hpwebservice/GetMarketDay.aspx?cb="
			+ this._varName + "._RenderZeroOut";
	AddJRequest(a)
};
TickerTape.prototype._RenderZeroOut = function(b) {
	if (b == null) {
		return
	}
	var a = b.Results;
	if (this._dtNow < this._dt6am) {
		this._zeroOut = false
	}
	if (a == "False" && this._dtNow > this._dt6am) {
		this._zeroOut = true
	}
	RemoveJRequestTag(b)
};
TickerTape.prototype._InitPrices = function() {
	this.GetPrices(this.UpdateTickerAndLayers);
	this.GetPrices()
};
TickerTape.prototype._InitTaperOptions = function() {
	var d = document.getElementById("markets");
	var c = document.getElementById("newTickers");
	var e = document.getElementById("rtQuote");
	var b = readWSCNameCookie("TickerTapeOptions");
	if (b) {
		var a = b.split(":");
		if (d && a[0] == "1") {
			d.checked = true
		} else {
			d.checked = false
		}
		if (c && a[1] == "1") {
			c.checked = true
		} else {
			c.checked = false
		}
		if (e && a[2] == "1") {
			e.checked = true
		} else {
			e.checked = false
		}
	}
};
TickerTape.prototype.SelectNewTicker = function(j) {
	if (j.Symbol) {
		j = j.Exchange + ":" + j.Symbol
	}
	j = j.replace(/\s/g, "");
	var c = j.split(",");
	var k = 0;
	j = "";
	var e = 0;
	var g = readWSCNameCookie("NewQuotes");
	var h;
	if (!g || g == "") {
		h = "";
		e = 1
	} else {
		h = g
	}
	for ( var d = 0; d < c.length; d++) {
		if (c[d] != "") {
			reg = new RegExp("\\b" + c[d] + "\\b", "gi");
			if (reg.test(h)) {
				continue
			}
			h = h + "," + c[d];
			k++;
			j = j + c[d] + ","
		}
	}
	if (k == 0) {
		document.getElementById("newTickerInput").value = "";
		return
	}
	j = j.substr(0, j.length - 1);
	if (e > 0) {
		h = h.substr(e)
	}
	var a = h.split(",");
	var f = a.length;
	var b = 0;
	while (f > 20) {
		b = h.indexOf(",", b + 1);
		f--
	}
	if (b > 0) {
		h = h.substr(b + 1)
	}
	g = h;
	setMSCNameCookie("NewQuotes", g);
	this._tickersArr = this._GetTickers();
	this.GetPrices()
};
TickerTape.prototype.SaveOptions = function() {
	var e = document.getElementById("markets");
	var d = document.getElementById("newTickers");
	var f = document.getElementById("rtQuote");
	var b = "";
	if (e) {
		if (e.checked) {
			b = "1"
		} else {
			b = "0"
		}
	}
	if (d) {
		if (d.checked) {
			b = b + ":1"
		} else {
			b = b + ":0"
		}
	}
	if (f) {
		if (f.checked) {
			b = b + ":1"
		} else {
			b = b + ":0"
		}
	}
	setMSCNameCookie("TickerTapeOptions", b);
	var c = document.getElementById("newTickerInput");
	if (c != null && c.value != "Enter Tickers" && c.value != "") {
		this.SelectNewTicker(c.value)
	}
	var a = this._varName + ".AfterSaveOptions";
	this._tickersArr = this._GetTickers();
	this.HideTickerTapeSettingsPanel("pricesPanel", "settingsPanel");
	this.GetPrices(this.AfterSaveOptions, true)
};
TickerTape.prototype._GetTickers = function() {
	var d = readWSCNameCookie("TickerTapeOptions");
	if (d) {
		var g = new Array();
		var a = d.split(":");
		if (a[0] == "1") {
			g = g.concat(this._marketTickersArr)
		}
		if (this._mstarCookie != null && this._portfolioTickersArr.length > 0) {
			g = g.concat(this._portfolioTickersArr)
		}
		if (a[1] == "1") {
			var c = readWSCNameCookie("NewQuotes");
			if (c) {
				var b = (c).split(",");
				g = g.concat(b)
			}
		}
		if (a[2] == "1") {
			var f = readWSCookie("RecentQuotes");
			if (f) {
				var e = (f).split("+");
				g = g.concat(e)
			}
		}
		g = g.unique();
		return g
	} else {
		return this._marketTickersArr
	}
};
TickerTape.prototype.RenderPriceLayer = function(c) {
	var a = this.RenderPrices();
	var b = document.getElementById(c);
	if (b) {
		b.innerHTML = a
	}
};
TickerTape.prototype.GetCommodityPrices = function(b) {
	var a;
	var c = new Date();
	c = c.getTime();
	if (b) {
		a = this._portfolioWebserviceUrl + "/GetCommodityQuotes.ashx?cb="
				+ this._varName + ".InitCommodityPrices";
		AddJRequest(a)
	} else {
		if (this._mCommodityState == 1 || (this._mCurrentTime + 120000) < c) {
			this._mCommodityState = 0;
			a = this._portfolioWebserviceUrl + "/GetCommodityQuotes.ashx?cb="
					+ this._varName + ".RenderCommodityPrices";
			AddJRequest(a)
		}
		this._mCurrentTime = c
	}
};
TickerTape.prototype.InitCommodityPrices = function(a) {
	this._commodityPricesArr = a.Results.split(",");
	this._InitPrices();
	RemoveJRequestTag(a)
};
TickerTape.prototype.RenderCommodityPrices = function(a) {
	this._commodityPricesArr = a.Results.split(",");
	this._mCommodityState = 1;
	RemoveJRequestTag(a)
};
TickerTape.prototype._InitPortfolios = function() {
	if (this._mstarCookie != null) {
		var a = this._portfolioWebserviceUrl + "/GetPortfolio.ashx?op=1&cb="
				+ this._varName + "._RenderPortfolioDropDownList";
		AddJRequest(a)
	} else {
		this._loginStatus = false
	}
};
TickerTape.prototype._RenderPortfolioDropDownList = function(c) {
	if (c == null) {
		return
	}
	if (c.Results == "Unlogined") {
		this._loginStatus = false;
		return
	}
	var a = document.getElementById("pfDropDownList");
	var b = "";
	if (a) {
		b = '<ul class="drop_shad_h"><li><a class="rowlist_h" href="javascript:' + this._varName + '.ClearPortfolioCookie()">Clear portfolio tickers</a></li><br />';
		for (i = 0; i < c.Results.length; i++) {
			b += '<li><a class="rowlist_h" href="javascript:void(0)" onclick="'
					+ this._varName + ".SelectPortfolio(" + c.Results[i][1]
					+ ',this.innerHTML)">' + c.Results[i][0]
					+ "</a></li><br />"
		}
		b += "</ul>";
		a.innerHTML = b;
		RemoveJRequestTag(c)
	}
};
TickerTape.prototype.ClearPortfolioCookie = function() {
	var b = document.getElementById("pfDropDownList");
	if (b) {
		b.style.display = "none"
	}
	this._portfolioTickersArr = new Array();
	setMSCNameCookie("NewPortfolios", "");
	var a = document.getElementById("pfSelect");
	if (a) {
		a.innerHTML = "Select a Portfolio"
	}
};
TickerTape.prototype.SelectPortfolio = function(e, d) {
	var a = document.getElementById("pfDropDownList");
	if (a) {
		a.style.display = "none"
	}
	var f = readWSCNameCookie("NewPortfolios");
	var c = new RegExp("\\b" + e + "\\b", "gi");
	if (c.test(f)) {
		return
	} else {
		f = e.toString() + "|" + d
	}
	setMSCNameCookie("NewPortfolios", f);
	this._GetPortfolioTickers();
	this._tickersArr = this._GetTickers();
	this.GetPrices();
	var b = document.getElementById("pfSelect");
	if (b) {
		b.innerHTML = d
	}
};
TickerTape.prototype._GetPortfolioTickers = function() {
	var d = readWSCNameCookie("NewPortfolios");
	var b = document.getElementById("pfSelect");
	if (d == null || d == "" || this._mstarCookie == null) {
		if (b) {
			b.innerHTML = "Select a Portfolio"
		}
		return
	}
	var c = d.split("|");
	if (b) {
		b.innerHTML = c[1]
	}
	var a = this._portfolioWebserviceUrl
			+ "/GetPortfolio.ashx/GetPortfolio.ashx?op=2&&pfIds=" + c[0]
			+ "&cb=" + this._varName + "._RenderPortfolioTickers";
	AddJRequest(a)
};
TickerTape.prototype._RenderPortfolioTickers = function(b) {
	try {
		if (b.Results == "Unlogined") {
			this._loginStatus = false;
			return
		} else {
			this._portfolioTickersArr = b.Results;
			this._tickersArr = this._GetTickers();
			this.GetPrices();
			RemoveJRequestTag(b)
		}
	} catch (a) {
	}
};
TickerTape.prototype.RenderPrices = function() {
	if (this._tickerPricesArr.length < 1) {
		return ""
	}
	var c = "";
	if (this._tickerPricesArr.length <= this._tickerCountForOnce) {
		for ( var b = 0; b < this._tickerPricesArr.length; b++) {
			if (c.length > 0) {
				c = c + this._RendSingleTickerPrice(this._tickerPricesArr[b])
			} else {
				c = this._RendSingleTickerPrice(this._tickerPricesArr[b])
			}
		}
	} else {
		var a;
		var d = 0;
		if (this.curTickerIndex + this._tickerCountForOnce >= this._tickerPricesArr.length) {
			a = this._tickerPricesArr.length;
			d = this.curTickerIndex + this._tickerCountForOnce
					- this._tickerPricesArr.length
		} else {
			a = this.curTickerIndex + this._tickerCountForOnce
		}
		for ( var b = this.curTickerIndex; b < a; b++) {
			if (c.length > 0) {
				c = c + this._RendSingleTickerPrice(this._tickerPricesArr[b])
			} else {
				c = this._RendSingleTickerPrice(this._tickerPricesArr[b])
			}
		}
		if (a == this._tickerPricesArr.length) {
			this.curTickerIndex = 0
		} else {
			this.curTickerIndex = a
		}
		if (d > 0) {
			for ( var b = 0; b < d; b++) {
				if (c.length > 0) {
					c = c
							+ this
									._RendSingleTickerPrice(this._tickerPricesArr[b])
				} else {
					c = this._RendSingleTickerPrice(this._tickerPricesArr[b])
				}
			}
			this.curTickerIndex = d
		}
	}
	return c
};
TickerTape.prototype._RendSingleTickerPrice = function(b) {
	var c = "";
	if (b == null || b == "") {
		return c
	}
	var a = b.split("|");
	if (a[4] == "1") {
		c = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
				+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
				+ '&nbsp;<font color="green">' + a[2] + "(" + a[3]
				+ ")</font></div></div>"
	} else {
		if (a[4] == "-1") {
			c = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
					+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
					+ '&nbsp;<font color="red">' + a[2] + "(" + a[3]
					+ ")</font></div></div>"
		} else {
			c = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
					+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
					+ "&nbsp;" + a[2] + "(" + a[3] + ")</div></div>"
		}
	}
	return c
};
TickerTape.prototype.TweenPrices = function() {
	var a;
	var b = document.getElementById("tpc");
	if (b) {
		var c = document.getElementById("tcPrices1");
		if (c) {
			c.innerHTML = ""
		}
		this.RenderPriceLayer("tcPrices2");
		a = new Tween(b.style, "top", Tween.strongEaseOut, 0, -24, 0.7, "px")
	}
	a.start()
};
TickerTape.prototype._htmlbak = "";
TickerTape.prototype.HideShowTickerTape = function(b, a) {
	var g = document.getElementById(b);
	var c = document.getElementById(a);
	if (g != null && c != null) {
		if (g.style.display == "") {
			g.style.display = "none"
		} else {
			g.style.display = ""
		}
		if (c.style.display == "") {
			this._htmlbak = c.innerHTML;
			c.innerHTML = "";
			var f = document.getElementById("pfDropDownList");
			if (f) {
				f.style.display = "none"
			}
			c.style.display = "none"
		} else {
			if (this._htmlbak) {
				c.innerHTML = this._htmlbak
			}
			this._InitTaperOptions();
			c.style.display = "";
			var d = document.getElementById("newTickerInput");
			if (d) {
				d.value = "Enter Tickers"
			}
			var e = initBoxQuote("newTickerInput", "AutoCompleteDropDownQuote");
			e.IdleDisplayMsg = "Enter Tickers";
			e.SetPreference("USA", "EN", 32);
			e.SubmitCallback = this._varName + ".SelectNewTicker";
			e.EntryChosenCallback = this._varName + ".SelectNewTicker"
		}
	}
};
TickerTape.prototype.HideTickerTapeSettingsPanel = function(b, a) {
	var e = document.getElementById(b);
	var c = document.getElementById(a);
	if (e != null && c != null) {
		if (c.style.display == "") {
			this._htmlbak = c.innerHTML;
			c.innerHTML = "";
			var d = document.getElementById("pfDropDownList");
			if (d) {
				d.style.display = "none"
			}
			c.style.display = "none";
			e.style.display = ""
		}
	}
};
TickerTape.prototype.HideTickerButtonClick = function(c, b, a) {
	var g = document.getElementById(c);
	var d = document.getElementById(b);
	var f = document.getElementById(a);
	if (g != null && d != null && f != null) {
		g.style.display = "none";
		this._htmlbak = d.innerHTML;
		d.innerHTML = "";
		var e = document.getElementById("pfDropDownList");
		if (e) {
			e.style.display = "none"
		}
		d.style.display = "none";
		f.style.display = ""
	}
	setMSCNameCookie("hiddenTickerTape", "1")
};
TickerTape.prototype.ShowTickerButtonClick = function(c, b, a) {
	var f = document.getElementById(c);
	var d = document.getElementById(b);
	var e = document.getElementById(a);
	if (f != null && d != null && e != null) {
		f.style.display = "";
		d.style.display = "none";
		e.style.display = "none"
	}
	setMSCNameCookie("hiddenTickerTape", "0")
};
TickerTape.prototype.DropDownPortfolioList = function(f) {
	if (!this._loginStatus) {
		var d = "http://member.morningstar.com/forbidden/loginrawp.html?vurl="
				+ document.URL;
		window.location.href = d;
		return
	}
	var c = document.getElementById("pfDropDownList");
	if (c) {
		if (c.style.display == "none") {
			if (c.innerHTML != null && c.innerHTML.length > 0) {
				var a = document.getElementById("pfSelect");
				if (a) {
					c.style.display = "";
					var g = FindCtrlPosition(a);
					var b = FindCtrlPosition(c.offsetParent);
					c.style.left = g.left - b.left + "px";
					c.style.top = g.top + a.clientHeight - b.top + "px"
				}
			}
		} else {
			c.style.display = "none"
		}
	}
	f = window.event || f;
	if (window.event) {
		f.cancelBubble = true
	} else {
		f.stopPropagation()
	}
};
TickerTape.prototype.GetPrices = function(a, d) {
	var c = null;
	for ( var b = 0; b < this._QUSZTickIdArr.length; b++) {
		c = QU.GetTickQuery(this._QUSZTickIdArr[b], this._QUSZcbList[b], this);
		if (c != null) {
			QU.RemoveSymbol(c)
		}
	}
	this._QUSZTickIdArr.length = 0;
	this._QUSZcbList.length = 0;
	this._isFirstCallBack = true;
	if (this._tickersArr.length < 1) {
		this._tickerPricesArr.length = 0;
		this.RenderPriceLayer("tcPrices1");
		this.RenderPriceLayer("tcPrices2");
		if (d) {
			this.TweenPrices();
			this.HideTickerTapeSettingsPanel("pricesPanel", "settingsPanel")
		}
		return
	}
	if (a == undefined) {
		a = this.UpdateTickerPrices
	}
	for ( var b = 0; b < this._tickersArr.length; b++) {
		this._QUSZTickIdArr[this._QUSZTickIdArr.length] = new QUSZTickId(
				QU.TICKIDTYPE_TICKANDREGION, this._tickersArr[b], "");
		this._QUSZcbList[this._QUSZcbList.length] = a;
		QU.AddSymbol(this._QUSZTickIdArr[this._QUSZTickIdArr.length - 1], a,
				this)
	}
	QU.Start()
};
TickerTape.prototype.UpdateTickerAndLayers = function(a, e) {
	a.UpdateTickerPrices(a, e);
	var d = "";
	for ( var c = 0; c < e.length; c++) {
		d = e[c];
		var b = d.getTickId();
		d = QU.GetTickQuery(b, arguments.callee, a);
		if (d != null) {
			QU.RemoveSymbol(d)
		}
	}
	a.RenderPriceLayer("tcPrices1")
};
TickerTape.prototype.AfterSaveOptions = function(a, b) {
	a.UpdateTickerPrices(a, b);
	if (a._isFirstCallBack) {
		a.TweenPrices();
		a._isFirstCallBack = false
	}
};
TickerTape.prototype.UpdateTickerPrices = function(s, c) {
	try {
		var g;
		var m;
		s._tickerPricesArr.length = 0;
		for (g = 0; g < c.length; g++) {
			var h = c[g];
			var n = h.getTickId();
			var l = h.getSecurityRecord();
			var o = "";
			for ( var b = 0; b < s._marketTickersArr.length; b++) {
				if (n.m_tickId1 == s._marketTickersArr[b]) {
					m = "http://quote.morningstar.com/switch.html?ticker="
							+ encodeURIComponent(s._marketTickersArr[b]);
					o = s._marketTickerNames[b];
					break
				}
			}
			if (o == "") {
				o = n.m_tickId1;
				m = "http://quote.morningstar.com/switch.html?ticker="
						+ encodeURIComponent(o)
			}
			var a = "0.00";
			var p = "0.00";
			var f = "1";
			try {
				var d = l.m_TradeTime.replace(/-/g, "/");
				var r = new Date(d);
				if (s._marketTickerNames.contains(o) && (s._zeroOut == true)
						&& (r < s._dt6am)) {
					f = "0";
					a = "0.00";
					p = "0.00"
				} else {
					if (l.m_lastPrice > l.m_yestClose) {
						f = "1"
					} else {
						if (l.m_lastPrice == l.m_yestClose) {
							f = "0"
						} else {
							f = "-1"
						}
					}
					a = l.m_lastPrice - l.m_yestClose;
					p = (l.m_lastPrice - l.m_yestClose) * 100 / l.m_yestClose;
					a = a.toFixed(2);
					p = p.toFixed(2)
				}
			} catch (k) {
			}
			if (o == "DJIA") {
				s._tickerPricesArr.push(o + "|" + l.m_lastPrice + "|" + a + "|"
						+ p + "%|" + f + "|" + m);
				for ( var q = 0; q < s._commodityPricesArr.length; q++) {
					if (s._commodityPricesArr[q].length > 0) {
						s._tickerPricesArr.push(s._commodityPricesArr[q])
					}
				}
			} else {
				if (l != null && l.m_state > 0) {
					s._tickerPricesArr.push(o + "|" + l.m_lastPrice + "|" + a
							+ "|" + p + "%|" + f + "|" + m)
				}
			}
		}
	} catch (k) {
	}
};
document.onclick = function() {
	var a = document.getElementById("pfDropDownList");
	if (a) {
		a.style.display = "none"
	}
};
function TickerTape1(g, d, a, c, b, e, f) {
	this._varName = g;
	this._wrapperID = d;
	this._cName = a;
	this._adMode = c;
	this._adParas = b;
	this._region = e ? e : "USA";
	this._lang = f ? f : "EN";
	this._selectedPfId = null;
	this._selectedPfName = null;
	this._configuration = this.GetConfiguration();
	this._tickers = new Array();
	this._pfTickers = new Array();
	this._tickerPrices = new Array();
	this._cPrices = new Array();
	this._commodityWebService = "http://www.morningstar.com/GetPortfolio/GetCommodityQuotes.ashx";
	this._portfolioWebService = "http://www.morningstar.com/GetPortfolio/GetPortfolio.ashx";
	this._marketTickers = [ "COMP", "SPX", "$INDU" ];
	this._marketTickerNames = [ "Nasdaq", "S&P 500", "DJIA" ];
	this._QUSZTickIdArr = new Array();
	this._QUSZcbList = new Array();
	this._tickerCountOnce = 5;
	this._curIndex = 0;
	this._update = false;
	this._zeroOut = false;
	this._dtNow = new Date();
	this._dt6am = new Date(this._dtNow.getFullYear(), this._dtNow.getMonth(),
			this._dtNow.getDate(), 6, 0);
	this._resourcesList = [ "&nbsp;&nbsp;Display Settings:", "Markets",
			"Recent Quotes", "Hide Ticker Tape", "Select a portfolio",
			"Enter Tickers" ];
	this._htmlbak = "";
	this._commodityTimer = null;
	this._autoScrollTimer = null;
	this._isFirstcb = true;
	this.Init()
}
TickerTape1.prototype.IsWeekendHoliday = function() {
	var a = "http://www.morningstar.com/hpwebservice/GetMarketDay.aspx?cb=?"
			+ this._varName + "._RenderZeroOut";
	var b = this;
	$.getJSON(a, function(d) {
		if (d == null) {
			return
		}
		var c = d.Results;
		if (b._dtNow < b._dt6am) {
			b._zeroOut = false
		}
		if (c == "False" && b._dtNow > b._dt6am) {
			b._zeroOut = true
		}
	})
};
TickerTape1.prototype.Init = function() {
	if (document.getElementById(this._wrapperID)) {
		document.write("<div id=" + this._wrapperID + "></div>")
	}
	$("#" + this._wrapperID).attr("class", "h_TickerTape");
	var c = '<div id="pricesPanel">';
	c += '<a class="TTButtEdit" onclick="' + this._varName + '.Show(2);"></a>';
	c += '<div class="TickerWrap">';
	c += '<div class="TickerTableContain">';
	c += '<div style="overflow: hidden; height: 24px; width: 921px;">';
	c += '<div id="tpc">';
	c += '<div id="tcPrices1" style="height: 24px; width: 921px;"></div>';
	c += '<div id="tcPrices2" style="height: 24px; width: 921px;"></div>';
	c += "</div>";
	c += "</div>";
	c += "</div></div></div>";
	$("#" + this._wrapperID).append(c);
	if ($("#tkEditPanel").length < 1) {
		$("#" + this._wrapperID).append(this.RenderEditHtml());
		if (this._configuration.Markets) {
			$("#markets").attr("checked", true)
		} else {
			$("#markets").attr("checked", false)
		}
		if (this._configuration.NewTickers) {
			$("#newTickers").attr("checked", true)
		} else {
			$("#newTickers").attr("checked", false)
		}
		if (this._configuration.RtTickers) {
			$("#rtQuote").attr("checked", true)
		} else {
			$("#rtQuote").attr("checked", false)
		}
		if (this._configuration.PName && this._configuration.PName != "null") {
			$("#pfSelect").html(this._configuration.PName)
		} else {
			$("#pfSelect").html(this._resourcesList[4])
		}
		if (this._configuration.Hidden) {
			$("#hideTape").attr("checked", true)
		} else {
			$("#hideTape").attr("checked", false)
		}
	}
	var d = '<div id="HiddenPanel" style="display:none"><div id="expandBtnPanel" style="z-index: 500;"><a href="javascript:' + this._varName + '.Show(2)" class="TickerExpand"></a></div></div>';
	$("#" + this._wrapperID).append(d);
	if (this._adMode == 0) {
		$("#" + this._wrapperID).append('<div class="TTButtAd"></div>')
	} else {
		if (this._adMode == 1) {
			if (this._adParas) {
				var b = "/oas247/AdsSrv.html?adpos=x61&site="
						+ this._adParas[0] + "&poslist=" + this._adParas[1]
						+ "&query=" + this._adParas[2] + "&r="
						+ this._adParas[3] + "&rand=" + this._adParas[4];
				$("#" + this._wrapperID)
						.append(
								'<div class="TTButtAd"><iframe src="' + b + '"; name="x61" id="x61" width= "88" height="31"  scrolling="no" frameborder="no"  marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" allowtransparency="true" framespacing="0" border="0"  HSPACE="0" VSPACE="0"></iframe></div>')
			} else {
				$("#" + this._wrapperID)
						.append(
								'<div class="TTButtAd"><iframe src="http://ads.morningstar.com/RealMedia/ads/adstream_sx.ads/www.morningstar.com/homepage@x61"; width= "88" height="31"  scrolling="no" frameborder="no"  marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" allowtransparency="true" framespacing="0" border="0"  HSPACE="0" VSPACE="0"></iframe></div>')
			}
		} else {
			if (this._adMode == 2) {
				$("#" + this._wrapperID).append(
						'<div class="TTButtAd"><div id="OAS_x61"></div></div>')
			}
		}
	}
	if (this._configuration.Hidden) {
		this.Show(0)
	} else {
		this.RefreshPrices();
		this.RefreshCommodityPrices();
		var e = this._varName + ".RefreshCommodityPrices()";
		this._commodityTimer = setInterval(e, 60000)
	}
	var a = this._varName + ".AutoScroll()";
	this._autoScrollTimer = setInterval(a, 6000)
};
TickerTape1.prototype.RenderEditHtml = function() {
	var a = "";
	a += '<div id="tkEditPanel" style="display:none">';
	a += '<a class="TTButtSave" href="javascript:' + this._varName + '.Save()"></a>';
	a += '<div class="TickerWrap">';
	a += '<div class="TickerTableContain2">';
	a += '<div class="TTControl">';
	a += '<div class="TTControlText">' + this._resourcesList[0] + "</div>";
	a += "</div>";
	a += '<div class="TTForm1">';
	a += '<div class="menucont_h" style="margin-top: 3px;" id="pfDropDown">';
	a += '<ul id="nav">';
	a += '<li onclick="' + this._varName + '.GetPortfolioList(event,this);">';
	a += '<a class="headerlink3" id="pfSelect"></a><a class="arrow_h"></a>';
	a += '<ul class="drop_shad_h" id="npfDropDownList">';
	a += "</ul>";
	a += "</li>";
	a += "</ul> ";
	a += "</div>";
	a += "</div>";
	a += '<div class="TTForm"></div>';
	a += '<div class="TTForm3"><input name="markets" id="markets" type="checkbox" /></div>';
	a += '<div class="TTControlText">' + this._resourcesList[1] + "</div>";
	a += '<div class="TTForm" style="z-index: 50;">';
	a += '<input name="newTickers" id="newTickers" type="checkbox" />';
	a += "</div>";
	a += '<div class="TTForm2">';
	a += '<input name="newTickerInput" id="newTickerInput" value="'
			+ this._resourcesList[5]
			+ '" size="15" class="headerlink2" onclick="if(this.value==\'Enter Tickers\') this.value=\'\';" onkeyup="if(event.keyCode==13 &amp;&amp; this.value!=\'\') {'
			+ this._varName
			+ '.SelectNewTicker(this.value);this.value=\'\'}" type="text">';
	a += "</div>";
	a += '<div class="TTForm">';
	a += '<input name="rtQuote" id="rtQuote" type="checkbox">';
	a += "</div>";
	a += '<div class="TTControlText">' + this._resourcesList[2] + "</div>";
	a += '<div class="TTForm">';
	a += '<input name="hideTape" id="hideTape" onclick="' + this._varName + '.Hide();" type="checkbox">';
	a += "</div>";
	a += '<div class="TTControlText">' + this._resourcesList[3] + "</div>";
	a += "</div>";
	a += "</div>";
	a += "</div>";
	a += '<div class="AutoCompleteDropDownQuote" style="position: absolute; float: left; left: 304px; background-color: rgb(255, 255, 255); top: 119px;z-index:1000" id="AutoCompleteDropDownQuote"></div>';
	return a
};
TickerTape1.prototype.GetConfiguration = function() {
	var g = this._cName ? this._cName + "MSTickerTape" : "MSTickerTape";
	var b = readWSCookie(g);
	var c;
	if (!b) {
		c = {
			Hidden : false,
			Pid : null,
			PName : null,
			Markets : true,
			NewTickers : false,
			RtTickers : false
		}
	} else {
		try {
			var a = b.split("|");
			c = {
				Hidden : false,
				Pid : null,
				PName : null,
				Markets : true,
				NewTickers : false,
				RtTickers : false
			};
			var e = a[0].split(":");
			c.Markets = e[0] == "1" ? true : false;
			c.NewTickers = e[1] == "1" ? true : false;
			c.RtTickers = e[2] == "1" ? true : false;
			c.Hidden = a[2] == 1 ? true : false;
			var f = a[1].split(":");
			if (f.length == 2) {
				c.Pid = f[0];
				c.PName = f[1]
			} else {
				c.Pid = null;
				c.PName = null
			}
			this._selectedPfId = c.Pid;
			this._selectedPfName = c.PName
		} catch (d) {
			c = {
				Hidden : false,
				Pid : null,
				PName : null,
				Markets : true,
				NewTickers : false,
				RtTickers : false
			}
		}
	}
	return c
};
TickerTape1.prototype.AutoScroll = function() {
	var a = this.RenderRowHTML();
	$("#tcPrices1").html(a);
	$("#tcPrices2").html(a);
	$("#tpc").animate( {
		marginTop : "-24px"
	}, 500, function() {
		$(this).css( {
			marginTop : "0px"
		}).find("div:first").appendTo(this)
	})
};
TickerTape1.prototype.GetTickers = function() {
	this._tickers.length = 0;
	if (this._configuration.Markets) {
		this._tickers = this._tickers.concat( [ "COMP", "SPX", "$INDU" ])
	}
	if (this._configuration.NewTickers) {
		var e = this._cName ? this._cName + "NewQuotes" : "NewQuotes";
		var a = readWSCookie(e);
		if (a) {
			var b = (a).split(",");
			this._tickers = this._tickers.concat(b)
		}
	}
	if (this._configuration.RtTickers) {
		var d = readWSCookie("RecentQuotes");
		if (d) {
			var c = (d).split("+");
			this._tickers = this._tickers.concat(c)
		}
	}
	if (this._pfTickers.length > 0) {
		this._tickers = this._tickers.concat(this._pfTickers)
	}
	this._tickers = this._tickers.unique()
};
TickerTape1.prototype.GetPortfolioTickers = function(b) {
	var a = this._portfolioWebService + "?op=2&&pfIds=" + b + "&cb=?";
	var c = this;
	$.getJSON(a, function(d) {
		c._pfTickers = d.Results;
		c.GetTickers();
		c.StartQU()
	})
};
TickerTape1.prototype.RefreshPrices = function() {
	if (this._configuration.Pid && this._configuration.Pid != "null"
			&& this._configuration.Pid != "undefined") {
		this.GetPortfolioTickers(this._configuration.Pid)
	} else {
		this._pfTickers.length = 0;
		this.GetTickers();
		this.StartQU()
	}
};
TickerTape1.prototype.StartQU = function() {
	this._isFirstcb = true;
	var c = null;
	for ( var b = 0; b < this._QUSZTickIdArr.length; b++) {
		c = QU.GetTickQuery(this._QUSZTickIdArr[b], this._QUSZcbList[b], this);
		if (c != null) {
			QU.RemoveSymbol(c)
		}
	}
	if (this._tickers.length == 0) {
		this._tickerPrices.length = 0;
		this._isFirstcb = false;
		this.AutoScroll()
	}
	for ( var b = 0; b < this._tickers.length; b++) {
		if (this._tickers[b].indexOf(":") > 0) {
			var a = this._tickers[b].split(":");
			this._QUSZTickIdArr[this._QUSZTickIdArr.length] = new QUSZTickId(
					QU.TICKIDTYPE_TICKANDEXCHANGE, a[1], a[0])
		} else {
			this._QUSZTickIdArr[this._QUSZTickIdArr.length] = new QUSZTickId(
					QU.TICKIDTYPE_TICKANDREGION, this._tickers[b], "")
		}
		this._QUSZcbList[this._QUSZcbList.length] = this.RefreshPricescb;
		QU.AddSymbol(this._QUSZTickIdArr[this._QUSZTickIdArr.length - 1],
				this.RefreshPricescb, this)
	}
	QU.Start()
};
TickerTape1.prototype.RefreshPricescb = function(t, c) {
	try {
		var n;
		t._tickerPrices.length = 0;
		if (!t._autoScrollTimer) {
			var o = t._varName + ".AutoScroll()";
			t._autoScrollTimer = setInterval(o, 6000)
		}
		for ( var g = 0; g < c.length; g++) {
			try {
				var h = c[g];
				var p = h.getTickId();
				var l = h.getSecurityRecord();
				var m = "";
				var a = "0.00";
				var q = "0.00";
				var f = "1";
				for ( var b = 0; b < t._marketTickers.length; b++) {
					if (p.m_tickId1 == t._marketTickers[b]) {
						n = "http://quote.morningstar.com/switch.html?ticker="
								+ encodeURIComponent(t._marketTickers[b]);
						m = t._marketTickerNames[b];
						break
					}
				}
				if (!m) {
					if (l != null) {
						m = l.m_exchange + ":" + l.m_tick;
						n = "http://quote.morningstar.com/switch.html?ticker="
								+ encodeURIComponent(m)
					}
				}
				var d = l.m_TradeTime.replace(/-/g, "/");
				var s = new Date(d);
				if (t._marketTickerNames.contains(m) && (t._zeroOut == true)
						&& (s < t._dt6am)) {
					f = "0";
					a = "0.00";
					q = "0.00"
				} else {
					if (l.m_lastPrice > l.m_yestClose) {
						f = "1"
					} else {
						if (l.m_lastPrice == l.m_yestClose) {
							f = "0"
						} else {
							f = "-1"
						}
					}
					a = l.m_lastPrice - l.m_yestClose;
					q = (l.m_lastPrice - l.m_yestClose) * 100 / l.m_yestClose;
					a = a.toFixed(2);
					q = q.toFixed(2)
				}
				if (m == "DJIA" && t._configuration.Markets) {
					t._tickerPrices.push(m + "|" + l.m_lastPrice.toFixed(2)
							+ "|" + a + "|" + q + "%|" + f + "|" + n);
					for ( var r = 0; r < t._cPrices.length; r++) {
						if (t._cPrices[r].length > 0) {
							t._tickerPrices.push(t._cPrices[r])
						}
					}
				} else {
					if (l != null && l.m_state > 0) {
						t._tickerPrices.push(m + "|" + l.m_lastPrice.toFixed(2)
								+ "|" + a + "|" + q + "%|" + f + "|" + n)
					}
				}
			} catch (k) {
			}
		}
		if (t._isFirstcb) {
			t._isFirstcb = false;
			t.AutoScroll()
		}
	} catch (k) {
	}
};
TickerTape1.prototype.RenderRowHTML = function() {
	if (this._tickerPrices.length < 1) {
		return ""
	}
	var c = "";
	if (this._tickerPrices.length <= this._tickerCountOnce) {
		for ( var b = 0; b < this._tickerPrices.length; b++) {
			if (c.length > 0) {
				c = c + this.RenderSingleTickerHTML(this._tickerPrices[b])
			} else {
				c = this.RenderSingleTickerHTML(this._tickerPrices[b])
			}
		}
	} else {
		var a;
		var d = 0;
		if (this._curIndex + this._tickerCountOnce >= this._tickerPrices.length) {
			a = this._tickerPrices.length - 1;
			d = this._curIndex + this._tickerCountOnce
					- this._tickerPrices.length
		} else {
			a = this._curIndex + this._tickerCountOnce - 1
		}
		for ( var b = this._curIndex; b <= a; b++) {
			if (c.length > 0) {
				c = c + this.RenderSingleTickerHTML(this._tickerPrices[b])
			} else {
				c = this.RenderSingleTickerHTML(this._tickerPrices[b])
			}
		}
		if ((a + 1) == this._tickerPrices.length) {
			this._curIndex = 0
		} else {
			this._curIndex = a + 1
		}
		if (d > 0) {
			for ( var b = 0; b < d; b++) {
				if (c.length > 0) {
					c = c + this.RenderSingleTickerHTML(this._tickerPrices[b])
				} else {
					c = this.RenderSingleTickerHTML(this._tickerPrices[b])
				}
			}
			this._curIndex = d
		}
	}
	return c
};
TickerTape1.prototype.RenderSingleTickerHTML = function(c) {
	var b = "";
	var a = c.split("|");
	if (a[4] == "1") {
		b = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
				+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
				+ '&nbsp;<font color="green">' + a[2] + "(" + a[3]
				+ ")</font></div></div>"
	} else {
		if (a[4] == "-1") {
			b = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
					+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
					+ '&nbsp;<font color="red">' + a[2] + "(" + a[3]
					+ ")</font></div></div>"
		} else {
			b = '<div class="TTTWrap"><div class="TTtickers"><a href="' + a[5]
					+ '">' + a[0] + '</a></div><div class="TTQuote">' + a[1]
					+ "&nbsp;" + a[2] + "(" + a[3] + ")</div></div>"
		}
	}
	return b
};
TickerTape1.prototype.RefreshCommodityPrices = function() {
	var a = this._commodityWebService + "?cb=?";
	var b = this;
	$.getJSON(a, function(c) {
		b._cPrices = c.Results.split(",")
	})
};
TickerTape1.prototype.Show = function(a) {
	if ($("#tkEditPanel").css("display") != "none") {
		this._htmlbak = $("#tkEditPanel").html()
	} else {
		if (this._htmlbak && $.browser.msie) {
			$("#tkEditPanel").html(this._htmlbak)
		}
	}
	$("#pricesPanel").hide();
	$("#tkEditPanel").hide();
	$("#HiddenPanel").hide();
	if (a == 0) {
		$("#HiddenPanel").show();
		$(".TTButtAd").hide()
	} else {
		if (a == 1) {
			$("#pricesPanel").show();
			$(".TTButtAd").show()
		} else {
			if (a == 2) {
				$("#tkEditPanel").show();
				$(".TTButtAd").show();
				var b = initBoxQuote("newTickerInput",
						"AutoCompleteDropDownQuote");
				b.IdleDisplayMsg = "Enter Tickers";
				b.SetPreference(this._region, this._lang, 32);
				b.SubmitCallback = this._varName + ".SelectNewTicker";
				b.EntryChosenCallback = this._varName + ".SelectNewTicker";
				this._update = false
			}
		}
	}
};
TickerTape1.prototype.GetPortfolioList = function(d, c) {
	var a = this._portfolioWebService + "?op=1&cb=?";
	var b = this;
	$
			.getJSON(
					a,
					function(g) {
						if (g.Results == "Unlogined") {
							var h = "https://members.morningstar.com/memberservice/login.aspx?vurl="
									+ encodeURIComponent(document.URL);
							window.location.href = h;
							return
						}
						var e = '<li><a class="rowlist_h" href="javascript:' + b._varName + '.SelectPortfolio(null,null)">Clear portfolio tickers</a></li><br />';
						for (i = 0; i < g.Results.length; i++) {
							try {
								e += '<li><a class="rowlist_h" href="javascript:'
										+ b._varName
										+ ".SelectPortfolio("
										+ g.Results[i][1]
										+ ",'"
										+ g.Results[i][0]
										+ "')\">"
										+ g.Results[i][0] + "</a></li><br />"
							} catch (f) {
							}
						}
						$("#npfDropDownList").html(e)
					});
	if (readWSCookie("mstar")) {
		showDropdown(d, c)
	}
};
TickerTape1.prototype.Save = function() {
	if ($("#markets").attr("checked") != this._configuration.Markets) {
		this._configuration.Markets = $("#markets").attr("checked");
		this._update = true
	}
	if ($("#newTickers").attr("checked") != this._configuration.NewTickers) {
		this._configuration.NewTickers = $("#newTickers").attr("checked");
		this._update = true
	}
	if ($("#rtQuote").attr("checked") != this._configuration.RtTickers) {
		this._configuration.RtTickers = $("#rtQuote").attr("checked");
		this._update = true
	}
	if ($("#hideTape").attr("checked") != this._configuration.Hidden) {
		this._configuration.Hidden = $("#hideTape").attr("checked");
		this._update = true
	}
	var c = false;
	if (this._selectedPfId != this._configuration.Pid) {
		this._configuration.Pid = this._selectedPfId;
		this._configuration.PName = this._selectedPfName;
		c = true
	}
	var e = "";
	if (this._update || c) {
		e = this._configuration.Markets ? 1 : 0;
		e += ":";
		e += this._configuration.NewTickers ? 1 : 0;
		e += ":";
		e += this._configuration.RtTickers ? 1 : 0;
		var d = this._configuration.Hidden ? 1 : 0;
		var g = this._cName ? this._cName + "MSTickerTape" : "MSTickerTape";
		var b = readWSCookie(g);
		if (b) {
			var a = e.split("|");
			if (!c) {
				e = e + "|" + b[1] + "|" + d
			} else {
				e = e + "|" + this._configuration.Pid + ":"
						+ this._configuration.PName + "|" + d
			}
		} else {
			e = e + "|null:null|" + d
		}
		setMSCookie(g, e);
		if (!this._commodityTimer) {
			this.RefreshCommodityPrices();
			var f = this._varName + ".RefreshCommodityPrices()";
			this._commodityTimer = setInterval(f, 60000)
		}
		if (this._autoScrollTimer) {
			this._curIndex = 0;
			clearInterval(this._autoScrollTimer);
			this._autoScrollTimer = null
		}
		this.RefreshPrices()
	}
	if (this._configuration.Hidden) {
		this.Show(0)
	} else {
		this.Show(1)
	}
};
TickerTape1.prototype.Hide = function() {
	var c = this._cName ? this._cName + "MSTickerTape" : "MSTickerTape";
	var b = readWSCookie(c);
	if (b) {
		var a = b.split("|");
		b = a[0] + "|" + a[1] + "|1"
	} else {
		b = "1:0:0|null:null|1"
	}
	this._configuration.Hidden = true;
	setMSCookie(c, b);
	if ($("#hideTape").attr("checked")) {
		this.Show(0)
	}
};
TickerTape1.prototype.SelectNewTicker = function(k) {
	if (k.Symbol) {
		k = k.Exchange + ":" + k.Symbol
	}
	k = k.replace(/\s/g, "");
	var c = k.split(",");
	var l = 0;
	k = "";
	var e = 0;
	var g = this._cName ? this._cName + "NewQuotes" : "NewQuotes";
	var h = readWSCookie(g);
	var j;
	if (!h || h == "") {
		j = "";
		e = 1
	} else {
		j = h
	}
	for ( var d = 0; d < c.length; d++) {
		if (c[d] != "") {
			reg = new RegExp("\\b" + c[d] + "\\b", "gi");
			if (reg.test(j)) {
				continue
			}
			this._update = true;
			j = j + "," + c[d];
			l++;
			k = k + c[d] + ","
		}
	}
	if (l == 0) {
		document.getElementById("newTickerInput").value = "";
		return
	}
	k = k.substr(0, k.length - 1);
	if (e > 0) {
		j = j.substr(e)
	}
	var a = j.split(",");
	var f = a.length;
	var b = 0;
	while (f > 20) {
		b = j.indexOf(",", b + 1);
		f--
	}
	if (b > 0) {
		j = j.substr(b + 1)
	}
	h = j;
	setMSCookie(g, h)
};
TickerTape1.prototype.SelectPortfolio = function(b, a) {
	this._selectedPfId = b;
	this._selectedPfName = a;
	if (b != null) {
		$("#pfSelect").html(a)
	} else {
		$("#pfSelect").html(this._resourcesList[4])
	}
};
/*!
 * jQuery JavaScript Library v1.6
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Mon May 2 13:50:00 2011 -0400
 */
(function(a,b){function cw(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function ct(a){if(!ch[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ci||(ci=c.createElement("iframe"),ci.frameBorder=ci.width=ci.height=0),c.body.appendChild(ci);if(!cj||!ci.createElement)cj=(ci.contentWindow||ci.contentDocument).document,cj.write("<!doctype><html><body></body></html>");b=cj.createElement(a),cj.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ci)}ch[a]=d}return ch[a]}function cs(a,b){var c={};f.each(cn.concat.apply([],cn.slice(0,b)),function(){c[this]=a});return c}function cr(){co=b}function cq(){setTimeout(cr,0);return co=f.now()}function cg(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cf(){try{return new a.XMLHttpRequest}catch(b){}}function b_(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function b$(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bZ(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bD.test(a)?d(a,e):bZ(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)bZ(a+"["+e+"]",b[e],c,d);else d(a,b)}function bY(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bS,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bY(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bY(a,c,d,e,"*",g));return l}function bX(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bO),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bB(a,b,c){var d=b==="width"?bv:bw,e=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return e;f.each(d,function(){c||(e-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?e+=parseFloat(f.css(a,"margin"+this))||0:e-=parseFloat(f.css(a,"border"+this+"Width"))||0});return e}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval(b.text||b.textContent||b.innerHTML||""),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):a.getElementsByTagName&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bf(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function W(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(R.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(x,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){name="data-"+c.replace(j,"$1-$2").toLowerCase(),d=a.getAttribute(name);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(e){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?g=[null,a,null]:g=i.exec(a);if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:E?function(a){return a==null?"":E.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?C.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(F)return F.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=D.call(arguments,2),g=function(){return a.apply(c,f.concat(D.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(c,d){d&&d instanceof e&&!(d instanceof a)&&(d=a(d));return e.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){G["[object "+b+"]"]=b.toLowerCase()}),x=e.uaMatch(w),x.browser&&(e.browser[x.browser]=!0,e.browser.version=x.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?z=function(){c.removeEventListener("DOMContentLoaded",z,!1),e.ready()}:c.attachEvent&&(z=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",z),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g](h)}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b,d,e,f,g,h,i,j,k,l,m,n,o,p,q;a.setAttribute("className","t"),a.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",b=a.getElementsByTagName("*"),d=a.getElementsByTagName("a")[0];if(!b||!b.length||!d)return{};e=c.createElement("select"),f=e.appendChild(c.createElement("option")),g=a.getElementsByTagName("input")[0],i={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.55$/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:g.value==="on",optSelected:f.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},g.checked=!0,i.noCloneChecked=g.cloneNode(!0).checked,e.disabled=!0,i.optDisabled=!f.disabled;try{delete a.test}catch(r){i.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function click(){i.noCloneEvent=!1,a.detachEvent("onclick",click)}),a.cloneNode(!0).fireEvent("onclick")),g=c.createElement("input"),g.value="t",g.setAttribute("type","radio"),i.radioValue=g.value==="t",g.setAttribute("checked","checked"),a.appendChild(g),j=c.createDocumentFragment(),j.appendChild(a.firstChild),i.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",k=c.createElement("body"),l={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(p in l)k.style[p]=l[p];k.appendChild(a),c.documentElement.appendChild(k),i.appendChecked=g.checked,i.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,i.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",i.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",m=a.getElementsByTagName("td"),q=m[0].offsetHeight===0,m[0].style.display="",m[1].style.display="none",i.reliableHiddenOffsets=q&&m[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(h=c.createElement("div"),h.style.width="0",h.style.marginRight="0",a.appendChild(h),i.reliableMarginRight=(parseInt(c.defaultView.getComputedStyle(h,null).marginRight,10)||0)===0),k.innerHTML="",c.documentElement.removeChild(k);if(a.attachEvent)for(p in{submit:1,change:1,focusin:1})o="on"+p,q=o in a,q||(a.setAttribute(o,"return;"),q=typeof a[o]=="function"),i[p+"Bubbles"]=q;return i}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[c]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function l(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark";while(g--)if(tmp=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,tmp.done(l);l();return d.promise()}});var n=/[\n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:data-|aria-)/,u=/\:/,v;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.addClass(a.call(this,b,c.attr("class")||""))});if(a&&typeof a=="string"){var b=(a||"").split(o);for(var c=0,d=this.length;c<d;c++){var e=this[c];if(e.nodeType===1)if(!e.className)e.className=a;else{var g=" "+e.className+" ",h=e.className;for(var i=0,j=b.length;i<j;i++)g.indexOf(" "+b[i]+" ")<0&&(h+=" "+b[i]);e.className=f.trim(h)}}}return this},removeClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.removeClass(a.call(this,b,c.attr("class")))});if(a&&typeof a=="string"||a===b){var c=(a||"").split(o);for(var d=0,e=this.length;d<e;d++){var g=this[d];if(g.nodeType===1&&g.className)if(a){var h=(" "+g.className+" ").replace(n," ");for(var i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){var d=f(this);d.toggleClass(a.call(this,c,d.attr("class"),b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if((" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||"set"in c&&c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b=a.selectedIndex,c=[],d=a.options,e=a.type==="select-one";if(b<0)return null;for(var g=e?b:0,h=e?b+1:d.length;g<h;g++){var i=d[g];if(i.selected&&(f.support.optDisabled?!i.disabled:i.getAttribute("disabled")===null)&&(!i.parentNode.disabled||!f.nodeName(i.parentNode,"optgroup"))){value=f(i).val();if(e)return value;c.push(value)}}if(e&&!c.length&&d.length)return f(d[b]).val();return c},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex",readonly:"readOnly"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c]||(v&&(f.nodeName(a,"form")||u.test(c))?v:b);if(d!==b){if(d===null||d===!1&&!t.test(c)){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;d===!0&&!t.test(c)&&(d=c),a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.getAttribute("value");a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),f.support.getSetAttribute||(f.attrFix=f.extend(f.attrFix,{"for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder"}),v=f.attrHooks.name=f.attrHooks.value=f.valHooks.button={get:function(a,c){var d;if(c==="value"&&!f.nodeName(a,"button"))return a.getAttribute(c);d=a.getAttributeNode(c);return d&&d.specified?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=Object.prototype.hasOwnProperty,x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.indexOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.clientLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,N(a.origType,a.selector),f.extend({},a,{handler:M,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,N(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?E:D):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=E;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=E;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=E,this.stopPropagation()},isDefaultPrevented:D,isPropagationStopped:D,isImmediatePropagationStopped:D};var F=function(a){var b=a.relatedTarget;try{if(b&&b!==c&&!b.parentNode)return;while(b&&b!==this)b=b.parentNode;b!==this&&(a.type=a.data,f.event.handle.apply(this,arguments))}catch(d){}},G=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?G:F,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?G:F)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&f(b).closest("form").length&&K("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&K("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var H,I=function(a){var b=a.type,c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function J(a){var c=a.target,d,e;if(!!y.test(c.nodeName)&&!c.readOnly){d=f._data(c,"_change_data"),e=I(c),(a.type!=="focusout"||c.type!=="radio")&&f._data(c,"_change_data",e);if(d===b||e===d)return;if(d!=null||e)a.type="change",a.liveFired=b,f.event.trigger(a,arguments[1],c)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var L={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isFunction(d))e=d||D,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=x.exec(h),k="",j&&(k=j[0],h=h.replace(x,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,L[h]?(a.push(L[h]+k),h=h+k):h=(L[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+N(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+N(h,m),e)}return this}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).length>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a){throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){return a.nodeName.toLowerCase()==="input"&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(a===b){g=!0;return 0}if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var O=/Until$/,P=/^(?:parents|prevUntil|prevAll)/,Q=/,/,R=/^.[^:#\[\.,]*$/,S=Array.prototype.slice,T=f.expr.match.POS,U={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(W(this,a,!1),"not",a)},filter:function(a){return this.pushStack(W(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=T.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/<tbody/i,ba=/<|&#?\w+;/,bb=/<(?:script|object|embed|option|style)/i,bc=/checked\s*(?:[^=]|=\s*.checked.)/i,bd=/\/(java|ecma)script/i,be={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!be[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bc.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bf(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bl)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i=b&&b[0]?b[0].ownerDocument||b[0]:c;a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!bb.test(a[0])&&(f.support.checkClone||!bc.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[];for(var i=0,j;(j=a[i])!=null;i++){typeof j=="number"&&(j+="");if(!j)continue;if(typeof j=="string")if(!ba.test(j))j=b.createTextNode(j);else{j=j.replace(Z,"<$1></$2>");var k=($.exec(j)||["",""])[1].toLowerCase(),l=be[k]||be._default,m=l[0],n=b.createElement("div");n.innerHTML=l[1]+j+l[2];while(m--)n=n.lastChild;if(!f.support.tbody){var o=_.test(j),p=k==="table"&&!o?n.firstChild&&n.firstChild.childNodes:l[1]==="<table>"&&!o?n.childNodes:[];for(var q=p.length-1;q>=0;--q)f.nodeName(p[q],"tbody")&&!p[q].childNodes.length&&p[q].parentNode.removeChild(p[q])}!f.support.leadingWhitespace&&Y.test(j)&&n.insertBefore(b.createTextNode(Y.exec(j)[0]),n.firstChild),j=n.childNodes}var r;if(!f.support.appendChecked)if(j[0]&&typeof (r=j.length)=="number")for(i=0;i<r;i++)bk(j[i]);else bk(j);j.nodeType?h.push(j):h=f.merge(h,j)}if(d){g=function(a){return!a.type||bd.test(a.type)};for(i=0;h[i];i++)if(e&&f.nodeName(h[i],"script")&&(!h[i].type||h[i].type.toLowerCase()==="text/javascript"))e.push(h[i].parentNode?h[i].parentNode.removeChild(h[i]):h[i]);else{if(h[i].nodeType===1){var s=f.grep(h[i].getElementsByTagName("script"),g);h.splice.apply(h,[i+1,0].concat(s))}d.appendChild(h[i])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bm=/alpha\([^)]*\)/i,bn=/opacity=([^)]*)/,bo=/-([a-z])/ig,bp=/([A-Z]|^ms)/g,bq=/^-?\d+(?:px)?$/i,br=/^-?\d/,bs=/^[+\-]=/,bt=/[^+\-\.\de]+/g,bu={position:"absolute",visibility:"hidden",display:"block"},bv=["Left","Right"],bw=["Top","Bottom"],bx,by,bz,bA=function(a,b){return b.toUpperCase()};f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bx(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0,widows:!0,orphans:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d;if(h==="number"&&isNaN(d)||d==null)return;h==="string"&&bs.test(d)&&(d=+d.replace(bt,"")+parseFloat(f.css(a,c))),h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bx)return bx(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bo,bA)}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){a.offsetWidth!==0?e=bB(a,b,d):f.swap(a,bu,function(){e=bB(a,b,d)});if(e<=0){e=bx(a,b,b),e==="0px"&&bz&&(e=bz(a,b,b));if(e!=null)return e===""||e==="auto"?"0px":e}if(e<0||e==null){e=a.style[b];return e===""||e==="auto"?"0px":e}return typeof e=="string"?e:e+"px"}},set:function(a,b){if(!bq.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV;try{bU=e.href}catch(bW){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bX(bS),ajaxTransport:bX(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?b$(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b_(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bY(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bY(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bZ(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var ca=f.now(),cb=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+ca++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cb.test(b.url)||e&&cb.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cb,l),b.url===j&&(e&&(k=k.replace(cb,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cc=a.ActiveXObject?function(){for(var a in ce)ce[a](0,1)}:!1,cd=0,ce;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cf()||cg()}:cf,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cc&&delete ce[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cd,cc&&(ce||(ce={},f(a).unload(cc)),ce[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ch={},ci,cj,ck=/^(?:toggle|show|hide)$/,cl=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cm,cn=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],co,cp=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cs("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",ct(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cs("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cs("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g];if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=ct(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block")),b.animatedProperties[g]=f.isArray(h)?h[1]:b.specialEasing&&b.specialEasing[g]||b.easing||"swing"}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],ck.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=cl.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[g]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custom(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cs("show",1),slideUp:cs("hide",1),slideToggle:cs("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this),f.isFunction(d.old)&&d.old.call(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function h(a){return d.step(a)}var d=this,e=f.fx,g;this.startTime=co||cq(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,h.elem=this.elem,h()&&f.timers.push(h)&&!cm&&(cp?(cm=1,g=function(){cm&&(cp(g),e.tick())},cp(g)):cm=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=co||cq(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a=f.timers,b=a.length;while(b--)a[b]()||a.splice(b,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cm),cm=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cu=/^t(?:able|d|h)$/i,cv=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cw(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cu.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cv.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cv.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cw(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cw(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){return this[0]?parseFloat(f.css(this[0],d,"padding")):null},f.fn["outer"+c]=function(a){return this[0]?parseFloat(f.css(this[0],d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window);
/* Javascript plotting library for jQuery, v. 0.5.
 *
 * Released under the MIT license by IOLA, December 2007.
 *
 */

(function($) {
    function Plot(targetID,_option,obj) {
        // data is on the form:
        //   [ series1, series2 ... ]
        // where series is either just the data as [ [x1, y1], [x2, y2], ... ]
        // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label" }

        var series = [],
        markSeries = [],
        markOptions = {},
        dataOffsets = [],
            options = {
            // the color theme used for graphs
            colors: ["#2f4880", "#9b0033","#e96610","#f1ad02","#9faa00","#006065","#809aba","#e1b2c1","#e2e5b2","#293f6f","#fbe6b3","#f2a370","#b2cfd0", "#bec5d4","#c5cc66","#f8d1b7","#c36685"],//["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"], changed by Jacye
                legend: {
                    show: false,
                    noColumns: 1, // number of colums in legend table
                    labelFormatter: null, // fn: string -> string
                    labelBoxBorderColor: "#ccc", // border color for the little label boxes
                    container: null, // container (as jQuery object) to put legend in, null means default on top of graph
                    position: "sw", // position of default legend container within plot
                    margin: 5, // distance from grid edge to default legend container within plot
                    backgroundColor: null, // null means auto-detect
                    backgroundOpacity: 0.85 // set to 0 to avoid background
                },
                xaxis: {
                    mode: null, // null or "time"
                    min: null, // min. value to show, null means set automatically
                    max: null, // max. value to show, null means set automatically
                    autoscaleMargin: null, // margin in % to add if auto-setting min/max
                    ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
                    tickFormatter: null, // fn: number -> string
                    labelWidth: null, // size of tick labels in pixels
                    labelHeight: null,
                    showLabel:true, // is show label.
                    // mode specific options
                    tickDecimals: null, // no. of decimals, null means auto
                    tickSize: null, // number or [number, "unit"]
                    minTickSize: null, // number or [number, "unit"]
                    monthNames: null, // list of names of months
                    timeformat: null, // format string to use
                    posStyle:null,
                    offset:0,
                    interval:1,
                    link:null,
                    style:null,
                    textAlign:null
                },
                yaxis: {
                    autoscaleMargin: 0.02,
                    showLabel:true
                },
                x2axis: {
                    autoscaleMargin: null,
                    showLabel:true
                },
                y2axis: {
                    autoscaleMargin: 0.02,
                    showLabel:false
                },              
                points: {
                    show: false,
                    radius: 1.5,
                    lineWidth: 2, // in pixels
                    fill: false,
                    fillColor: "#ffffff"
                },
                lines: {
                    show: false,
                    lineWidth: 2, // in pixels
                    fill: false,
                    
                    fillColor: null
                },
                bars: {                  
                    show: false,
                    outLine:false,
                    lineWidth: 2, // in pixels
                    barWidth: 1, // in units of the x axis
                    minBarWidth:2,
                    maxBarWidth:16,
                    upColor:"#008000",
                	downColor:"#ff0000",
                    fill: true,
                    fillColor: null,
                    align: "left", // or "center"
                    offset: 0,
                    barValues:null,
                    overlap:"absolute"
                },
                OLHC:
                {
                  show: false,
                  lineWidth: 2, // in pixels
                  fill: false,
                  fillColor: null,
                  maxBarWidth:10,
                  minBarWidth:2,
                  barWidth:null,
                  highLightColor:"#ff0000"
                },
                candleStick:{
                	show:false,
                	lineWidth:1,
                	fill:true,
                	upColor:"#008000",
                	downColor:"#ff0000",
                	maxCandleWidth:16,
                	minCandleWidth:2,
                	candleWidth:null,
                	highLightColor:"#2f4880"
                },
                imagePoints: {
                    show: false,
                    imageObj:null
                },
                grid: {
                    color: "#545454", // primary color used for outline and labels
                    backgroundColor: null, // null for transparent, else color
                    tickColor: "#dddddd", // color used for the ticks
                    labelMargin: 5, // in pixels
                    borderWidth: 0.5,
                    markings: null, // array of ranges or fn: axes -> array of ranges
                    markingsColor: "#f4f4f4",
                    markingsLineWidth: 1,
                    // interactive stuff
                    clickable: false,
                    hoverable: false,
                    autoHighlight: true, // highlight in case mouse is near
                    mouseActiveRadius: 10 // how far the mouse can be away to activate an item
                },
                selection: {
                    mode: null, // one of null, "x", "y" or "xy"
                    color: "#e8cfac"
                },
                 crosshair: {
                    mode: null, // one of null, "x", "y" or "xy",
                    color: "#aa0000"
                },
                shadowSize: 0
            },
        canvas = obj.canvas,      // the canvas for the plot itself
        overlay = obj.overlay,     // canvas for interactive stuff on top of plot
        eventHolder = obj.eventHolder, // jQuery object that events should be bound to
        ctx = obj.ctx, 
        octx = obj.octx,
        target = $("#"+targetID),
        axes = { xaxis: {}, yaxis: {}, x2axis: {}, y2axis: {} },
        plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
        canvasWidth = 0, canvasHeight = 0,
        plotWidth = 0, plotHeight = 0,
        // dedicated to storing data for buggy standard compliance cases
        workarounds = {};
        
        this.setData = setData;
        this.setupGrid = setupGrid;
        this.draw = draw;
        this.clearSelection = clearSelection;
        this.setSelection = setSelection;
        this.getCanvas = function() { return canvas; };
        this.getPlotOffset = function() { return plotOffset; };
        this.getData = function() { return series; };
        this.getAxes = function() { return axes; };
        this.highlight = highlight;
        this.unhighlight = unhighlight;
        this.insertLabels = insertLabels;
        this.init=init;
        this.initParameter = constructCanvas;
        this.clearHighlights = clearHighlights;
        this.clear = function() { 
            ctx.clearRect(0, 0, canvasWidth, canvasHeight);
            octx.clearRect(0, 0, canvasWidth, canvasHeight);
            if ($.browser.msie) { 
                ctx.canvas.onPropertyChange = null;ctx.canvas.onResize = null;
                octx.canvas.onPropertyChange = null;octx.canvas.onResize = null;
                ctx.element_ = null; ctx.canvas = null; ctx.currentPath_ = null; ctx.m_ = null;
                octx.element_ = null; octx.canvas = null;octx.currentPath_ = null;octx.m_ = null;
            }
            target.unbind("plothover");
            eventHolder.each(function () {
                 this.onmousemove = null;
                 this.onmousedown = null;
                 this.onclick = null;
            }); 
            ctx = null,octx = null;
            eventHolder = null; target.html("");target = null;
            series = null; options = null; axes = null;
        };
    
        function clearHighlights() {
           if (highlights != null && highlights.length > 0) {                 // clean highlight points
               for (var i = 0; i < highlights.length; ++i) {
                  var h = highlights[i];
                  if (h.auto) {
                      unhighlight(h.series, h.point);
                  }
               }
           }
        }
        
        function init(data,options, mark, markOption, dataOffset) {  
          canvasWidth = target.width();
          canvasHeight = target.height();
          clearHighlights();
          parseOptions(options);
          setData(data);        
          if(mark != undefined) {
        	  markSeries = mark;
          }
          if(markOption != undefined) {
        	  markOptions = markOption;
          }
          if(dataOffset != undefined) {
        	  dataOffsets = dataOffset;
          }
          setupGrid();
          draw();
        }
        
        function setData(d) {
            series = parseData(d);
            fillInSeriesOptions();
            processData();
        }

        function setMark(d) {
            markSeries = parseData(d);
        }

        function parseData(d) {
            var res = [];
            for (var i = 0; i < d.length; ++i) {
                var s;
                if (d[i].data) {
                    s = {};
                    for (var v in d[i])
                        s[v] = d[i][v];
                }
                else {
                    s = { data: d[i] };
                }
                res.push(s);
            }

            return res;
        }
        
        function parseOptions(o) {
           options.xaxis.ticks = null;
            $.extend(true, options, o);

            // backwards compatibility, to be removed in future
            if (options.xaxis.noTicks && options.xaxis.ticks == null)
                options.xaxis.ticks = options.xaxis.noTicks;
            if (options.yaxis.noTicks && options.yaxis.ticks == null)
                options.yaxis.ticks = options.yaxis.noTicks;
            if (options.grid.coloredAreas)
                options.grid.markings = options.grid.coloredAreas;
            if (options.grid.coloredAreasColor)
                options.grid.markingsColor = options.grid.coloredAreasColor;
        }

        function fillInSeriesOptions() {
            var i;
            
            // collect what we already got of colors
            var neededColors = series.length,
                usedColors = [],
                assignedColors = [];
            for (i = 0; i < series.length; ++i) {
                var sc = series[i].color;
                if (sc != null) {
                    --neededColors;
                    if (typeof sc == "number")
                        assignedColors.push(sc);
                    else
                        usedColors.push(parseColor(series[i].color));
                }
            }
            
            // we might need to generate more colors if higher indices
            // are assigned
            for (i = 0; i < assignedColors.length; ++i) {
                neededColors = Math.max(neededColors, assignedColors[i] + 1);
            }

            // produce colors as needed
            var colors = [], variation = 0;
            i = 0;
            while (colors.length < neededColors) {
                var c;
                if (options.colors.length == i) // check degenerate case
                    c = new Color(100, 100, 100);
                else
                    c = parseColor(options.colors[i]);

                // vary color if needed
                var sign = variation % 2 == 1 ? -1 : 1;
                var factor = 1 + sign * Math.ceil(variation / 2) * 0.2;
                c.scale(factor, factor, factor);

                // FIXME: if we're getting to close to something else,
                // we should probably skip this one
                colors.push(c);
                
                ++i;
                if (i >= options.colors.length) {
                    i = 0;
                    ++variation;
                }
            }

            // fill in the options
            var colori = 0, s;
            for (i = 0; i < series.length; ++i) {
                s = series[i];

                // assign colors
                if (s.color == null) {
                    s.color = colors[colori].toString();
                    ++colori;
                }
                else if (typeof s.color == "number")
                    s.color = colors[s.color].toString();

                // copy the rest
                s.lines = $.extend(true, {}, options.lines, s.lines);
                s.points = $.extend(true, {}, options.points, s.points);
                s.bars = $.extend(true, {}, options.bars, s.bars);
                s.OLHC = $.extend(true,{},options.OLHC,s.OLHC);
                s.imagePoints = $.extend(true,{},options.imagePoints,s.imagePoints);
                s.candleStick = $.extend(true,{},options.candleStick,s.candleStick);
                if (s.shadowSize == null)
                    s.shadowSize = options.shadowSize;
                if (s.xaxis && s.xaxis == 2)
                    s.xaxis = axes.x2axis;
                else
                    s.xaxis = axes.xaxis;
                if (s.yaxis && s.yaxis == 2)
                    s.yaxis = axes.y2axis;
                else
                    s.yaxis = axes.yaxis;
            }
        }
        
        function processData() {
            var topSentry = Number.POSITIVE_INFINITY,
                bottomSentry = Number.NEGATIVE_INFINITY,
                axis;

            for (axis in axes) {
                axes[axis].datamin = topSentry;
                axes[axis].datamax = bottomSentry;
                axes[axis].used = false;
            }
            
            for (var i = 0; i < series.length; ++i) {
                var data = series[i].data,
                    axisx = series[i].xaxis,
                    axisy = series[i].yaxis,
                    mindelta = 0, maxdelta = 0;
                if(series[i].imagePoints&&series[i].imagePoints.show) continue;
                // make sure we got room for the bar
               /* if (series[i].bars.show) {
                    mindelta = series[i].bars.align == "left" ? 0 : -series[i].bars.barWidth/2;
                    maxdelta = mindelta + series[i].bars.barWidth;
                }*/ //comment by Jacye.
                
                axisx.used = axisy.used = true;
                for (var j = 0; j < data.length; ++j) {
                    if (data[j] == null)
                        continue;
                    
                    var x = data[j][0], y = data[j][1],ymin = data[j][1];
                    if((series[i].OLHC.show||series[i].candleStick.show)&&data[j].length>4)
                     { y = data[j][2]; ymindelta= data[j][3]; ymin = data[j][3]}//Jacye CHLO
                    // convert to number
                    if (x != null && !isNaN(x = +x)) {
                        if (x + mindelta < axisx.datamin)
                            axisx.datamin = x + mindelta;
                        if (x + maxdelta > axisx.datamax)
                            axisx.datamax = x + maxdelta;
                    }
                    
                    if (y != null && !isNaN(y = +y)) {
                        if (ymin < axisy.datamin)
                            axisy.datamin = ymin;
                        if (y > axisy.datamax)
                            axisy.datamax = y;
                    }
                }
            }

            for (axis in axes) {
                if (axes[axis].datamin == topSentry)
                    axes[axis].datamin = 0;
                if (axes[axis].datamax == bottomSentry)
                    axes[axis].datamax = 1;
            }
        }
     
      
        function constructCanvas(_option) {
          parseOptions(_option);   
          canvasWidth = target.width();
          canvasHeight = target.height();
          // for positioning labels and overlay
          if (canvasWidth <= 0 || canvasHeight <= 0)
          {
        	  canvasWidth = 1;
        	  canvasHeight = 1;
        	  //throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight;
          }
            // bind events
          if (options.selection.mode != null || options.crosshair.mode != null
                || options.grid.hoverable) {
                // FIXME: temp. work-around until jQuery bug 4398 is fixed
                eventHolder.each(function () {
                    this.onmousemove = onMouseMove;
                });
                if (options.selection.mode != null)
                    eventHolder.mousedown(onMouseDown);
            } 
            if (options.crosshair.mode != null)
                eventHolder.mouseout(onMouseOut);
            if (options.grid.clickable)
                eventHolder.click(onClick);
        }

        function setupGrid() {
            for (var axis in axes) {
                setupAxis(axes[axis], options[axis]);
            } 
           setSpacing();
           insertLabels();
           // insertLegend();
        }
        function setupAxis(axis, op) {
                setRange(axis, op);
                prepareTickGeneration(axis, op);
                setTicks(axis, op);
                // add transformation helpers
                if (axis == axes.xaxis || axis == axes.x2axis) {
                    // data point to canvas coordinate
                    axis.p2c = function (p) { return (p - axis.min) * axis.scale; };
                    // canvas coordinate to data point 
                    axis.c2p = function (c) { return axis.min + c / axis.scale; };
                }
                else {
                    axis.p2c = function (p) { return (axis.max - p) * axis.scale; };
                    axis.c2p = function (c) { return axis.max - c / axis.scale; };
                }
            }
        function setRange(axis, axisOptions) {
            var min = axisOptions.min != null ? axisOptions.min : axis.datamin;
            var max = axisOptions.max != null ? axisOptions.max : axis.datamax;
            if(axisOptions.posStyle) axis.posStyle = axisOptions.posStyle;
            if (max - min == 0.0) {
                // degenerate case
                var widen;
                if (max == 0.0)
                    widen = 1.0;
                else
                    widen = 0.01;
                min -= widen;
                max += widen;
            }
            else {
                // consider autoscaling
                var margin = axisOptions.autoscaleMargin;
                if (margin != null) {
                    if (axisOptions.min == null) {
                        min -= (max - min) * margin;
                        // make sure we don't go below zero if all values
                        // are positive
                        if (min < 0 && axis.datamin >= 0)
                            min = 0;
                    }
                    if (axisOptions.max == null) {
                        max += (max - min) * margin;
                        if (max > 0 && axis.datamax <= 0)
                            max = 0;
                    }
                }
            }
            axis.min = min;
            axis.max = max;
        }

        function prepareTickGeneration(axis, axisOptions) {
            // estimate number of ticks
            var noTicks;
            if (typeof axisOptions.ticks == "number" && axisOptions.ticks > 0)
                noTicks = axisOptions.ticks;
            else if (axis == axes.xaxis || axis == axes.x2axis)
                noTicks = canvasWidth / 100;
            else
                noTicks = canvasHeight / 60;
            
            var delta = (axis.max - axis.min) / noTicks;
            var size, generator, unit, formatter, i, magn, norm;

            if (axisOptions.mode == "time") {
                // pretty handling of time
                
                function formatDate(d, fmt, monthNames) {
                    var leftPad = function(n) {
                        n = "" + n;
                        return n.length == 1 ? "0" + n : n;
                    };
                    
                    var r = [];
                    var escape = false;
                    if (monthNames == null)
                        monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
                    for (var i = 0; i < fmt.length; ++i) {
                        var c = fmt.charAt(i);
                        
                        if (escape) {
                            switch (c) {
                            case 'h': c = "" + d.getUTCHours(); break;
                            case 'H': c = leftPad(d.getUTCHours()); break;
                            case 'M': c = leftPad(d.getUTCMinutes()); break;
                            case 'S': c = leftPad(d.getUTCSeconds()); break;
                            case 'd': c = "" + d.getUTCDate(); break;
                            case 'm': c = "" + (d.getUTCMonth() + 1); break;
                            case 'y': c = "" + d.getUTCFullYear(); break;
                            case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
                            }
                            r.push(c);
                            escape = false;
                        }
                        else {
                            if (c == "%")
                                escape = true;
                            else
                                r.push(c);
                        }
                    }
                    return r.join("");
                }
                
                    
                // map of app. size of time units in milliseconds
                var timeUnitSize = {
                    "second": 1000,
                    "minute": 60 * 1000,
                    "hour": 60 * 60 * 1000,
                    "day": 24 * 60 * 60 * 1000,
                    "month": 30 * 24 * 60 * 60 * 1000,
                    "year": 365.2425 * 24 * 60 * 60 * 1000
                };


                // the allowed tick sizes, after 1 year we use
                // an integer algorithm
                var spec = [
                    [1, "second"], [2, "second"], [5, "second"], [10, "second"],
                    [30, "second"], 
                    [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
                    [30, "minute"], 
                    [1, "hour"], [2, "hour"], [4, "hour"],
                    [8, "hour"], [12, "hour"],
                    [1, "day"], [2, "day"], [3, "day"],
                    [0.25, "month"], [0.5, "month"], [1, "month"],
                    [2, "month"], [3, "month"], [6, "month"],
                    [1, "year"]
                ];

                var minSize = 0;
                if (axisOptions.minTickSize != null) {
                    if (typeof axisOptions.tickSize == "number")
                        minSize = axisOptions.tickSize;
                    else
                        minSize = axisOptions.minTickSize[0] * timeUnitSize[axisOptions.minTickSize[1]];
                }

                for (i = 0; i < spec.length - 1; ++i)
                    if (delta < (spec[i][0] * timeUnitSize[spec[i][1]]
                                 + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
                       && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize)
                        break;
                size = spec[i][0];
                unit = spec[i][1];
                
                // special-case the possibility of several years
                if (unit == "year") {
                    magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10));
                    norm = (delta / timeUnitSize.year) / magn;
                    if (norm < 1.5)
                        size = 1;
                    else if (norm < 3)
                        size = 2;
                    else if (norm < 7.5)
                        size = 5;
                    else
                        size = 10;

                    size *= magn;
                }

                if (axisOptions.tickSize) {
                    size = axisOptions.tickSize[0];
                    unit = axisOptions.tickSize[1];
                }
                
                generator = function(axis) {
                    var ticks = [],
                        tickSize = axis.tickSize[0], unit = axis.tickSize[1],
                        d = new Date(axis.min);
                    
                    var step = tickSize * timeUnitSize[unit];

                    if (unit == "second")
                        d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize));
                    if (unit == "minute")
                        d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize));
                    if (unit == "hour")
                        d.setUTCHours(floorInBase(d.getUTCHours(), tickSize));
                    if (unit == "month")
                        d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize));
                    if (unit == "year")
                        d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize));
                    
                    // reset smaller components
                    d.setUTCMilliseconds(0);
                    if (step >= timeUnitSize.minute)
                        d.setUTCSeconds(0);
                    if (step >= timeUnitSize.hour)
                        d.setUTCMinutes(0);
                    if (step >= timeUnitSize.day)
                        d.setUTCHours(0);
                    if (step >= timeUnitSize.day * 4)
                        d.setUTCDate(1);
                    if (step >= timeUnitSize.year)
                        d.setUTCMonth(0);


                    var carry = 0, v = Number.NaN, prev;
                    do {
                        prev = v;
                        v = d.getTime();
                        ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
                        if (unit == "month") {
                            if (tickSize < 1) {
                                // a bit complicated - we'll divide the month
                                // up but we need to take care of fractions
                                // so we don't end up in the middle of a day
                                d.setUTCDate(1);
                                var start = d.getTime();
                                d.setUTCMonth(d.getUTCMonth() + 1);
                                var end = d.getTime();
                                d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
                                carry = d.getUTCHours();
                                d.setUTCHours(0);
                            }
                            else
                                d.setUTCMonth(d.getUTCMonth() + tickSize);
                        }
                        else if (unit == "year") {
                            d.setUTCFullYear(d.getUTCFullYear() + tickSize);
                        }
                        else
                            d.setTime(v + step);
                    } while (v < axis.max && v != prev);

                    return ticks;
                };

                formatter = function (v, axis) {
                    var d = new Date(v);

                    // first check global format
                    if (axisOptions.timeformat != null)
                        return formatDate(d, axisOptions.timeformat, axisOptions.monthNames);
                    
                    var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
                    var span = axis.max - axis.min;
                    
                    if (t < timeUnitSize.minute)
                        fmt = "%h:%M:%S";
                    else if (t < timeUnitSize.day) {
                        if (span < 2 * timeUnitSize.day)
                            fmt = "%h:%M";
                        else
                            fmt = "%b %d %h:%M";
                    }
                    else if (t < timeUnitSize.month)
                        fmt = "%b %d";
                    else if (t < timeUnitSize.year) {
                        if (span < timeUnitSize.year)
                            fmt = "%b";
                        else
                            fmt = "%b %y";
                    }
                    else
                        fmt = "%y";
                    
                    return formatDate(d, fmt, axisOptions.monthNames);
                };
            }
            else {
                // pretty rounding of base-10 numbers
                var maxDec = axisOptions.tickDecimals;
                var dec = -Math.floor(Math.log(delta) / Math.LN10);
                if (maxDec != null && dec > maxDec)
                    dec = maxDec;
                
                magn = Math.pow(10, -dec);
                norm = delta / magn; // norm is between 1.0 and 10.0
                
                if (norm < 1.5)
                    size = 1;
                else if (norm < 3) {
                    size = 2;
                    // special case for 2.5, requires an extra decimal
                    if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
                        size = 2.5;
                        ++dec;
                    }
                }
                else if (norm < 7.5)
                    size = 5;
                else
                    size = 10;

                size *= magn;
                
                if (axisOptions.minTickSize != null && size < axisOptions.minTickSize)
                    size = axisOptions.minTickSize;

                if (axisOptions.tickSize != null)
                    size = axisOptions.tickSize;
                
                axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec);
                
                generator = function (axis) {
                    var ticks = [];

                    // spew out all possible ticks
                    var start = floorInBase(axis.min, axis.tickSize),
                        i = 0, v = Number.NaN, prev;
                    do {
                        prev = v;
                        v = start + i * axis.tickSize;
                        ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
                        ++i;
                    } while (v < axis.max && v != prev);
                    return ticks;
                };

                formatter = function (v, axis) {
                    return v.toFixed(axis.tickDecimals);
                };
            }

            axis.tickSize = unit ? [size, unit] : size;
            axis.tickGenerator = generator;
            if ($.isFunction(axisOptions.tickFormatter))
                axis.tickFormatter = function (v, axis) { return "" + axisOptions.tickFormatter(v, axis); };
            else
                axis.tickFormatter = formatter;
            if (axisOptions.labelWidth != null)
                axis.labelWidth = axisOptions.labelWidth;
            if (axisOptions.labelHeight != null)
                axis.labelHeight = axisOptions.labelHeight;
        }
        
        function setTicks(axis, axisOptions) {
            axis.ticks = [];
            if (!axis.used)
                return;
            if (axisOptions.showLabel) {
                axis.showLabel = axisOptions.showLabel
            } // Jacye.
			if (axisOptions.backgroundColor) {
                axis.backgroundColor = axisOptions.backgroundColor
            } // Jacye.
            if (axisOptions.ticks == null) {
                axis.ticks = axis.tickGenerator(axis);
            } else if (typeof axisOptions.ticks == "number") {
                if (axisOptions.ticks > 0) {
                    axis.ticks = axis.tickGenerator(axis);
                }    
            }
            else if (axisOptions.ticks) {
                var ticks = axisOptions.ticks;
                if ($.isFunction(ticks)) {
                    // generate the ticks
                    ticks = ticks({ min: axis.min, max: axis.max });
                }
                // clean up the user-supplied ticks, copy them over
                var i, v;
                for (i = 0; i < ticks.length; ++i) {
                    var label = null;
                    var t = ticks[i];
                    if (typeof t == "object") {
                        v = t[0];
                        if (t.length > 1)
                            label = t[1];
                    } else {
                        v = t;
                    }    
                    if (label == null) {
                        label = axis.tickFormatter(v, axis);
                    }
                    axis.ticks[i] = { v: v, label: label };
                }
            }
            if (axisOptions.autoscaleMargin != null && axis.ticks.length > 0) {
                // snap to ticks
                if (axisOptions.min == null)
                    axis.min = Math.min(axis.min, axis.ticks[0].v);
                if (axisOptions.max == null && axis.ticks.length > 1) {
                    //axis.max = Math.min(axis.max, axis.ticks[axis.ticks.length - 1].v);  // change by Jacye. max
                    var dx = 0;
                    if (axis.ticks.length > 1) {
                       dx = axis.tickSize / 2;
                       axis.max = Math.max(axis.max, axis.ticks[axis.ticks.length - 1].v - dx);
                    } else {
                       axis.max = Math.min(axis.max, axis.ticks[axis.ticks.length - 1].v);
                    }  
                }               
            }
        }
        
        function setSpacing() {
            function measureXLabels(axis) {
                // to avoid measuring the widths of the labels, we
                // construct fixed-size boxes and put the labels inside
                // them, we don't need the exact figures and the 
                // fixed-size box content is easy to center
                if(!axis.showLabel) return;
                if (axis.labelWidth == null)
                    axis.labelWidth = canvasWidth / 6;

                // measure x label heights
                if (axis.labelHeight == null) {
                    labels = [];
                    for (i = 0; i < axis.ticks.length; ++i) {
                        l = axis.ticks[i].label;
                        if (l)
                            labels.push('<div class="tickLabel" style="float:left;width:' + axis.labelWidth + 'px">' + l + '</div>');
                    }
                    
                    axis.labelHeight = 0;
                    if (labels.length > 0) {
                       // var dummyDiv = $('<div style="position:absolute;top:-10000px;width:10000px;">'
                        //                 + labels.join("") + '<div style="clear:left"></div></div>').appendTo(target);
                        target.append('<div style="position:absolute;top:-10000px;width:10000px;">' + labels.join("") + '<div style="clear:left"></div></div>');
                        axis.labelHeight = 12;//dummyDiv.height();
                       // dummyDiv.remove();
                    }
                }
            }
            
            function measureYLabels(axis) {
                if (axis.labelWidth == null || axis.labelHeight == null) {
                    var i, labels = [], l;
                    // calculate y label dimensions
                    for (i = 0; i < axis.ticks.length; ++i) {
                        l = axis.ticks[i].label;
                        if (l)
                            labels.push('<div class="tickLabel">' + l + '</div>');
                    }
                    
                    if (labels.length > 0) {
                        var dummyDiv = $('<div style="position:absolute;top:-10000px;">'
                                         + labels.join("") + '</div>').appendTo(target);
                        if (axis.labelWidth == null)
                            axis.labelWidth = dummyDiv.width();
                        if (axis.labelHeight == null)
                            axis.labelHeight = dummyDiv.find("div").height();
                            dummyDiv.remove();
                    }
                    
                    if (axis.labelWidth == null)
                        axis.labelWidth = 0;
                    if (axis.labelHeight == null)
                        axis.labelHeight = 0;
                }
            }
            
              measureXLabels(axes.xaxis);
              measureYLabels(axes.yaxis);
          //  measureXLabels(axes.x2axis);
           // measureYLabels(axes.y2axis);

            // get the most space needed around the grid for things
            // that may stick out
            var maxOutset = options.grid.borderWidth / 2;
            for (i = 0; i < series.length; ++i)
                maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2));

            //plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 2;//maxOutset; Jacye
            plotOffset.left = 0;
            plotOffset.right = plotOffset.top = plotOffset.bottom = 2;//maxOutset; Jacye

            if (axes.xaxis.showLabel&&axes.xaxis.labelHeight > 0&&!axes.xaxis.posStyle&&!axes.xaxis.posStyle!="inner")//Jacye
                plotOffset.bottom = Math.max(0, axes.xaxis.labelHeight + options.grid.labelMargin);//jacye
            if (axes.yaxis.showLabel&&axes.yaxis.labelWidth > 0)//Jacye
                plotOffset.left = Math.max(maxOutset, axes.yaxis.labelWidth + options.grid.labelMargin);

            if (axes.x2axis.showLabel&&axes.x2axis.labelHeight > 0)//Jacye
                plotOffset.top = Math.max(0, axes.x2axis.labelHeight + options.grid.labelMargin);//Jacye
            
            if (axes.y2axis.showLabel&&axes.y2axis.labelWidth > 0)//Jacye
                plotOffset.right = Math.max(maxOutset, axes.y2axis.labelWidth + options.grid.labelMargin);

            plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
            plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;

            // precompute how much the axis is scaling a point in canvas space
            axes.xaxis.scale = parseFloat((plotWidth / (axes.xaxis.max - axes.xaxis.min)).toFixed(5));
            axes.yaxis.scale = parseFloat((plotHeight / (axes.yaxis.max - axes.yaxis.min)).toFixed(5));
            axes.x2axis.scale = plotWidth / (axes.x2axis.max - axes.x2axis.min);
            axes.y2axis.scale = plotHeight / (axes.y2axis.max - axes.y2axis.min);
        }
        
        function draw() {
            drawGrid();
            for (var i = 0; i < series.length; i++) {
                drawSeries(series[i]);
            }
        }
        
        function extractRange(ranges, coord) {
            var firstAxis = coord + "axis",
                secondaryAxis = coord + "2axis",
                axis, from, to, reverse;

            if (ranges[firstAxis]) {
                axis = axes[firstAxis];
                from = ranges[firstAxis].from;
                to = ranges[firstAxis].to;
            }
            else if (ranges[secondaryAxis]) {
                axis = axes[secondaryAxis];
                from = ranges[secondaryAxis].from;
                to = ranges[secondaryAxis].to;
            }
            else {
                // backwards-compat stuff - to be removed in future
                axis = axes[firstAxis];
                from = ranges[coord + "1"];
                to = ranges[coord + "2"];
            }

            // auto-reverse as an added bonus
            if (from != null && to != null && from > to)
                return { from: to, to: from, axis: axis };
            
            return { from: from, to: to, axis: axis };
        }
        
        function drawGrid() {
            var i;
            
            ctx.save();
            ctx.clearRect(0, 0, canvasWidth, canvasHeight);
             if (options.grid.borderWidth) {
                // draw border
                ctx.lineWidth = 1;//options.grid.borderWidth;
                ctx.strokeStyle =options.grid.tickColor;// options.grid.color;
               // ctx.lineJoin = "round";
                ctx.beginPath();
                ctx.moveTo(0,ctx.lineWidth/2);
                ctx.lineTo(plotWidth+plotOffset.left+ctx.lineWidth/2,ctx.lineWidth/2);
                ctx.lineTo(plotWidth+plotOffset.left+ctx.lineWidth/2,plotHeight+plotOffset.top+ctx.lineWidth/2);
                ctx.lineTo(0,plotHeight+plotOffset.top+ctx.lineWidth/2);
                ctx.moveTo(plotOffset.left+ctx.lineWidth/2,0);
                ctx.lineTo(plotOffset.left+ctx.lineWidth/2,plotHeight+plotOffset.top);
                ctx.stroke();
               // ctx.strokeRect(0, 0, plotWidth, plotHeight);
            }
            ctx.translate(plotOffset.left, plotOffset.top);

            // draw background, if any
           if (options.grid.backgroundColor) {
                ctx.fillStyle = options.grid.backgroundColor;
                ctx.fillRect(0, 0, plotWidth, plotHeight);
            }
            /*var g = ctx.createLinearGradient(0, 0, 0,plotHeight);
             g.addColorStop(0, '#ffffff');
             g.addColorStop(1, '#d7d7d7');
             ctx.fillStyle = g;
             ctx.fillRect(0, 0, plotWidth, plotHeight);
             */
            // draw markings
            if (options.grid.markings) {
                var markings = options.grid.markings;
                if ($.isFunction(markings))
                    // xmin etc. are backwards-compatible, to be removed in future
                    markings = markings({ xmin: axes.xaxis.min, xmax: axes.xaxis.max, ymin: axes.yaxis.min, ymax: axes.yaxis.max, xaxis: axes.xaxis, yaxis: axes.yaxis, x2axis: axes.x2axis, y2axis: axes.y2axis });

                for (i = 0; i < markings.length; ++i) {
                    var m = markings[i],
                        xrange = extractRange(m, "x"),
                        yrange = extractRange(m, "y");

                    // fill in missing
                    if (xrange.from == null)
                        xrange.from = xrange.axis.min;
                    if (xrange.to == null)
                        xrange.to = xrange.axis.max;
                    if (yrange.from == null)
                        yrange.from = yrange.axis.min;
                    if (yrange.to == null)
                        yrange.to = yrange.axis.max;

                    // clip
                    if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
                        yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
                        continue;

                    xrange.from = Math.max(xrange.from, xrange.axis.min);
                    xrange.to = Math.min(xrange.to, xrange.axis.max);
                    yrange.from = Math.max(yrange.from, yrange.axis.min);
                    yrange.to = Math.min(yrange.to, yrange.axis.max);

                    if (xrange.from == xrange.to && yrange.from == yrange.to)
                        continue;

                    // then draw
                    xrange.from = xrange.axis.p2c(xrange.from);
                    xrange.to = xrange.axis.p2c(xrange.to);
                    yrange.from = yrange.axis.p2c(yrange.from);
                    yrange.to = yrange.axis.p2c(yrange.to);
                    
                    if (xrange.from == xrange.to || yrange.from == yrange.to) {
                        // draw line
                        ctx.strokeStyle = m.color || options.grid.markingsColor;
                        ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth;
                        ctx.moveTo(Math.floor(xrange.from), Math.floor(yrange.from));
                        ctx.lineTo(Math.floor(xrange.to), Math.floor(yrange.to));
                        ctx.stroke();
                    }
                    else {
                        // fill area
                        ctx.fillStyle = m.color || options.grid.markingsColor;
                        ctx.fillRect(Math.floor(xrange.from),
                                     Math.floor(yrange.to),
                                     Math.floor(xrange.to - xrange.from),
                                     Math.floor(yrange.from - yrange.to));
                    }
                }
            }
            
            // draw the inner grid
            ctx.lineWidth = 1;
            ctx.strokeStyle = options.grid.tickColor;
            ctx.beginPath();
            var v, axis = axes.xaxis;
            var interval = options.xaxis.interval;
            for (i = 0; i < axis.ticks.length; i=i+interval) {
                v = axis.ticks[i].v;
                if (isNaN(v)||v <= axis.min || v >= axes.xaxis.max)
                    continue;   // skip those lying on the axes

                ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 0);
                ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, plotHeight);
            }

            axis = axes.yaxis;
            for (i = 0; i < axis.ticks.length; ++i) {
                v = axis.ticks[i].v;
                if (v <= axis.min || v >= axis.max)
                    continue;

                ctx.moveTo(plotOffset.left*(-1), Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
                ctx.lineTo(plotWidth, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
            }

            axis = axes.x2axis;
            for (i = 0; i < axis.ticks.length; ++i) {
                v = axis.ticks[i].v;
                if (v <= axis.min || v >= axis.max)
                    continue;
    
                ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, -5);
                ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 5);
            }

            axis = axes.y2axis;
            for (i = 0; i < axis.ticks.length; ++i) {
                v = axis.ticks[i].v;
                if (v <= axis.min || v >= axis.max)
                    continue;

                ctx.moveTo(plotWidth-5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
                ctx.lineTo(plotWidth+5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
            }
            
            ctx.stroke();
            
          
          ctx.restore();
        }
        
        function getAxisLabelHtml(ax)
        { var axis ,tp,tick, str = "";
          if(ax=="xaxis") { axis = axes.xaxis; tp = plotOffset.top + plotHeight + options.grid.labelMargin;
          var xOffset = options.xaxis.offset;
           if(axis.showLabel)
           {
          		if(axis.backgroundColor != null)
          		{
          			
          			var preStr = '<div style="display:inline; position:absolute; top:' + (axis.posStyle&&axis.posStyle=="inner"?(tp-18):(tp - 4))  + 'px; left:0px; background-color:' + axis.backgroundColor + '; width:' + (canvasWidth-1) + 'px; height:21px; border-width:0px 0px 1px 0px; border-style:solid; border-color:#C5C5C5 ">';
          			if(options.xaxis.style) {
          				preStr = '<div style="display:inline; position:absolute; top:' + (axis.posStyle&&axis.posStyle=="inner"?(tp-18):(tp - 4))  + 'px; left:0px; width:' + (canvasWidth-1) + 'px; ' + options.xaxis.style + '">';	
          			}
          			str += preStr;
		            for (var i = 0; i < axis.ticks.length; ++i)
		            { tick = axis.ticks[i];
		             if (!tick.label || tick.v < axis.min || tick.v > axis.max) continue;    
		             if(options.xaxis.link) {
		            	 var link = options.xaxis.link.replace("#param", tick.v);
		            	 tick.label = '<a href="' + link + '" id="a' + tick.v + '">' + tick.label + '</a>';
		             }
		             var textAlign = options.xaxis.textAlign;
		             if(textAlign == null) {
		             	 str += '<div style="position:absolute;top:3px;left:' + (xOffset + plotOffset.left + axis.p2c(tick.v) ) + 'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + "</div>";
		             } else { 
			             var xLabelWidth = (target.width() - axis.labelWidth)/axis.ticks.length; 
			             str += '<div style="position:absolute;top:3px;left:' + (plotOffset.left + axis.p2c(tick.v) ) + 'px;width:' + xLabelWidth + 'px;text-align:'+textAlign+'" class="tickLabel">' + tick.label + "</div>";
		             }
		            }
		            str += '</div>';
	            }
	            else
	            {
	             	for (var i = 0; i < axis.ticks.length; ++i)
		            { tick = axis.ticks[i];
		             if (!tick.label || tick.v < axis.min || tick.v > axis.max) continue;    
		             if(options.xaxis.link) tick.label = '<a href="' + options.xaxis.link + '">' + tick.label + '</a>';
		             str += '<div style="position:absolute;top:' + (axis.posStyle&&axis.posStyle=="inner"?(tp-18):tp)  + 'px;left:' + (xOffset + plotOffset.left + axis.p2c(tick.v) ) + 'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + "</div>";
		            }
	            }
            }
           }
          else if(ax == "yaxis") { axis = axes.yaxis;
            if(axis.showLabel)
            {
             for (var i = 0; i < axis.ticks.length; ++i)
             {tick = axis.ticks[i];
              if (!tick.label || tick.v < axis.min || tick.v > axis.max) continue;    
              str+='<div style="position:absolute;top:' + (plotOffset.top + axis.p2c(tick.v) - axis.labelHeight) + 'px;right:' + (plotOffset.right + plotWidth + options.grid.labelMargin) + 'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + "</div>";
             }
            }
          }
          else if(ax == "x2axis") {axis = axes.x2axis;   
          if(axis.showLabel){
            for (var i = 0; i < axis.ticks.length; ++i)
            {tick = axis.ticks[i];
             if (!tick.label || tick.v < axis.min || tick.v > axis.max) continue;    
            str+='<div style="position:absolute;bottom:' + (plotOffset.bottom + plotHeight + options.grid.labelMargin) + 'px;left:' + (plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2) + 'px;width:' + axis.labelWidth + 'px;text-align:center" class="tickLabel">' + tick.label + '</div>';
            }
          }
          }
          else if(ax == "y2axis") 
          {axis = axes.y2axis;
           if(axis.showLabel){
            for (var i = 0; i < axis.ticks.length; ++i)
            {tick = axis.ticks[i]; 
            if (!tick.label || tick.v < axis.min || tick.v > axis.max) continue;            
            str+='<div style="position:absolute;top:' + (plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2) + 'px;left:' + (plotOffset.left + plotWidth + options.grid.labelMargin) +'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + '</div>';
            }
          }
          }
          return str;
        }
        function insertLabels() {
            var $TickerContainer = target.find(".tickLabels");
            if($TickerContainer.length<1) target.append('<div class="tickLabels" style="color:' + options.grid.color + '"></div>');   
            else  $TickerContainer.html("");
            var html = '';
            html+=getAxisLabelHtml("xaxis");
            html+=getAxisLabelHtml("x2axis");
            html+=getAxisLabelHtml("yaxis");
            html+=getAxisLabelHtml("y2axis");
            target.find(".tickLabels").html(html);
            $TickerContainer = null;
           html=null;
        }

        function drawSeries(series) {
            if (series.lines.show || (!series.bars.show && !series.points.show&&!series.OLHC.show&&!series.candleStick.show&&!series.imagePoints.show))
                drawSeriesLines(series);
            if (series.bars.show)
                drawSeriesBars(series);
            if (series.points.show)
                drawSeriesPoints(series);
            if(series.OLHC.show)
            {
            	 drawSeriesOLHC(series);
            }
            if(series.candleStick.show)
            { drawSeriesCandleStick(series);
            }
            if(series.imagePoints.show)
            {
              drawSeriesImage(series);
            }
        }
        
       function getDx(lg) {
            if (plotWidth <= 0) {
                dx = 1;
            } else {
                dx = Math.ceil(lg/plotWidth);
            }
            return dx;
       }
        function drawSeriesLines(series) {
            function plotLine(data, offset, axisx, axisy) {
                var prev, cur = null, drawx = null, drawy = null, color = null;
                var lg  = data.length;
                var ix = getDx(lg); 
                ctx.beginPath();
                var x1,y1,x2,y2;
                for (var i = 0; i < lg; i+=dx) {                    
                    prev = cur;
                    if (data[i] != null && !isNaN(data[i][1])) {
                        cur = data[i];                                      // update by Jacye
                    } else {
                        continue;
                    }
                    if (cur == null)
                        continue;             
                    if(prev != null ) {
                        x1 = prev[0], y1 = prev[1];
                    }
                    x2 = cur[0], y2 = cur[1];
                    if(y2 < 0) continue; 
                    if(color == null) color = cur[2];
                    drawx = axisx.p2c(x2);
                    drawy = axisy.p2c(y2) + offset;
                    if (prev == null || y1 < 0) { // the first point or the same point.
                        ctx.moveTo(drawx, drawy);
                    } else {     // different points
                        ctx.lineTo(drawx, drawy);
                    }
                }
                if(color != null) {
                	ctx.strokeStyle = color;
                }
                ctx.stroke();
            }

            function plotLineArea(data, axisx, axisy) {
                var prev, cur = null;             
                var bottom = Math.min(Math.max(0, axisy.min), axisy.max);
                var top, lastX = 0;
                var areaOpen = false;     
                var x1,y1,x2,y2,x1old, x2old;        
                for (var i = 0; i < data.length; ++i) {
                    prev = cur;
                    cur = data[i];
                    if (areaOpen && prev != null && cur == null) {
                        // close area
                        ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
                        ctx.fill();
                        areaOpen = false;
                        continue;
                    }
                    if (prev == null || cur == null)
                        continue;                  
                    x1 = prev[0], y1 = prev[1], x2 = cur[0], y2 = cur[1];
                    // clip x values          
                    // clip with xmin
                    if (x1 <= x2 && x1 < axisx.min) {
                        if (x2 < axisx.min)
                            continue;
                        y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
                        x1 = axisx.min;
                    }
                    else if (x2 <= x1 && x2 < axisx.min) {
                        if (x1 < axisx.min)
                            continue;
                        y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
                        x2 = axisx.min;
                    }
                    // clip with xmax
                    if (x1 >= x2 && x1 > axisx.max) {
                        if (x2 > axisx.max)
                            continue;
                        y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
                        x1 = axisx.max;
                    }
                    else if (x2 >= x1 && x2 > axisx.max) {
                        if (x1 > axisx.max)
                            continue;
                        y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
                        x2 = axisx.max;
                    }
                    if (!areaOpen) {
                        // open area
                        ctx.beginPath();
                        ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
                        areaOpen = true;
                    }                 
                    // now first check the case where both is outside
                    if (y1 >= axisy.max && y2 >= axisy.max) {
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
                        continue;
                    }
                    else if (y1 <= axisy.min && y2 <= axisy.min) {
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
                        continue;
                    }                   
                    // else it's a bit more complicated, there might
                    // be two rectangles and two triangles we need to fill
                    // in; to find these keep track of the current x values
                    x1old = x1, x2old = x2;
                    // and clip the y values, without shortcutting                
                    // clip with ymin
                    if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
                        x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
                        y1 = axisy.min;
                    }
                    else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
                        x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
                        y2 = axisy.min;
                    }

                    // clip with ymax
                    if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
                        x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
                        y1 = axisy.max;
                    }
                    else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
                        x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
                        y2 = axisy.max;
                    }
                    // if the x value was changed we got a rectangle
                    // to fill
                    if (x1 != x1old) {
                        if (y1 <= axisy.min)
                            top = axisy.min;
                        else
                            top = axisy.max;
                        
                        ctx.lineTo(axisx.p2c(x1old), axisy.p2c(top));
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(top));
                    }
                    
                    // fill the triangles
                    ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1));
                    ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));

                    // fill the other rectangle if it's there
                    if (x2 != x2old) {
                        if (y2 <= axisy.min)
                            top = axisy.min;
                        else
                            top = axisy.max;
                        
                        ctx.lineTo(axisx.p2c(x2old), axisy.p2c(top));
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(top));
                    }
                    lastX = Math.max(x2, x2old);
                }
                if (areaOpen) {
                    ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
                    ctx.fill();
                }
            }            
            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            ctx.lineJoin = "round";
            var lw = series.lines.lineWidth;
            if (series.lineW != null) lw = series.lineW;
            var sw = series.shadowSize;
            // FIXME: consider another form of shadow when filling is turned on
            if (sw > 0) {
                // draw shadow in two steps
                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.1)";
                plotLine(series.data, lw/2 + sw/2 + ctx.lineWidth/2, series.xaxis, series.yaxis);
                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.2)";
                plotLine(series.data, lw/2 + ctx.lineWidth/2, series.xaxis, series.yaxis);
            }

            ctx.lineWidth = lw;
            ctx.strokeStyle = series.color;
            setFillStyle(series.lines, series.color);
            if (series.lines.fill)
                plotLineArea(series.data, series.xaxis, series.yaxis);
            plotLine(series.data, 0, series.xaxis, series.yaxis);
            ctx.restore();
        }
       
        function drawSeriesOLHC(series) {          
        	function  plotOLHC(data, offset,axisx,axisy,olhcOption) {   
        	    ctx.beginPath();
        	    var w = (canvasWidth-plotOffset.left-plotOffset.right-offset)/data.length;
        	    if (w > olhcOption.maxBarWidth) w = olhcOption.maxBarWidth;
        	    if (w < olhcOption.minBarWidth) w = olhcOption.minBarWidth;
        	    olhcOption.barWidth = w;
        	    var x, c, h, l, o, px, pc, po, pl, ph;
        	    var maxW = canvasWidth-plotOffset.left-plotOffset.right-offset-w/2;
        	    var lg = data.length;
        		for (var i = 0; i < lg; ++i) {
        			if (data[i] == null) continue;
        			var dt = data[i];
        			if (dt.length < 6 || isNaN(dt[1]) || isNaN(dt[2]) || isNaN(dt[3]) || isNaN(dt[4])) continue;
        			x=dt[0], c = dt[1],h= dt[2], l=dt[3], o = dt[4];
        			px = axisx.p2c(x);
        			pc = axisy.p2c(c), po = axisy.p2c(o), pl = axisy.p2c(l), ph = axisy.p2c(h);
        			if (i == 0 && px < w/2)  px = w/2;
        			if (i == lg-1&& px > maxW) px = maxW;      			
        			ctx.moveTo(px,ph);
        			ctx.lineTo(px,pl);
        			ctx.moveTo(px,po);
        			ctx.lineTo(px-w/2,po);
        			ctx.moveTo(px,pc);
        			ctx.lineTo(px+w/2,pc);      			
        		}
        		ctx.stroke();
            }
            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            ctx.lineJoin = "round";
            ctx.strokeStyle = series.color;
            setFillStyle(series.OLHC, series.color);
            plotOLHC(series.data, 0, series.xaxis, series.yaxis,series.OLHC);
            ctx.restore();	
        }   
        function drawCandleStick(px,po,pl,ph,pc,dt,aw,clo,isFilled,ct) { 
        	ct.moveTo(px-aw/2,po);
        	ct.lineTo(px+aw/2,po);
        	if (pc != po) {
        	    ct.lineTo(px+aw/2,pc);
        	    ct.lineTo(px-aw/2,pc);
        	    ct.lineTo(px-aw/2,po);
        	}
            ct.moveTo(px,pl);
            var pM = po>pc?po:pc;
            var pL =  po>pc?pc:po;
        	if (pl != pM) {
        	    ct.lineTo(px,pM);
        	}
        	ct.moveTo(px,ph);
        	if(ph != pL) {
        	    ct.lineTo(px,pL);
        	}
        }
        
        function drawDividendImg(x,y,ct) {    
            ct.strokeStyle = "rgb(47, 47, 128)";
            ct.lineWidth = 2;
            ct.beginPath();
            ct.lineCap = "butt";
            ct.fillStyle="rgb(47,72,128)";
            ct.arc(x,y,9,0,2*Math.PI,true);
            ct.fill();
            ct.fillStyle="rgb(255,255,255)";
            ct.fillRect(x-6,y-4,10,10);
            ct.fillRect(x+1,y-5,5,5);
            ct.moveTo(x+1,y-5);
            ct.lineTo(x+1,y);
            ct.lineTo(x+6,y);
            ct.stroke();
        }
        
        function drawSplitsImg(x,y,ct) {    
            ct.strokeStyle = "rgb(47, 47, 128)";
            ct.lineWidth = 2;
            ct.beginPath();
            ct.lineCap = "butt";
            ct.fillStyle="rgb(47,72,128)";
            ct.arc(x,y,9,0,2*Math.PI,true);
            ct.fill();
            ct.fillStyle="rgb(255,255,255)";
            ct.fillRect(x-5,y-5,10,10);
            ct.moveTo(x-5,y+5);
            ct.lineTo(x+5,y-5);
            ct.stroke();
        }
        function drawSeriesCandleStick(series) {   
            function drawColorCandle(pdata,clo, axisx,axisy,aw,isFilled) {
                var filldata = [];
        	    var lg = pdata.length;
        	    var dt, x, c , h, l, o, px, pc, po, pl, ph;
        	    var maxW = canvasWidth-plotOffset.right-plotOffset.left - aw/2;
                ctx.strokeStyle = clo;
                ctx.lineWidth=1;
        	    ctx.beginPath();
        	    for(var k = 0; k < lg; k++) { 
        	        dt = pdata[k];
        	        x=dt[0], c = dt[1],h = dt[2], l=dt[3], o = dt[4];
        			px = axisx.p2c(x);
        			pc = axisy.p2c(c), po = axisy.p2c(o), pl = axisy.p2c(l), ph = axisy.p2c(h);
        			if (k == (lg-1) && px>maxW) {
        			    px= maxW;
        			}
        			if (k == 0 && px < aw/2) {
        			    px=aw/2;
        			}
        			if(c<o) { // close price <open price fill the bar
        			    filldata.push([px,po,pc]);
        			}
        			drawCandleStick(px,po,pl,ph,pc,dt,aw,clo,isFilled,ctx)
        	    }
        	    ctx.stroke();
        	    if (filldata.length > 0) { // filled the candlesticks which need to be filled.
        	        ctx.lineWidth = aw; 
        	        ctx.lineCap="butt";
        	        ctx.beginPath();
        	        for (var j = 0;j < filldata.length; j++){ 
        	            if(filldata[j][1] != filldata[j][2]) {
        	                ctx.moveTo(filldata[j][0],filldata[j][1]);
        	                ctx.lineTo(filldata[j][0],filldata[j][2]);
        	            }
        	        }
        	        ctx.stroke();
        	    }
            }
        	function plotCandleStick(data, offset, axisx,axisy,candleOption) {
        	    var maxwidth = (candleOption.maxCandleWidth==null)?16:candleOption.maxCandleWidth;
        	    var minwidth = (candleOption.minCandleWidth==null)?4:candleOption.minCandleWidth;
        	    var aw = Math.floor(0.7*(canvasWidth-plotOffset.left-plotOffset.right)/data.length);  	
                var upData = [],downData = [], dt;
                var lg = data.length;    
        	    if (aw < minwidth) aw = minwidth;
        	    if (aw > maxwidth) aw = maxwidth;
        	    candleOption.candleWidth = aw;
        	    isFilled = candleOption.fill;
        	    for (var j = 0;j < lg ;j++) {
        	        dt = data[j];
        	        if (dt == null || dt.length<6 || isNaN(dt[1]) || isNaN(dt[2]) || isNaN(dt[3]) || isNaN(dt[4])) continue;
        	        if (dt[5] > 0) {    // up trend.
        	            upData.push(dt); 
        	        } else {
        	            downData.push(dt);
        	        }
        	    }
        	    drawColorCandle(upData,candleOption.upColor, axisx,axisy,aw,isFilled);
        	    drawColorCandle(downData,candleOption.downColor, axisx,axisy,aw,isFilled);		
        	}
        	ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            ctx.lineJoin = "round";
            ctx.strokeStyle = series.color;
            setFillStyle(series.candleStick, series.color);
            plotCandleStick(series.data, 0, series.xaxis, series.yaxis,series.candleStick);
            ctx.restore();
       }
        	
       function drawSeriesImage(series) {    
           function plotImage(data, offset, axisx,axisy,imageOption) {
               var dt,  ty, px, py;
               for (var i = 0; i < data.length; ++i) {
        	       if(data[i] == null) continue;
        			dt = data[i];
        			if (isNaN(dt[0]) || isNaN(dt[1])) continue;
        			ty = dt[2]; 
        			px = axisx.p2c(dt[0]), py =axisy.p2c(dt[1])-10;
        			if(ty == 1) drawDividendImg(px,py,ctx);
        			else if(ty == 0) drawSplitsImg(px,py,ctx);
        		}     		
        	}
            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            ctx.lineJoin = "round";
            ctx.strokeStyle = series.color;
            plotImage(series.data, 0, series.xaxis, series.yaxis,series.imagePoints);
            ctx.restore();
       }
        function drawSeriesPoints(series) {
            function plotPoints(data, radius, fill, axisx, axisy) {
                ctx.beginPath();
                var x,y, px,py,mp;
                for (var i = 0; i < data.length; ++i) {
                    if (data[i] == null||isNaN(data[i][1]))
                        continue;         
                    x = data[i][0], y = data[i][1];
                    px = axisx.p2c(x); py = axisy.p2c(y);
                    mp = 2 * Math.PI;
                    if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
                        continue;
                    ctx.moveTo(px,py);    
                    ctx.arc(px, py, radius, 0, mp, true);      
                }
                if (fill)
                   ctx.fill(); 
                ctx.stroke();
            }

            function plotPointShadows(data, offset, radius, axisx, axisy) {
                for (var i = 0; i < data.length; ++i) {
                    if (data[i] == null)
                        continue;          
                    var x = data[i][0], y = data[i][1];
                    if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
                        continue;
                    ctx.beginPath();
                    ctx.arc(axisx.p2c(x), axisy.p2c(y) + offset, radius, 0, Math.PI, false);
                    ctx.stroke();
                }
            }    
            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            var lw = series.lines.lineWidth;
            var sw = series.shadowSize;
            if (sw > 0) {
                // draw shadow in two steps
                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.1)";
                plotPointShadows(series.data, sw/2 + ctx.lineWidth/2,series.points.radius, series.xaxis, series.yaxis);
                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.2)";
                plotPointShadows(series.data, ctx.lineWidth/2,series.points.radius, series.xaxis, series.yaxis);
            }
            ctx.lineWidth = series.points.lineWidth;
            ctx.strokeStyle = series.color;
            setFillStyle(series.points, series.color);
            plotPoints(series.data, series.points.radius, series.points.fill,series.xaxis, series.yaxis);
            ctx.restore();
        }
        function drawBar(x, y, aw, offset, xOffset, clo, axisx, axisy, c) {
            var drawLeft = false, drawRight = false, drawTop = false, drawBottom = false;
            var  bottom = 0, top = y, maxW = canvasWidth-plotOffset.right-plotOffset.left-offset - aw/2;
            var px = axisx.p2c(x);
            //if y is less than 0, the bar may exceed bottom of the grid
            if(top < 0) {
            	if(top < options.yaxis.min) top = options.yaxis.min * 1.01;
            }
        	//if (px < aw/2) px=aw/2;
            if (false) {
                c.lineWidth = aw;
                c.strokeStyle = clo;
                if (bottom != top) {
                    c.moveTo(px, axisy.p2c(bottom + offset));
                    c.lineTo(px, axisy.p2c(top + offset));
                }
            } else {
                c.lineWidth = 0;
                c.strokeStyle = clo;
                c.fillStyle = clo;
                c.beginPath();	

                c.moveTo((px + xOffset), axisy.p2c(bottom + offset));
                c.lineTo((px + xOffset), axisy.p2c(top + offset));
                c.lineTo((px+aw + xOffset), axisy.p2c(top + offset));//c.lineTo(axisx.p2c(right), axisy.p2c(top) + offset);
                c.lineTo((px+aw + xOffset), axisy.p2c(bottom + offset));  //c.lineTo(axisx.p2c(right), axisy.p2c(bottom) + offset);
                if(clo != "#") {
                	c.fill();
                }
            }

            // draw outline
            if (series[0].bars.outLine) {         //(drawLeft || drawRight || drawTop || drawBottom)
                c.beginPath();
                left = axisx.p2c(left + offset);
                bottom = axisy.p2c(bottom + offset);
                right = axisx.p2c(right + offset);
                top = axisy.p2c(top + offset);
                
                c.moveTo(left, bottom + offset);
                if (drawLeft)
                    c.lineTo(left, top + offset);
                else
                    c.moveTo(left, top + offset);
                if (drawTop)
                    c.lineTo(right, top + offset);
                else
                    c.moveTo(right, top + offset);
                if (drawRight)
                    c.lineTo(right, bottom + offset);
                else
                    c.moveTo(right, bottom + offset);
                if (drawBottom)
                    c.lineTo(left, bottom + offset);
                else
                    c.moveTo(left, bottom + offset);
                c.stroke();
            }
        }
        
        function drawBarValue(x, y, aw, offset, xOffset, clo, axisx, axisy, c) {
        	var str = target.find(".tickLabels").html();
        	var left = axisx.p2c(x);
        	var top = axisy.p2c(offset) - 15;
        	//var maxBarWidth = (options.bars.maxBarWidth==null)?16:options.bars.maxBarWidth;
        	var gridWidth = axisx.p2c(2) - axisx.p2c(1);
       	 	str += '<div style="position:absolute;top:'+top+'px;left:' + (plotOffset.left + left ) + 'px;width:'+gridWidth+'px; font-weight: bold;text-align:center" class="barLabel">'+y+'</div>';
       	 	target.find(".tickLabels").html(str);
        }
        
        function drawMark(x, y, direction, color, aw, offset, xOffset, axisx, axisy, c) {
        	var maxBarWidth = (options.bars.maxBarWidth==null)?16:options.bars.maxBarWidth;
        	var markWidth = markOptions.markWidth;
    		var markHeight = markOptions.markHeight;
    		var tunning = markOptions.tunning;
        	var left = axisx.p2c(x) + xOffset - tunning;
        	if(direction == "left") {
        		left = left + maxBarWidth;
        	} else if(direction == "right") {
        		left = left - markWidth;
        	}
        	
        	var top = axisy.p2c(y);
        	
        	var icondrawer = new Icon.Drawer(c.canvas);
        	var iconsetting = new Icon.Setting();
        	if(direction == "left") {
        		iconsetting.iconType = Icon.IconType.TriangleLeft;
        	} else if(direction == "right") {
        		iconsetting.iconType = Icon.IconType.TriangleRight;
        	}
        	iconsetting.color = color;
        	iconsetting.position.x = left;
        	iconsetting.position.y = top;
        	iconsetting.size.width = markWidth;
        	iconsetting.size.height = markHeight;
            $(icondrawer.draw(iconsetting)).css({
                "float": "left"
            });
       	 	//str += '<div style="position:absolute;top:'+top+'px;left:' + (xOffset + plotOffset.left + left ) + 'px;width:66px; font-weight: bold;text-align:left" class="tickLabel">'+y+'</div>';
       	 	//target.find(".tickLabels").html(str);
        }
        
        function drawSeriesBars(series) {
            function plotBars(data, offset, op, axisx, axisy,color) {
            	var barValues = options.bars.barValues;
            	var overlap = options.bars.overlap;
            	var maxwidth = (op.maxBarWidth==null)?16:op.maxBarWidth;
        	    var minwidth = (op.minBarWidth==null)?4:op.minBarWidth;
        	    var xOffset = op.offset;
        	    var aw = Math.floor(0.7*(canvasWidth-plotOffset.left-plotOffset.right)/data.length);
        	    var lg = data.length;      	    
        	    if(aw < minwidth) aw = minwidth;
        	    if(aw > maxwidth) aw = maxwidth;
        	    op.barWidth = aw;
        	    ctx.beginPath();
        	    var ix = getDx(lg);
                for (var i = 0; i < lg; i+=ix) {
                    if (data[i] == null||isNaN(data[i][1])) continue;             
                    //drawBar(data[i][0], data[i][1], aw, offset, color, axisx, axisy, ctx);
                    offset = 0;
					for(var j = 1; j < 100; j+=2) {
						if(data[i][j] == null  || isNaN(data[i][j]) || typeof data[i][j] == "string") {
							  break;            	
						}								
						var fillColor = color;
						if(data[i][j + 1] != null) {		 
								fillColor = data[i][j + 1];	  								
						} else {
								fillColor = color;
						}
						if(overlap == "absolute") {
							if((data[i][j] > 0 && offset < 0) || (data[i][j] < 0 && offset > 0)) {
									offset = 0;
							}					
						}			
						if(dataOffsets[i]) {
							xOffset = dataOffsets[i][1];
						}
		     		    drawBar(data[i][0], data[i][j], aw, offset, xOffset, fillColor, axisx, axisy, ctx);						     		    
		     		   	offset += data[i][j];
                    }
					if(barValues && barValues[i][1] != '') {
						drawBarValue(barValues[i][0], barValues[i][1], aw, offset, xOffset, '', axisx, axisy, ctx);
					}
					if(markSeries.length > 0) {
						var subMarkSeries = markSeries[i];
						if(subMarkSeries != null) {
							for(var m = 1; m < subMarkSeries.length; m=m+3) {
								drawMark(subMarkSeries[0], subMarkSeries[m], subMarkSeries[m+1], subMarkSeries[m+2], aw, offset, xOffset, axisx, axisy, ctx);
							}
						}
					}
                }
                ctx.stroke();
            }

            ctx.save();
            ctx.translate(plotOffset.left, plotOffset.top);
            ctx.lineJoin = "round";

            // FIXME: figure out a way to add shadows
            /*
            var bw = series.bars.barWidth;
            var lw = series.bars.lineWidth;
            var sw = series.shadowSize;
            if (sw > 0) {
                // draw shadow in two steps
                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.1)";
                plotBars(series.data, bw, lw/2 + sw/2 + ctx.lineWidth/2, false);

                ctx.lineWidth = sw / 2;
                ctx.strokeStyle = "rgba(0,0,0,0.2)";
                plotBars(series.data, bw, lw/2 + ctx.lineWidth/2, false);
            }*/

            ctx.lineWidth = series.bars.lineWidth;
            ctx.strokeStyle = series.color;
            setFillStyle(series.bars, series.color);
            plotBars(series.data,0, series.bars,series.xaxis, series.yaxis,series.color);//Jacye
            ctx.restore();
        }

        function setFillStyle(obj, seriesColor) {
            var fill = obj.fill;
            if (!fill)
                return;
            
            if (obj.fillColor)
                ctx.fillStyle = obj.fillColor;
            else {
                var c = parseColor(seriesColor);
                c.a = typeof fill == "number" ? fill : 0.4;
                c.normalize();
                ctx.fillStyle = c.toString();
            }
        }
        
        function insertLegend() {
            target.find(".legend").remove();

            if (!options.legend.show)
                return;
            
            var fragments = [];
            var rowStarted = false;
            for (i = 0; i < series.length; ++i) {
                if (!series[i].label)
                    continue;
                
                if (i % options.legend.noColumns == 0) {
                    if (rowStarted)
                        fragments.push('</tr>');
                    fragments.push('<tr>');
                    rowStarted = true;
                }

                var label = series[i].label;
                if (options.legend.labelFormatter != null)
                    label = options.legend.labelFormatter(label);
                
                fragments.push(
                    '<td class="legendColorBox"><div style="border:1px solid ' + options.legend.labelBoxBorderColor + ';padding:1px"><div style="width:14px;height:10px;background-color:' + series[i].color + ';overflow:hidden"></div></div></td>' +
                    '<td class="legendLabel">' + label + '</td>');
            }
            if (rowStarted)
                fragments.push('</tr>');
            
            if (fragments.length == 0)
                return;

            var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
            if (options.legend.container != null)
                options.legend.container.html(table);
            else {
                var pos = "";
                var p = options.legend.position, m = options.legend.margin;
                if (p.charAt(0) == "n")
                    pos += 'top:' + (m + plotOffset.top) + 'px;';
                else if (p.charAt(0) == "s")
                    pos += 'bottom:' + (m + plotOffset.bottom) + 'px;';
                if (p.charAt(1) == "e")
                    pos += 'right:' + (m + plotOffset.right) + 'px;';
                else if (p.charAt(1) == "w")
                    pos += 'left:' + (m + plotOffset.left) + 'px;';
                var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(target);
                if (options.legend.backgroundOpacity != 0.0) {
                    // put in the transparent background
                    // separately to avoid blended labels and
                    // label boxes
                    var c = options.legend.backgroundColor;
                    if (c == null) {
                        var tmp;
                        if (options.grid.backgroundColor)
                            tmp = options.grid.backgroundColor;
                        else
                            tmp = extractColor(legend);
                        c = parseColor(tmp).adjust(null, null, null, 1).toString();
                    }
                    var div = legend.children();
                    $('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
                    
                }
            }
        }


        // interactive features
        
        var lastMousePos = { pageX: null, pageY: null },
            selection = {
                first: { x: -1, y: -1}, second: { x: -1, y: -1},
                show: false, active: false },
            highlights = [],
            clickIsMouseUp = false,
            redrawTimeout = null,
            hoverTimeout = null;
        
        // Returns the data item the mouse is over, or null if none is found
        function result(i, j) {
            return { datapoint: series[i].data[j],dataIndex: j,series: series[i],seriesIndex: i};
        }
            
        function findNearbyItem(mouseX, mouseY) {
            var maxDistance = options.grid.mouseActiveRadius;
            var lowestDistance = maxDistance * maxDistance + 1;            
            var item = null, foundPoint = false;
            var data, axisx, axisy, mx, my, maxx, maxy, checkbar, checkcandle, checkOLHC, checkpoint, barLeft, barRight, candlew;
            for (var i = 0; i < series.length; ++i) {
                data = series[i].data;
                axisx = series[i].xaxis, axisy = series[i].yaxis;
                mx = axisx.c2p(mouseX), my = axisy.c2p(mouseY);
                var gridWidth = axisx.p2c(2) - axisx.p2c(1);  
                
                var barWidth = options.bars.barWidth;
                var maxBarWidth = (options.bars.maxBarWidth==null)?16:options.bars.maxBarWidth;
        	    var minBarWidth = (options.bars.minBarWidth==null)?4:options.bars.minBarWidth;
        	    var barWidth = Math.floor(0.7*(canvasWidth-plotOffset.left-plotOffset.right)/data.length);      	    
        	    if(barWidth < minBarWidth) barWidth = minBarWidth;
        	    if(barWidth > maxBarWidth) barWidth = maxBarWidth;

                var barRatio = barWidth / gridWidth;
                var barLeftRatio = options.bars.offset / gridWidth;
                var barRightRatio = barRatio + barLeftRatio;
                maxx = maxDistance / axisx.scale, maxy = maxDistance / axisy.scale;
                checkbar = series[i].bars.show , checkcandle = series[i].candleStick.show, checkOLHC = series[i].OLHC.show;
                checkpoint = (!checkOLHC && !checkcandle && !checkbar)||(series[i].lines.show || series[i].points.show);
                if (checkbar) barLeft = series[i].bars.align == "left" ? 0 : -series[i].bars.barWidth/2, barRight = barLeft + series[i].bars.barWidth;
                if (checkcandle) candlew = (series[i].candleStick.candleWidth==null)?0:series[i].candleStick.candleWidth;
                var x, y, lg = data.length;
                for (var j = 0; j < lg; ++j) {
                    if (data[j] == null||isNaN(data[j][1]) || typeof data[j][1] == "string")
                        continue;                    
                    for(var m = 1; m < 100; m+=2) {	                    
						if(data[j][m] == null  || isNaN(data[j][m]) || typeof data[j][m] == "string") {
							  break;            	
						}
						x = data[j][0], y = data[j][m];
	                    if (checkbar) {
	                        // For a bar graph, the cursor must be inside the bar
	                        // and no other point can be nearby
	                        //if (!foundPoint && Math.floor(mx) == x && (my >= 0 ? my >= 0 : my >= Math.min(0, y)) && my <= Math.max(0, y)) {	                        	
	                    	if (!foundPoint && mx >= x + barLeftRatio && mx <= x + barRightRatio && (my >= 0 ? my >= 0 : my >= Math.min(0, y)) && my <= Math.max(0, y)) {
	                            item = result(i, j);
	                            item.y = my;
	                        }
	                    } else if(checkcandle || checkOLHC) {
	                        if ((mx <= x+0.5)&&(mx >= x-0.5)) {
	                          foundPoint = true;
	                          item = result(i, j);
	                          item.y = my;
	                          return  item;
	                        }
	                    } else if (checkpoint) {
	                        if (mx<=x){
	                            foundPoint = true;
	                            item = result(i, j);
	                           item.y = my;
	                           return  item;
	                        } 
	                    }
                    }
                }
            }
            return item;
        }

        function onMouseMove(ev) {
            // FIXME: temp. work-around until jQuery bug 1871 is fixed
            var e = ev || window.event;
            if (e.pageX == null && e.clientX != null) {
                var de = document.documentElement, b = document.body;
                lastMousePos.pageX = e.clientX + (de && de.scrollLeft || b.scrollLeft || 0);
                lastMousePos.pageY = e.clientY + (de && de.scrollTop || b.scrollTop || 0);
            }
            else {
                lastMousePos.pageX = e.pageX;
                lastMousePos.pageY = e.pageY;
            }
            
            if (options.grid.hoverable && !hoverTimeout)
                hoverTimeout = setTimeout(onHover, 100);

            if (selection.active)
                updateSelection(lastMousePos);
        }
        
        function onMouseDown(e) {
            if (e.which != 1)  // only accept left-click
                return;
            
            // cancel out any text selections
            document.body.focus();

            // prevent text selection and drag in old-school browsers
            if (document.onselectstart !== undefined && workarounds.onselectstart == null) {
                workarounds.onselectstart = document.onselectstart;
                document.onselectstart = function () { return false; };
            }
            if (document.ondrag !== undefined && workarounds.ondrag == null) {
                workarounds.ondrag = document.ondrag;
                document.ondrag = function () { return false; };
            }
            
            setSelectionPos(selection.first, e);
                
            lastMousePos.pageX = null;
            selection.active = true;
            $(document).one("mouseup", onSelectionMouseUp);
        }

        function onClick(e) {
            if (clickIsMouseUp) {
                clickIsMouseUp = false;
                return;
            }

            triggerClickHoverEvent("plotclick", e);
        }
        
        function onHover() {
            triggerClickHoverEvent("plothover", lastMousePos);
            hoverTimeout = null;
        }

        // trigger click or hover event (they send the same parameters
        // so we share their code)
        function triggerClickHoverEvent(eventname, event) {
           if(eventHolder == null) return false;
            var offset = eventHolder.offset(),
                pos = { pageX: event.pageX, pageY: event.pageY },
                canvasX = event.pageX - offset.left - plotOffset.left,
                canvasY = event.pageY - offset.top - plotOffset.top;

            if (axes.xaxis.used)
                pos.x = axes.xaxis.c2p(canvasX);
            if (axes.yaxis.used)
                pos.y = axes.yaxis.c2p(canvasY);
            if (axes.x2axis.used)
                pos.x2 = axes.x2axis.c2p(canvasX);
            if (axes.y2axis.used)
                pos.y2 = axes.y2axis.c2p(canvasY);

            var item = findNearbyItem(canvasX, canvasY);

            if (item) {
                // fill in mouse pos for any listeners out there
                item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left);
                item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top);                   
            }

            if (options.grid.autoHighlight) {
                for (var i = 0; i < highlights.length; ++i) {
                    var h = highlights[i];
                    if (h.auto &&
                        !(item && h.series == item.series && h.point == item.datapoint))
                        unhighlight(h.series, h.point);
                }
                /**
                if (item)
                    highlight(item.series, item.datapoint, true);
             	*/
            }
            
            target.trigger(eventname, [ pos, item ]);
        }

        function triggerRedrawOverlay() {
            if (!redrawTimeout)
                redrawTimeout = setTimeout(redrawOverlay, 50);
        }

        function redrawOverlay() {
            redrawTimeout = null;
            if(octx == null) return;
            // redraw highlights
            octx.save();
            octx.clearRect(0, 0, canvasWidth, canvasHeight);
            octx.translate(plotOffset.left, plotOffset.top);
            
            var i, hi; 
            for (i = 0; i < highlights.length; ++i) {
                hi = highlights[i];

                if (hi.series.bars.show)
                    drawBarHighlight(hi.series, hi.point);
                else if(hi.series.lines.show||hi.series.points.show)
                    drawPointHighlight(hi.series, hi.point);
                else if(hi.series.OLHC.show)
                drawOLHCHighlight(hi.series, hi.point);
                else if(hi.series.candleStick.show)
                drawCandleStickHighlight(hi.series, hi.point);
                else
                drawPointHighlight(hi.series, hi.point);
                
            }
            octx.restore();
          // console.debug("draw h");
            // redraw selection
            if (selection.show && selectionIsSane()) {
                octx.strokeStyle = parseColor(options.selection.color).scale(null, null, null, 0.8).toString();
                octx.lineWidth = 1;
                ctx.lineJoin = "round";
                octx.fillStyle = parseColor(options.selection.color).scale(null, null, null, 0.4).toString();
                
                var x = Math.min(selection.first.x, selection.second.x),
                    y = Math.min(selection.first.y, selection.second.y),
                    w = Math.abs(selection.second.x - selection.first.x),
                    h = Math.abs(selection.second.y - selection.first.y);
                
                octx.fillRect(x + plotOffset.left, y + plotOffset.top, w, h);
                octx.strokeRect(x + plotOffset.left, y + plotOffset.top, w, h);
            }
        }
        
        function highlight(s, point, auto) {
            if (typeof s == "number")
                s = series[s];

            if (typeof point == "number")
                point = s.data[point];

            var i = indexOfHighlight(s, point);
            if (i == -1) {
                highlights.push({ series: s, point: point, auto: auto });

                triggerRedrawOverlay();
            }
            else if (!auto)
                highlights[i].auto = false;
        }
            
        function unhighlight(s, point) {
            if (typeof s == "number")
                s = series[s];

            if (typeof point == "number")
                point = s.data[point];

            var i = indexOfHighlight(s, point);
            if (i != -1) {
                highlights.splice(i, 1);
                triggerRedrawOverlay();
            }
        }
        
        function indexOfHighlight(s, p) {
            for (var i = 0; i < highlights.length; ++i) {
                var h = highlights[i];
                if (h.series == s && h.point[0] == p[0]
                    && h.point[1] == p[1])
                    return i;
            }
            return -1;
        }
        
        function drawPointHighlight(series, point) {
            var x = point[0], y = point[1],
                axisx = series.xaxis, axisy = series.yaxis;
            
            if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
                return;
            
            var pointRadius = series.points.radius + series.points.lineWidth / 2;
            octx.lineWidth = pointRadius;
            octx.strokeStyle = parseColor(series.color).scale(1, 1, 1, 0.5).toString();
            var radius = 1.5 * pointRadius;
            octx.beginPath();
            octx.arc(axisx.p2c(x), axisy.p2c(y), radius, 0, 2 * Math.PI, true);
            octx.stroke();
        }

        function drawBarHighlight(series, point) {
        if (point == null)return; 
            octx.lineJoin = "round";
            octx.lineWidth = series.bars.lineWidth;
            octx.strokeStyle = parseColor(series.color).scale(1, 1, 1, 0.5).toString();
            octx.fillStyle = parseColor(series.color).scale(1, 1, 1, 0.5).toString();
           // var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
            var x=point[0],y=point[1],aw = series.bars.barWidth;          
            var cl = series.color;
            var op = series.bars;
            if(point.length>3)  cl=(point[2]==1)?op.upColor:op.downColor;  
            drawBar(x, y, aw, 0, cl, series.xaxis, series.yaxis, octx);
            //drawBar(point[0], point[1], barLeft, barLeft + series.bars.barWidth,
            //        0, true, series.xaxis, series.yaxis, octx);
        }
        
        function drawOLHCHighlight(series,point)
        {
                    var dt = point;
                    var w = series.OLHC.barWidth;
        			if(dt.length<6||isNaN(dt[1])||isNaN(dt[2])||isNaN(dt[3])||isNaN(dt[4]))return;
        			var x=dt[0], c = dt[1],h = dt[2], l=dt[3], o = dt[4];
        			var px = series.xaxis.p2c(x);
        			var pc = series.yaxis.p2c(c), po = series.yaxis.p2c(o), pl = series.yaxis.p2c(l), ph = series.yaxis.p2c(h);
        			if(px<w/2)  px=w/2;
        			if(px>(canvasWidth-plotOffset.left-plotOffset.right-w/2)) px = canvasWidth-plotOffset.left-plotOffset.right-w/2;   
        			octx.strokeStyle = series.OLHC.highLightColor;
        			octx.lineJoin = "round";
                    octx.lineWidth = series.OLHC.lineWidth+1;
        			
        			octx.beginPath();   			
        			octx.moveTo(px,ph);
        			octx.lineTo(px,pl);
        			//ctx.stroke();
        			//ctx.beginPath();
        			octx.moveTo(px,po);
        			octx.lineTo(px-w/2,po);
        			//ctx.stroke();
        			//ctx.beginPath();
        			octx.moveTo(px,pc);
        			octx.lineTo(px+w/2,pc);
        			octx.stroke();
        }
        
        function drawCandleStickHighlight(series,point)
        {
        var candleOption = series.candleStick;
        var maxwidth = (candleOption.maxCandleWidth==null)?16:candleOption.maxCandleWidth;
        var minwidth = (candleOption.minCandleWidth==null)?4:candleOption.minCandleWidth;
        var aw = Math.floor(0.7*(canvasWidth-plotOffset.left-plotOffset.right)/series.data.length);     	    
        	    if(aw<minwidth) aw = minwidth;
        	    if(aw>maxwidth) aw = maxwidth;
         var dt = point;
         var clo, isFilled = false;
         octx.lineJion="round";
         octx.lineWidth = 2;
        octx.strokeStyle = candleOption.highLightColor;//"#cccccc";
        octx.fillStyle = candleOption.highLightColor;//"#cccccc";
     
         if(dt.length<6||isNaN(dt[1])||isNaN(dt[2])||isNaN(dt[3])||isNaN(dt[4]))return;
         var x=dt[0], c = dt[1],h = dt[2], l = dt[3], o = dt[4];
         var px = series.xaxis.p2c(x);
        			var pc = series.yaxis.p2c(c), po = series.yaxis.p2c(o), pl = series.yaxis.p2c(l), ph = series.yaxis.p2c(h);
        			if((px+aw/2)>(canvasWidth-plotOffset.right-plotOffset.left)) 
        			{px= canvasWidth-aw/2-plotOffset.right-plotOffset.left;}
        			if(px<aw/2) px=aw/2;
        			clo = (c>o)?candleOption.upColor:candleOption.downColor;
        			octx.beginPath();
        			drawCandleStick(px,po,pl,ph,pc,dt,aw,candleOption.highLightColor,isFilled,octx);
        			octx.stroke();
        }
        function triggerSelectedEvent() {
            var x1 = Math.min(selection.first.x, selection.second.x),
                x2 = Math.max(selection.first.x, selection.second.x),
                y1 = Math.max(selection.first.y, selection.second.y),
                y2 = Math.min(selection.first.y, selection.second.y);

            var r = {};
            if (axes.xaxis.used)
                r.xaxis = { from: axes.xaxis.c2p(x1), to: axes.xaxis.c2p(x2) };
            if (axes.x2axis.used)
                r.x2axis = { from: axes.x2axis.c2p(x1), to: axes.x2axis.c2p(x2) };
            if (axes.yaxis.used)
                r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) };
            if (axes.y2axis.used)
                r.yaxis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) };
            
            target.trigger("plotselected", [ r ]);

            // backwards-compat stuff, to be removed in future
            if (axes.xaxis.used && axes.yaxis.used)
                target.trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
        }
        
        function onSelectionMouseUp(e) {
            // revert drag stuff for old-school browsers
            if (document.onselectstart !== undefined)
                document.onselectstart = workarounds.onselectstart;
            if (document.ondrag !== undefined)
                document.ondrag = workarounds.ondrag;
            
            // no more draggy-dee-drag
            selection.active = false;
            updateSelection(e);
            
            if (selectionIsSane()) {
                triggerSelectedEvent();
                clickIsMouseUp = true;
            }
            
            return false;
        }

        function setSelectionPos(pos, e) {
            var offset = eventHolder.offset();
            if (options.selection.mode == "y") {
                if (pos == selection.first)
                    pos.x = 0;
                else
                    pos.x = plotWidth;
            }
            else {
                pos.x = e.pageX - offset.left - plotOffset.left;
                pos.x = Math.min(Math.max(0, pos.x), plotWidth);
            }

            if (options.selection.mode == "x") {
                if (pos == selection.first)
                    pos.y = 0;
                else
                    pos.y = plotHeight;
            }
            else {
                pos.y = e.pageY - offset.top - plotOffset.top;
                pos.y = Math.min(Math.max(0, pos.y), plotHeight);
            }
        }
        
        function updateSelection(pos) {
            if (pos.pageX == null)
                return;
            
            setSelectionPos(selection.second, pos);
            if (selectionIsSane()) {
                selection.show = true;
                triggerRedrawOverlay();
            }
            else
                clearSelection();
        }

        function clearSelection() {
            if (selection.show) {
                selection.show = false;
                triggerRedrawOverlay();
            }
        }

        function setSelection(ranges, preventEvent) {
            var range;
            
            if (options.selection.mode == "y") {
                selection.first.x = 0;
                selection.second.x = plotWidth;
            }
            else {
                range = extractRange(ranges, "x");
                
                selection.first.x = range.axis.p2c(range.from);
                selection.second.x = range.axis.p2c(range.to);
            }
            
            if (options.selection.mode == "x") {
                selection.first.y = 0;
                selection.second.y = plotHeight;
            }
            else {
                range = extractRange(ranges, "y");
                
                selection.first.y = range.axis.p2c(range.from);
                selection.second.y = range.axis.p2c(range.to);
            }

            selection.show = true;
            triggerRedrawOverlay();
            if (!preventEvent)
                triggerSelectedEvent();
        }
        
        function selectionIsSane() {
            var minSize = 5;
            return Math.abs(selection.second.x - selection.first.x) >= minSize &&
                Math.abs(selection.second.y - selection.first.y) >= minSize;
        }
    }
    
    $.plot = function(targetID,_option,obj) {
        var plot = new Plot(targetID,_option,obj);
        plot.initParameter(_option);
        /*var t0 = new Date();     
        var t1 = new Date();
        var tstr = "time used (msecs): " + (t1.getTime() - t0.getTime())
        if (window.console)
            console.log(tstr);
        else
            alert(tstr);*/
        return plot;
    };
    
    // round to nearby lower multiple of base
    function floorInBase(n, base) {
        return base * Math.floor(n / base);
    }
    
    function clamp(min, value, max) {
        if (value < min)
            return value;
        else if (value > max)
            return max;
        else
            return value;
    }
    
    // color helpers, inspiration from the jquery color animation
    // plugin by John Resig
    function Color (r, g, b, a) {
       
        var rgba = ['r','g','b','a'];
        var x = 4; //rgba.length
       
        while (-1<--x) {
            this[rgba[x]] = arguments[x] || ((x==3) ? 1.0 : 0);
        }
       
        this.toString = function() {
            if (this.a >= 1.0) {
                return "rgb("+[this.r,this.g,this.b].join(",")+")";
            } else {
                return "rgba("+[this.r,this.g,this.b,this.a].join(",")+")";
            }
        };

        this.scale = function(rf, gf, bf, af) {
            x = 4; //rgba.length
            while (-1<--x) {
                if (arguments[x] != null)
                    this[rgba[x]] *= arguments[x];
            }
            return this.normalize();
        };

        this.adjust = function(rd, gd, bd, ad) {
            x = 4; //rgba.length
            while (-1<--x) {
                if (arguments[x] != null)
                    this[rgba[x]] += arguments[x];
            }
            return this.normalize();
        };

        this.clone = function() {
            return new Color(this.r, this.b, this.g, this.a);
        };

        var limit = function(val,minVal,maxVal) {
            return Math.max(Math.min(val, maxVal), minVal);
        };

        this.normalize = function() {
            this.r = limit(parseInt(this.r), 0, 255);
            this.g = limit(parseInt(this.g), 0, 255);
            this.b = limit(parseInt(this.b), 0, 255);
            this.a = limit(this.a, 0, 1);
            return this;
        };

        this.normalize();
    }
    
    var lookupColors = {
        aqua:[0,255,255],
        azure:[240,255,255],
        beige:[245,245,220],
        black:[0,0,0],
        blue:[0,0,255],
        brown:[165,42,42],
        cyan:[0,255,255],
        darkblue:[0,0,139],
        darkcyan:[0,139,139],
        darkgrey:[169,169,169],
        darkgreen:[0,100,0],
        darkkhaki:[189,183,107],
        darkmagenta:[139,0,139],
        darkolivegreen:[85,107,47],
        darkorange:[255,140,0],
        darkorchid:[153,50,204],
        darkred:[139,0,0],
        darksalmon:[233,150,122],
        darkviolet:[148,0,211],
        fuchsia:[255,0,255],
        gold:[255,215,0],
        green:[0,128,0],
        indigo:[75,0,130],
        khaki:[240,230,140],
        lightblue:[173,216,230],
        lightcyan:[224,255,255],
        lightgreen:[144,238,144],
        lightgrey:[211,211,211],
        lightpink:[255,182,193],
        lightyellow:[255,255,224],
        lime:[0,255,0],
        magenta:[255,0,255],
        maroon:[128,0,0],
        navy:[0,0,128],
        olive:[128,128,0],
        orange:[255,165,0],
        pink:[255,192,203],
        purple:[128,0,128],
        violet:[128,0,128],
        red:[255,0,0],
        silver:[192,192,192],
        white:[255,255,255],
        yellow:[255,255,0]
    };    

    function extractColor(element) {
        var color, elem = element;
        do {
            color = elem.css("background-color").toLowerCase();
            // keep going until we find an element that has color, or
            // we hit the body
            if (color != '' && color != 'transparent')
                break;
            elem = elem.parent();
        } while (!$.nodeName(elem.get(0), "body"));

        // catch Safari's way of signalling transparent
        if (color == "rgba(0, 0, 0, 0)") 
            return "transparent";
        
        return color;
    }
    
    // parse string, returns Color
    function parseColor(str) {
        var result;

        // Look for rgb(num,num,num)
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))
            return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10));
        
        // Look for rgba(num,num,num,num)
        if (result = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
            return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10), parseFloat(result[4]));
            
        // Look for rgb(num%,num%,num%)
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))
            return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55);

        // Look for rgba(num%,num%,num%,num)
        if (result = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
            return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));
        
        // Look for #a0b1c2
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))
            return new Color(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16));

        // Look for #fff
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))
            return new Color(parseInt(result[1]+result[1], 16), parseInt(result[2]+result[2], 16), parseInt(result[3]+result[3], 16));

        // Otherwise, we're most likely dealing with a named color
        var name = $.trim(str).toLowerCase();
        if (name == "transparent")
            return new Color(255, 255, 255, 0);
        else {
            result = lookupColors[name];
            return new Color(result[0], result[1], result[2]);
        }
    }
        
})(jQuery);

function isDigitalString(digitalStr){digitalStr=preFormat(digitalStr);if(""==digitalStr||"-"==digitalStr)return false;var valid="1234567890.-%";var text=new String(digitalStr+"");for(var i=0;i<digitalStr.length;i++){if(valid.indexOf(digitalStr.charAt(i))>-1)continue;else return false};return true};function preFormat(digitalStr){if(null==digitalStr)return "";var escapchars=" ,\r\n\t";for(var i=0;i<escapchars.length;i++){var escapchar=escapchars.charAt(i);if(digitalStr.indexOf(escapchar)>-1){digitalStr=digitalStr.replace(new RegExp(escapchar,"gm"),'')}};return $.trim(digitalStr)}(function(jQuery){function FormatData(dec,group,neg){this.dec=dec;this.group=group;this.neg=neg};function formatCodes(locale){var dec=".";var group=",";var neg="-";if(locale=="us"||locale=="ae"||locale=="eg"||locale=="il"||locale=="jp"||locale=="sk"||locale=="th"||locale=="cn"||locale=="hk"||locale=="tw"||locale=="au"||locale=="ca"||locale=="gb"||locale=="in"){dec=".";group=","}else if(locale=="de"||locale=="vn"||locale=="es"||locale=="dk"||locale=="at"||locale=="gr"||locale=="br"){dec=",";group="."}else if(locale=="cz"||locale=="fr"||locale=="fi"||locale=="ru"||locale=="se"){group=" ";dec=","}else if(locale=="ch"){group="'";dec="."};return new FormatData(dec,group,neg)};function formatValue(number,options,validator,preProcessor){{if(validator==null||"undefined"==validator){validator=isDigitalString};if(preProcessor==null||"undefined"==preProcessor){preProcessor=preFormat};if(!validator(number))return number;number=preProcessor(number);var isPercentage=false;if(number.charAt(number.length-1)=="%"){isPercentage=true;number=number.substring(0,number.length-1)}};var options=jQuery.extend({},jQuery.fn.parse.defaults,options);var formatData=formatCodes(options.locale.toLowerCase());var dec=formatData.dec;var group=formatData.group;var neg=formatData.neg;var validFormat="0#-,.";var valid="1234567890.-";var text=new String(number+"");var prefix="";var negativeInFront=false;for(var i=0;i<options.format.length;i++){if(validFormat.indexOf(options.format.charAt(i))==-1)prefix=prefix+options.format.charAt(i);else if(i==0&&options.format.charAt(i)=='-'){negativeInFront=true;continue}else break};var suffix="";for(var i=options.format.length-1;i>=0;i--){if(validFormat.indexOf(options.format.charAt(i))==-1)suffix=options.format.charAt(i)+suffix;else break};options.format=options.format.substring(prefix.length);options.format=options.format.substring(0,options.format.length-suffix.length);while(text.indexOf(group)>-1)text=text.replace(group,'');var number=new Number(text.replace(dec,".").replace(neg,"-"));if(suffix=="%")number=number*100;{var carryOut=false};var returnString="";var decimalValue=number%1;if(options.format.indexOf(".")>-1){var decimalPortion=dec;var decimalFormat=options.format.substring(options.format.lastIndexOf(".")+1);{var toFixedDecimal=decimalValue.toFixed(decimalFormat.length);if(toFixedDecimal>=1.0||toFixedDecimal<=-1.0)carryOut=true;var decimalString=new String(toFixedDecimal)};decimalString=decimalString.substring(decimalString.lastIndexOf(".")+1);for(var i=0;i<decimalFormat.length;i++){if(decimalFormat.charAt(i)=='#'&&decimalString.charAt(i)!='0'){decimalPortion+=decimalString.charAt(i);continue}else if(decimalFormat.charAt(i)=='#'&&decimalString.charAt(i)=='0'){var notParsed=decimalString.substring(i);if(notParsed.match('[1-9]')){decimalPortion+=decimalString.charAt(i);continue}else{break}}else if(decimalFormat.charAt(i)=="0"){decimalPortion+=decimalString.charAt(i)}};returnString+=decimalPortion}else number=Math.round(number);{var ones=Math.floor(number)+(carryOut?1:0);if(number<0)ones=Math.ceil(number)-(carryOut?1:0)};var onePortion="";if(ones==0){onePortion="0"}else{var onesFormat="";if(options.format.indexOf(".")==-1)onesFormat=options.format;else onesFormat=options.format.substring(0,options.format.indexOf("."));var oneText=new String(Math.abs(ones));var groupLength=9999;if(onesFormat.lastIndexOf(",")!=-1)groupLength=onesFormat.length-onesFormat.lastIndexOf(",")-1;var groupCount=0;for(var i=oneText.length-1;i>-1;i--){onePortion=oneText.charAt(i)+onePortion;groupCount++;if(groupCount==groupLength&&i!=0){onePortion=group+onePortion;groupCount=0}}};returnString=onePortion+returnString;if(number<0&&negativeInFront&&prefix.length>0){prefix=neg+prefix}else if(number<0){returnString=neg+returnString};if(!options.decimalSeparatorAlwaysShown){if(returnString.lastIndexOf(dec)==returnString.length-1){returnString=returnString.substring(0,returnString.length-1)}};returnString=prefix+returnString+suffix;{return isPercentage?returnString+"%":returnString}};jQuery.formatValue=function(number,options){return formatValue(number,options)};jQuery.fn.parse=function(options){var options=jQuery.extend({},jQuery.fn.parse.defaults,options);var formatData=formatCodes(options.locale.toLowerCase());var dec=formatData.dec;var group=formatData.group;var neg=formatData.neg;var valid="1234567890.-";var array=[];this.each(function(){var text=new String(jQuery(this).text());if(jQuery(this).is(":input"))text=new String(jQuery(this).val());while(text.indexOf(group)>-1)text=text.replace(group,'');text=text.replace(dec,".").replace(neg,"-");var validText="";var hasPercent=false;if(text.charAt(text.length-1)=="%")hasPercent=true;for(var i=0;i<text.length;i++){if(valid.indexOf(text.charAt(i))>-1)validText=validText+text.charAt(i)};var number=new Number(validText);if(hasPercent){number=number/100;number=number.toFixed(validText.length-1)};array.push(number)});return array};jQuery.fn.format=function(options){return this.each(function(){var text=new String(jQuery(this).text());if(jQuery(this).is(":input"))text=new String(jQuery(this).val());var returnString=formatValue(text,options);if(text==returnString)return;if(jQuery(this).is(":input"))jQuery(this).val(returnString);else jQuery(this).text(returnString)})};jQuery.fn.parse.defaults={locale:"us",decimalSeparatorAlwaysShown:false};jQuery.fn.format.defaults={format:"#,###.00",locale:"us",decimalSeparatorAlwaysShown:false}})(jQuery);
var regFilterDate = /^[0-9]{1,4}-[0-9]{1,4}-[0-9]{1,4}$/;
var startZero = /^0[1-9]/;
function i18_floatdata(jquery_path,locale,config){
	if(null==config){
		config={format:"#,###.00",locale:locale};
	}
	
	$(jquery_path).each(
		function(){
			var v = $(this).text();
			if(startZero.test(v)){
				return;
			}
			if(parseFloat(v) || parseFloat(v) == 0){
				$(this).format(config);
			}
		}
	);
}
function i18_data(jquery_path,locale,config){

	$(jquery_path).each(
		function(){
			i18FormatData(this,locale,config);
		}
	);
}
function i18FormatData(formartObj,locale,config,spcDecimalNumber)
{
	var value = $(formartObj).text().replace(/\n(\s*$)/g, "");
	value = value.replace(/(^\s*)|(\s*$)/g, "");
	if(regFilterDate.test(value))
	{
		return;
	}
	if(parseFloat(value) ==0 || parseFloat(value)){
		var bool = false;
		if(startZero.test(value))
		{
			return;
		}
		if(value >0)
		{
			bool = parseInt(value)-value <= 0 && (parseInt(value)+"").length != value.length;
		}
		else if(value < 0)
		{
			bool = parseInt(value)-value >= 0 && (parseInt(value)+"").length != value.length;		  
		}
		  
		var hf = $(formartObj).attr('hf');
		if(null == hf || undefined == hf)
		{
			if(bool){
				if(spcDecimalNumber == undefined || null == spcDecimalNumber)
				{
					config={format:"#,###.00",locale:locale};
				}
				else
				{
					config={format:"#,###.0000",locale:locale};
				}
				$(formartObj).format(config);
			}else{
				config={format:"#,###",locale:locale};
				$(formartObj).format(config);
			}
			$(formartObj).attr('hf',true);
		}
	}
}

function globalChartYxaisNeedLocalParam()
{
		$("div > canvas").each(function(i){
			$(this).parent().children(".tickLabels").children(".tickLabel").each(function(i){
				i18FormatData(this,globalLoacalCulture,'',4);
			}); 	
		}); 
}

function commonHisQuarsPaintLine(data,ticksVal,maxValue,conatinerId,cacheUse10YearChart)
{
	var intervalNumber = 1;
	if(cacheUse10YearChart == 'true')
	{
		intervalNumber = 4;
	}
	var localMaxVal = parseInt(Math.ceil(maxValue * 1.1));
	var eachLayer = parseInt(Math.ceil(localMaxVal / 5));
	var option = { xaxis: { mode:null,showLabel:true,interval:intervalNumber,ticks:ticksVal,tickFormatter:null, labelHeight:20, backgroundColor:"#e6e5e6", textAlign:"left", style:"height:35px; border-width:0px 0px 0px 0px; border-style:solid; border-color:#C5C5C5; font-weight:normal" }, 
								 yaxis: {labelWidth:40,labelHeight:-2, min:0, max:eachLayer*5, ticks:[[0,""],[eachLayer,''+eachLayer],[eachLayer*2,''+eachLayer*2],[eachLayer*3,''+eachLayer*3],[eachLayer*4,''+eachLayer*4],[eachLayer*5,''+eachLayer*5]]}, 
								 lines:{show:true, barWidth:1, maxBarWidth:50, offset:0}, 
								 grid: { hoverable: true, clickable: true, color:"#000000" } };

	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[370,135]};
	commonPaint(data,option,conatinerId,canvasObj);
}

function commonHisQuarsPaintBar(data,ticksVal,maxValue,conatinerId)
{

	if(maxValue == 0)
	{
		maxValue = 2;
	}
	
	var localMaxVal = parseInt(Math.ceil(maxValue * 1.1));
	var eachLayer = parseInt(Math.ceil(localMaxVal / 3));
	var option = { xaxis: { mode:null,showLabel:false,ticks:[[1,"25"],[2,"25"],[3,"33"]],tickFormatter:null, labelHeight:20, backgroundColor:"#FDFDFD", textAlign:"left", style:"height:35px; border-width:0px 0px 0px 0px; border-style:solid; border-color:#C5C5C5; font-weight:normal" }, 
				 yaxis: {labelWidth:65,labelHeight:-2, min:0, max:eachLayer*3, ticks:[[0,""],[eachLayer,''+eachLayer],[eachLayer*2,''+eachLayer*2],[eachLayer*3,''+eachLayer*3]]}, 
								 bars:{show:true, barWidth:1, maxBarWidth:50, offset:0}, 
								 grid: { hoverable: true, clickable: true, color:"#000000" } };

	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[370,145]};
	commonPaint(data,option,conatinerId,canvasObj);
}

function commonHisSingleBar(data,ticksVal,maxValue,conatinerId)
{
	if(maxValue == 0)
	{
		maxValue = 2;
	}
	
	var resultArr = getMaxAndPoingArr(maxValue,3);
	var localMaxVal = resultArr[0];
	var eachLayer = resultArr[1];
	var ticksArr = getEachLayer(eachLayer,3,maxValue);
	var option = { xaxis: { mode:null,showLabel:true,ticks:ticksVal,tickFormatter:null, labelHeight:20, backgroundColor:"#e6e5e6", style:"height:0px; border-width:0px 0px 0px 0px; border-style:solid; border-color:#C5C5C5; font-weight:normal; line-height:12px" }, 
								 yaxis: {labelWidth:40,labelHeight:2, min:0, max:eachLayer*3, ticks:[[0,""],[eachLayer,''+eachLayer],[ticksArr[2],''+ticksArr[2]],[eachLayer*3,''+ticksArr[3]]]}, 
								 bars:{show:true, barWidth:1, maxBarWidth:6, offset:0}, 
								 grid: { hoverable: true, clickable: true, color:"#000000" } };

	var height = $("#" + conatinerId).height();
	var width = $("#" + conatinerId).width();
	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[width,height]};
	commonPaint(data,option,conatinerId,canvasObj);
}

function commonHisSingleLine(data,ticksVal,maxValue,conatinerId,gbFillColor,cacheUse10YearChart)
{
	if(maxValue == 0)
	{
		maxValue = 2;
	}
	var intervalNumber = 1;
	if(cacheUse10YearChart == 'true')
	{
		intervalNumber = 4;
	}
	var resultArr = getMaxAndPoingArr(maxValue,3);
	var localMaxVal = resultArr[0];
	var eachLayer = resultArr[1];
	var ticksArr = getEachLayer(eachLayer,3,maxValue);
	var option = { xaxis: { mode:null,showLabel:true,interval:intervalNumber,ticks:ticksVal,tickFormatter:null, labelHeight:20, backgroundColor:"#e6e5e6", style:"height:0px; border-width:0px 0px 0px 0px; border-style:solid; border-color:#C5C5C5; font-weight:normal; line-height:12px" }, 
								 yaxis: {labelWidth:40,labelHeight:2, min:0, max:eachLayer*3, ticks:[[0,""],[eachLayer,''+eachLayer],[ticksArr[2],''+ticksArr[2]],[eachLayer*3,''+ticksArr[3]]]}, 
								 lines:{show:true, barWidth:1, maxBarWidth:6, offset:0,fill: true,fillColor: gbFillColor}};

	var height = $("#" + conatinerId).height();
	var width = $("#" + conatinerId).width();
	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[width,height]};
	commonPaint(data,option,conatinerId,canvasObj);
}

function commonEquityOSSingleLine(data,ticksVal,maxValue,conatinerId,cacheUse10YearChart)
{
	
	var intervalNumber = 1;
	if(cacheUse10YearChart == 'true')
	{
		intervalNumber = 4;
	}
	var resultArr = getMaxAndPoingArr(maxValue,4);
	var localMaxVal = resultArr[0];
	var eachLayer = resultArr[1];
	var ticksArr = getEachLayer(eachLayer,4,maxValue);
	var option = { xaxis: { mode:null,showLabel:false,interval:intervalNumber,ticks:ticksVal,tickFormatter:null, labelHeight:2, backgroundColor:"#e6e5e6", textAlign:"left", style:"height:35px; border-width:0px 0px 0px 0px; border-style:solid; border-color:#253864; font-weight:normal" }, 
								 yaxis: {showLabel:false,labelWidth:10,labelHeight:1, min:0, max:eachLayer*4, ticks:[[0,""],[eachLayer,''+eachLayer],[ticksArr[2],''+ticksArr[2]],[ticksArr[3],''+ticksArr[3]],[ticksArr[4],''+ticksArr[4]]]}, 
								 lines:{show:true, barWidth:1, maxBarWidth:6, offset:0,fill: true,fillColor: "#dde0e6"}};

	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[53,16]};
	
	commonPaint(data,option,conatinerId,canvasObj);
}

function commonEquityOSSingleFlowChart(data,ticksVal,maxValue,conatinerId,cacheUse10YearChart)
{
	
	var intervalNumber = 1;
	if(cacheUse10YearChart == 'true')
	{
		intervalNumber = 4;
	}
	var resultArr = getMaxAndPoingArr(maxValue,4);
	var localMaxVal = resultArr[0];
	var eachLayer = resultArr[1];
	var ticksArr = getEachLayer(eachLayer,4,maxValue);
	var option = { 
			xaxis: { mode:null,showLabel:true,ticks:ticksVal,interval:intervalNumber,tickFormatter:null,labelHeight:-10,textAlign:"left",style:"height:35px; margin-top:20px; padding-top:50px; border-width:0px 0px 1px 0px; border-style:solid; border-color:#C5C5C5; font-weight:bold"
					}, yaxis: {showLabel:true,labelWidth:40,labelHeight:0, min:0, max:eachLayer*4,ticks:[[0,""],[eachLayer,''+eachLayer],[ticksArr[2],''+ticksArr[2]],[ticksArr[3],''+ticksArr[3]],[ticksArr[4],''+ticksArr[4]]] }, 
								 lines:{show:true, barWidth:30, maxBarWidth:10, offset:0,fill: true,fillColor: "#dde0e6"},
								 grid: {fill: true,fillColor: "#FF0000"}};

	var canvasObj = {ctx:null,octx:null,eventHolder:null,size:[275,85]};
	
	commonPaint(data,option,conatinerId,canvasObj);
}
var decimalPoint = 5;
function getMaxAndPoingArr(maxValue,layers)
{
	var resultArr = new Array();
	var localMaxVal;
	var eachLayer;
	if(parseInt(maxValue) > 10)
	{
		localMaxVal = parseInt(Math.ceil(maxValue * 1.1));
		eachLayer = parseInt(Math.ceil(localMaxVal / layers));
	}
	else
	{
		localMaxVal = parseFloat(maxValue * 1.1).toFixed(decimalPoint);
		eachLayer = parseFloat(localMaxVal / layers).toFixed(decimalPoint);
	}
	resultArr.push(localMaxVal);
	resultArr.push(eachLayer);
	return resultArr;
}

function getEachLayer(layer,sort,maxValue)
{
	var resultArr = new Array();
	if(parseInt(maxValue) > 10)
	{
		for ( i = 2; i <= sort; i++) {
			resultArr[i]= parseInt(Math.ceil(layer * i));
		}
	}
	else
	{
		for ( i = 2; i <= sort; i++) {
			resultArr[i] = parseFloat(layer * i).toFixed(decimalPoint);
		}
	}
	return resultArr;
}

function commonPaint(data,option,conatinerId,canvasObj)
{
	var container = $("#"+conatinerId);
	container.html("");
	
	var flotObj = null;


function createCanvas(target,oCanvas) { 
      if (target.length < 1) {
          return;
      }
      var w, h;
      if (!oCanvas.size || oCanvas.size.length < 1) {
          w = target.width();
          h = target.height();
      } else {
          w = oCanvas.size[0];
          h = oCanvas.size[1];
      }         
      oCanvas.octx = null;
      oCanvas.ctx = null ;
      target.find(".tickLabels").html("");
      target.css("position", "relative"); // for positioning
      target.css("float","left"); // for positioning
														// labels and overlay
      var aCanvas = target.find("canvas");
      var isIE9 = navigator.userAgent.toLowerCase().indexOf("msie 9") > -1;
      var isTrident50 = navigator.userAgent.toLowerCase().indexOf("trident/5.0") > -1;
      if (isTrident50 && (navigator.userAgent.toLowerCase().indexOf("msie 7.0") > -1)) {
    	  isIE9 = true;
      }
      var bIsIE = $.browser.msie && !isIE9;
      if(bIsIE)   window.G_vmlCanvasManager.init_(document); // make sure
																// everything is
																// setup
      if (aCanvas.length < 1) {   
          oCanvas.canvas = document.createElement("canvas");
      } else {
          oCanvas.canvas  = aCanvas.get(0);
      }
      oCanvas.canvas.width =  w;
      oCanvas.canvas.height = h; 
      
      //oCanvas.canvas.style.float = "left";
      if (aCanvas.length < 1) {
          target.append(oCanvas.canvas);
      }  
      if (bIsIE) { // excanvas hack
          oCanvas.canvas = window.G_vmlCanvasManager.initElement(oCanvas.canvas); 
      }
      oCanvas.ctx = oCanvas.canvas.getContext("2d");  
      if (aCanvas.length < 1) {     
          oCanvas.overlay = document.createElement("canvas");
      } else {
          oCanvas.overlay  = aCanvas.get(1);
      }
      oCanvas.overlay.width =  w;
      oCanvas.overlay.height = h;
      oCanvas.overlay.style.position = "absolute";
      oCanvas.overlay.style.left="0px";
      oCanvas.overlay.style.top="0px";
      if (aCanvas.length < 1) {
          target.append(oCanvas.overlay);
      }  
      if (bIsIE) {  // excanvas hack
          oCanvas.overlay = window.G_vmlCanvasManager.initElement(oCanvas.overlay);
      }
      oCanvas.octx = oCanvas.overlay.getContext("2d");
      oCanvas.eventHolder = $([oCanvas.canvas,oCanvas.overlay]);
      oCanvas.overlay = null;
      oCanvas.canvas = null;
  }
  function draw() {
      if (flotObj == null) {
          flotObj = $.plot(conatinerId,option,canvasObj);
      }
      flotObj.init(data,option);
  }
  createCanvas(container,canvasObj);
  draw();
}

//cache variable for Ownership Current data
var currFundData;
var currInstData;
var curData;
var currFundVal;
var currInstVal;
var currMax;
var currInsiderVal;
var currInsiderData;
//cache variable for Ownership Current data

//global cache flag
var cacheHasLoad = false;

//cache variable for Ownership History data
var fundsArr;
var cacheHisMutualFunds;
var cacheHisTicksVal;
var cacheHisInst;
var cacheHistLineQuarsTicksVal;

var cacheHisMaxValue;
var cacheHisData;
var cacheHisInsiderVal;

var cacheUse10YearChart = 'false';

var cacheInsiderHisMaxVal;
var cacheInstHistMaxVal;
var cacheFundHisMaxVal;
//cache variable for Ownership History data

//cache Equity OS weather or not to load the chart data
var hasLoadEquityOSFunds = false;
var hasLoadEquityOSInst = false;

//Use to prompt message
var hasChangedMsg = false;

var disType_EquityOS = 'disType_EquityOS';
var disType_OwnerActivity_Fund = 'disType_OwnerActivity_Fund';
var disType_OwnerActivity_Inst = 'disType_OwnerActivity_Inst';
var globalLoacalCulture = 'us';

function displayEnlargeImg(divId,disType)
{
	var demo = document.getElementById(divId);
	var ei = document.getElementById("enlarge_images");
	var ts = demo;
	ts.onmousemove = function(event){
		var titleCon = '';
		if(disType_EquityOS == disType)
		{
			titleCon = document.getElementById('equityOSChartGid').value;
		}
		else if(disType_OwnerActivity_Inst == disType)
		{
			titleCon = document.getElementById(divId+'colName').innerHTML;
			titleCon = '<b>'+titleCon+'</b>';
		}
		else if(disType_OwnerActivity_Fund == disType)
		{
			var temp = divId.substring(divId.length-1,divId.length);
			titleCon = document.getElementById('instChartData'+temp+'colName').innerHTML;
			titleCon = '<b>'+titleCon+'</b>';
		}
		document.getElementById('titleDescGid').innerHTML = titleCon;
		ei.style.display = "block";
		event = event || window.event;
		commonSingleFlowChart(divId,'innerEnlarge_images','flow');
		ei.style.position="absolute";
		var positions = mouseCoords(event);
		
		var popDivHeight = ei.offsetHeight;
		var popDivWith = ei.offsetWidth;
		
		var bodyHeight = document.documentElement.clientHeight;
		var bodyWidth = document.documentElement.clientWidth;

		if((positions.y + popDivHeight + 10) > bodyHeight)
		{
			ei.style.top  = positions.y - popDivHeight - 10 + 'px';
		}
		else
		{
			ei.style.top  = positions.y  + 10 + 'px';
		}
		
		if((positions.x + popDivWith + 10) > bodyWidth)
		{
			ei.style.left  = positions.x - popDivWith - 10 + 'px';
		}
		else
		{
			ei.style.left  = positions.x  + 10 + 'px';
		}
		
		ei.style.zIndex = 1000;
	}
	ts.onmouseout = function(){
		ei.style.display = "none";
	}
}

function mouseCoords(ev){
    if(ev.pageX||ev.pageY){return {x:ev.pageX, y:ev.pageY};}
    return {x:ev.clientX + document.documentElement.scrollLeft,y:ev.clientY + document.documentElement.scrollTop}
}



function loadChartDataForActivityInst()
{ 
	var gidArr = new Array();
	
	getGidArr(gidArr,'instChartData');
	commonEquityOS8QuarsChart(gidArr,disType_OwnerActivity_Inst);
	loadChartDataForActivityFunds();
}
function loadChartDataForOwnerActivityInst()
{ 
	var gidArr = new Array();
	
	getGidArr(gidArr,'instChartData');
	commonEquityOS8QuarsChart(gidArr,disType_OwnerActivity_Inst);
	
}
function loadChartDataForActivityFunds()
{
   
	var gidArr = new Array();
	getGidArr(gidArr,'fundChartData');
	commonEquityOS8QuarsChart(gidArr,disType_OwnerActivity_Fund);
}

function getGidArr(gidArr,gid)
{
	for(i =0;i<12;i++)
	{
		gidArr.push(gid+i);
	}
	return gidArr;
}

function loadChartDataForOSInstEquity()
{
	var allOwnerIds = $.trim($('#allInstOwnerIds').html()).split(',');
	
	//display for total data chart
	commonEquityOS8QuarsChart(allOwnerIds,disType_EquityOS);
	hasLoadEquityOSInst = true;
	commonSingleFlowChart('equityInstDiv','equityInstDiv','totalBar');
}
function loadChartDataForOSFundEquity()
{
	var allOwnerIds = $.trim($('#allOwnerIds').html()).split(',');
	
	//display for total data chart
	commonSingleFlowChart('equityFundDiv','equityFundDiv','totalBar');
	commonEquityOS8QuarsChart(allOwnerIds,disType_EquityOS);
	hasLoadEquityOSFunds = true;
}

function commonEquityOS8QuarsChart(allOwnerIds,disType)
{

	$.each(allOwnerIds, function(i, displayId){
	var	divGid = ''+displayId+'cache';
		var dataObj = $("#"+divGid);
		if(undefined == dataObj)
		{
			return;
		}
		var cacheEquityChartInfo = dataObj.html();
		if(null == cacheEquityChartInfo)
		{
			return;
		}
		var tempArr = cacheEquityChartInfo.split("|");
		if(null != tempArr && 3 != tempArr.length)
		{
			return;
		}
		if("-000000" == $.trim(tempArr[2]))
		{
			return;
		}
		var equityChartData = eval('(' +  $.trim(tempArr[0]) + ')');
		var quityChartQuars = eval('(' +  $.trim(tempArr[1]) + ')');
		var quityChartMaxVal = eval('(' +  $.trim(tempArr[2]) + ')');
		
//		equityChartData.push([equityChartData.length+1,0]);
		var tempData = [{data:equityChartData}];
		$("#"+displayId).show();
		commonEquityOSSingleLine(tempData,quityChartQuars,quityChartMaxVal,displayId,cacheUse10YearChart);
		
		displayEnlargeImg(displayId,disType);
	});
	
}

function commonSingleFlowChart(ownerId,containerId,operateType)
{
		var divGid = ''+ownerId+'cache';
		var dataObj = $("#"+divGid);
		var cacheEquityChartInfo = dataObj.html();
		if(null == cacheEquityChartInfo)
		{
			return;
		}
		var tempArr = cacheEquityChartInfo.split("|");
		var equityChartData;
		var quityChartQuars;
		var quityChartMaxVal;
		var arr0 = tempArr[0];
		var arr1 = tempArr[1];
		var arr2 = tempArr[2];
		
		var needReturn = true;
		if(arr0 != undefined && arr0 != "" && arr0 != null)
		{
			equityChartData = eval('(' +  $.trim(arr0) + ')');
			needReturn = false;
		}
		else
		{
			equityChartData = new Array();
		}
		
		if(arr1 != undefined && arr1 != "" && arr1 != null)
		{
			quityChartQuars = eval('(' +  $.trim(arr1) + ')');
			needReturn = false;
		}
		else
		{
			quityChartQuars = new Array();
		}
		
		if(arr2 != undefined && arr2 != "" && arr2 != null)
		{
			quityChartMaxVal = eval('(' +  $.trim(arr2) + ')');
			needReturn = false;
		}
		else
		{
			quityChartMaxVal = 0;
		}
		
		if(needReturn)
		{
			return;
		}
		
//		equityChartData.push([equityChartData.length+1,0]);
		var tempData = [{data:equityChartData}];
		
		if('flow' == operateType)
		{
			commonEquityOSSingleFlowChart(tempData,quityChartQuars,quityChartMaxVal,containerId,cacheUse10YearChart);
		
		}
		else if('totalBar' == operateType)
		{
			$("#"+containerId).show();
			commonEquityOSSingleLine(tempData,quityChartQuars,quityChartMaxVal,containerId,cacheUse10YearChart);
			displayEnlargeImg(containerId,disType_EquityOS);
		}
}


function preparedSumDataForOSHistory()
{
	if(cacheHasLoad)
	{
//		commonHisQuarsPaintLine(cacheHisData,cacheHisTicksVal,cacheHisMaxValue,'idEquitySumHistChart');
		
		commonHisQuarsPaintLine(cacheHisData,cacheHistLineQuarsTicksVal,cacheHisMaxValue,'idEquitySumHistChart',cacheUse10YearChart);
		preparedSumDataForSingleHisInst();
		return;
	}
	cacheAllDataAboutCurrAndHis();
}

function copyArrForSingleHistBarChart(convertedArr)
{
	var t = new Array();
	$.map( convertedArr, function(n){
		  t.push(n);
		});
	t.push([convertedArr.length+1,-100000]);
	var tempCacheHisData = [{data:t}];
	return tempCacheHisData;
}

function preparedSumDataForSingleHisInst()
{
	if(cacheHasLoad)
	{
		var tempCacheHisData = copyArrForSingleHistBarChart(cacheHisInst);
		if(cacheUse10YearChart == 'true')
		{
			var cacheInstFillColor = "#dde0e7";
			commonHisSingleLine(tempCacheHisData,cacheHisTicksVal,cacheInstHistMaxVal,'imageDiv0',cacheInstFillColor,cacheUse10YearChart);
		}
		else
		{
			commonHisSingleBar(tempCacheHisData,cacheHisTicksVal,cacheInstHistMaxVal,'imageDiv0');
		}
		return;
	}
	cacheAllDataAboutCurrAndHis();
}

function preparedSumDataForSingleHisFunds()
{
	if(cacheHasLoad)
	{
		
		var tempCacheHisData = copyArrForSingleHistBarChart(cacheHisMutualFunds);
		
		if(cacheUse10YearChart == 'true')
		{
			var cacheFundFillColor = "#f2d9cd";
			commonHisSingleLine(tempCacheHisData,cacheHisTicksVal,cacheFundHisMaxVal,'imageDiv1',cacheFundFillColor,cacheUse10YearChart);
		}
		else
		{
			commonHisSingleBar(tempCacheHisData,cacheHisTicksVal,cacheFundHisMaxVal,'imageDiv1');
		}
		return;
	}
	cacheAllDataAboutCurrAndHis();
}

function preparedSumDataForSingleHisInsider()
{
	
	if(cacheHasLoad)
	{
		var tempCacheHisData = copyArrForSingleHistBarChart(cacheHisInsiderVal);
		if(cacheUse10YearChart == 'true')
		{
			var cacheInsiderFillColor = "#ffe89d";
			commonHisSingleLine(tempCacheHisData,cacheHisTicksVal,cacheInsiderHisMaxVal,'imageDiv2',cacheInsiderFillColor,cacheUse10YearChart);
		}
		else
		{
			commonHisSingleBar(tempCacheHisData,cacheHisTicksVal,cacheInsiderHisMaxVal,'imageDiv2');
		}
		return;
	}
	cacheAllDataAboutCurrAndHis();
}

function openWin(url) {
 	var win = window.open(url, 'newWindow', 'width=750,height=600,top=30,left=30,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes');
 	if(win == null || undefined == win){
 		return;
 	}
 	try{
	 	win.focus();
 	}
 	catch(err){
 	}
}

function locateTo(url){
	window.location.href=url;
}



