OSDN Git Service

25927f522c8d8b2fa220318763fd5652d9592c18
[sie/sie.git] / org / w3c / dom / svg.js
1 /*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence
2  *公式ページは http://sie.sourceforge.jp/
3  *利用方法は <script defer="defer" type="text/javascript" src="sie.js"></script>
4  *http://sie.sourceforge.jp/
5  *Usage: <script defer="defer" type="text/javascript" src="sie.js"></script>
6  */
7 /* ***** BEGIN LICENSE BLOCK *****
8  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9  *
10  * The contents of this file are subject to the Mozilla Public License Version
11  * 1.1 (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS" basis,
16  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17  * for the specific language governing rights and limitations under the
18  * License.
19  *
20  * The Original Code is the Mozilla SVG Cairo Renderer project.
21  *
22  * The Initial Developer of the Original Code is IBM Corporation.
23  * Portions created by the Initial Developer are Copyright (C) 2004
24  * the Initial Developer. All Rights Reserved.
25  *
26  * Parts of this file contain code derived from the following files(s)
27  * of the Mozilla SVG project (these parts are Copyright (C) by their
28  * respective copyright-holders):
29  *    layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
30  *
31  * Contributor(s):DHRNAME revulo bellbind
32  *
33  * Alternatively, the contents of this file may be used under the terms of
34  * either of the GNU General Public License Version 2 or later (the "GPL"),
35  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
36  * in which case the provisions of the GPL or the LGPL are applicable instead
37  * of those above. If you wish to allow use of your version of this file only
38  * under the terms of either the GPL or the LGPL, and not to allow others to
39  * use your version of this file under the terms of the MPL, indicate your
40  * decision by deleting the provisions above and replace them with the notice
41  * and other provisions required by the GPL or the LGPL. If you do not delete
42  * the provisions above, a recipient may use your version of this file under
43  * the terms of any one of the MPL, the GPL or the LGPL.
44  *
45  * ***** END LICENSE BLOCK ***** */
46 /*
47  * Copyright (c) 2000 World Wide Web Consortium,
48  * (Massachusetts Institute of Technology, Institut National de
49  * Recherche en Informatique et en Automatique, Keio University). All
50  * Rights Reserved. This program is distributed under the W3C's Software
51  * Intellectual Property License. This program is distributed in the
52  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
53  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
54  * PURPOSE.
55  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
56  */
57
58
59 //これを頭に付けたら、内部処理用
60 var  NAIBU = {};
61
62 /*
63 // File: svg.idl
64 #ifndef _SVG_IDL_
65 #define _SVG_IDL_
66 // For access to DOM2 core
67 #include "dom.idl"
68 // For access to DOM2 events
69 #include "events.idl"
70 // For access to those parts from DOM2 CSS OM used by SVG DOM.
71 #include "css.idl"
72 // For access to those parts from DOM2 Views OM used by SVG DOM.
73 #include "views.idl"
74 // For access to the SMIL OM used by SVG DOM.
75 #include "smil.idl"
76 #pragma prefix "dom.w3c.org"
77 #pragma javaPackage "org.w3c.dom"
78 module svg
79 {
80   typedef dom::DOMString DOMString;
81   typedef dom::DOMException DOMException;
82   typedef dom::Element Element;
83   typedef dom::Document Document;
84   typedef dom::NodeList NodeList;
85   // Predeclarations
86   interface SVGElement;
87   interface SVGLangSpace;
88   interface SVGExternalResourcesRequired;
89   interface SVGTests;
90   interface SVGFitToViewBox;
91   interface SVGZoomAndPan;
92   interface SVGViewSpec;
93   interface SVGURIReference;
94   interface SVGPoint;
95   interface SVGMatrix;
96   interface SVGPreserveAspectRatio;
97   interface SVGAnimatedPreserveAspectRatio;
98   interface SVGTransformList;
99   interface SVGAnimatedTransformList;
100   interface SVGTransform;
101   interface SVGICCColor;
102   interface SVGColor;
103   interface SVGPaint;
104   interface SVGTransformable;
105   interface SVGDocument;
106   interface SVGSVGElement;
107   interface SVGElementInstance;
108   interface SVGElementInstanceList;
109 */
110 function SVGException(code) {
111   /*unsigned short*/  this.code = code;
112   if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
113     this.message = "SVG Wrong Type Error";
114   } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
115     this.message = "SVG Invalid Value Error";
116   } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
117     this.message = "SVG Matrix Not Invertable";
118   }
119   return this;
120 };
121 SVGException.constructor = Error;
122 SVGException.prototype = new Error();
123 // SVGExceptionCode
124 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR           = 0;
125 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR        = 1;
126 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE    = 2;
127
128 /*SVGElement
129  *すべてのSVG関連要素の雛形となるオブジェクト
130  */
131 function SVGElement() {
132   Element.call(this);
133   SVGStylable.call(this);             //ElementCSSInlineStyleのインタフェースを継承
134   /*interface SVGTransformable : SVGLocatable
135    *TransformListはtransform属性を行列で表現したあとのリスト構造
136    */
137   /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
138   //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
139   this.addEventListener("DOMAttrModified", function(evt){
140     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
141       return;
142     }
143     var name = evt.attrName,
144         tar = evt.target;
145     if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
146       tar._attributeStyle.setProperty(name, evt.newValue, "");
147     }
148     if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
149       tar.id = evt.newValue;
150     } else if ((name === "transform") && !!tar.transform) {
151       var tft = evt.newValue,
152           degR = tar._degReg,
153           coma = tft.match(tar._comaReg),   //コマンド文字にマッチ translate
154           list = tft.match(tar._strReg),    //カッコ内のリストにマッチ (10 20 30...)
155           a,b,c,d,e,f,
156           lis,
157           com,
158           deg,
159           rad,
160           degli,
161           s,
162           cm,
163           degz,
164           etod = evt.target.ownerDocument.documentElement,
165           ttb = tar.transform.baseVal;
166       //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
167       for (var j=0,cli=coma.length;j<cli;j++) {
168         s = etod.createSVGTransform();
169         lis = list[j],
170         com = coma[j];
171         deg = lis.match(degR);
172         degli = deg.length;
173         if (degli === 6) {
174           cm = s.matrix;
175           cm.a = +(deg[0]);
176           cm.b = +(deg[1]);
177           cm.c = +(deg[2]);
178           cm.d = +(deg[3]);
179           cm.e = +(deg[4]);
180           cm.f = +(deg[5]);
181         } else {
182           if (degli === 3) {
183             degz = +(deg[0]);
184             s.setRotate(degz, +(deg[1]), +(deg[2]))
185           } else if (degli <= 2) {
186             degz = +(deg[0]);
187             if (com === "translate") {
188               s.setTranslate(degz, +(deg[1] || 0));
189             } else if (com === "scale") {
190               s.setScale(degz, +(deg[1] || deg[0]));
191             } else if (com === "rotate") {
192               s.setRotate(degz, 0, 0);
193             } else if (com === "skewX") {
194               s.setSkewX(degz);
195             } else if (com === "skewY") {
196               s.setSkewY(degz);
197             }
198           }
199         }
200         ttb.appendItem(s);
201       }
202       tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
203     } else if (name === "style") {
204       var sc = evt.newValue,
205           style = tar.style,
206           a,
207           ai,
208           m;
209       style.cssText = sc;
210       if (sc !== "") {
211         //style属性値の解析
212         sc = sc.replace(tar._shouReg, "")
213                .replace(tar._conReg, ":")
214                .replace(tar._bouReg, ";");
215         a = sc.split(";");
216         for (var i=0, ali=a.length;i<ali;++i) {
217           ai = a[i],
218           m = ai.split(":");
219           if (ai !== "") {
220             style.setProperty(m[0], m[1]);
221           }
222           ai = m = void 0;
223         }
224       }
225       a = sc = style = void 0;
226     } else if (name === "class") {
227       tar.className = evt.newValue;
228     } else if (name.indexOf("on") === 0) {           //event属性ならば
229       /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
230        *ところが、IEでは、undefinedの値を返してしまう。
231        *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
232        */
233       eval("document._s = (function(evt){" +evt.newValue+ "})");
234       var v = name.slice(2);
235       if (v === "load") {
236         v = "SVGLoad";
237       } else if (v === "unload") {
238         v = "SVGUnload";
239       } else if (v === "abort") {
240         v = "SVGAbort";
241       } else if (v === "error") {
242         v = "SVGError";
243       } else if (v === "resize") {
244         v = "SVGResize";
245       } else if (v === "scroll") {
246         v = "SVGScroll";
247       } else if (v === "zoom") {
248         v = "SVGZoom";
249       } else if (v === "begin") {
250         v = "beginEvent";
251       } else if (v === "end") {
252         v = "endEvent";
253       } else if (v === "repeat") {
254         v = "repeatEvent";
255       }
256       tar.addEventListener(v, document._s, false);
257     } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
258       tar.xmlbase = evt.newValue;
259     } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
260       var tea = tar[name],
261           tod = tar.ownerDocument.documentElement,
262           tvw = tod.viewport.width,
263           tvh = tod.viewport.height,
264           s,
265           n = evt.newValue.slice(-2),
266           m = n.charAt(1),
267           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
268           _parseFloat = parseFloat;
269       if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
270       } else if (m === "%") {
271         if (tar._x1width[name]) {
272           tea.baseVal._percent = tvw * 0.01;
273         } else if (tar._y1height[name]) {
274           tea.baseVal._percent = tvh * 0.01;
275         } else {
276           tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
277         }
278         type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
279       } else if (n === "em") {
280         type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
281       } else if (n === "ex") {
282         type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
283       } else if (n === "px") {
284         type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
285       } else if (n === "cm") {
286         type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
287       } else if (n === "mm") {
288         type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
289       } else if (n === "in") {
290         type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
291       } else if (n === "pt") {
292         type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
293       } else if (n === "pc") {
294         type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
295       }
296       s = _parseFloat(evt.newValue);
297       s = isNaN(s) ? 0 : s;
298       tea.baseVal.newValueSpecifiedUnits(type, s);
299       tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
300     }
301     evt = _parseFloat = name = tar = null;
302   }, false);
303   return this;
304 };
305 SVGElement.constructor = Element;
306 SVGElement.prototype = new Element();
307
308 (function(){
309   /*以下の正規表現は属性のパーサの際に用いる*/
310   this._degReg = /[\-\d\.e]+/g;
311   this._comaReg = /[A-Za-z]+(?=\s*\()/g;
312   this._strReg =  /\([^\)]+\)/g;
313   this._syouReg = /^[^a-z\-]+/;
314   this._conReg = /\:\s+/g;
315   this._bouReg = /\s*;[^a-z\-]*/g;
316   /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
317    *getCTMメソッドで使う
318    */
319   this._cacheMatrix = null;
320   /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
321   this._x1width = {
322       "x" : 1,
323       "x1" : 1,
324       "x2" : 1,
325       "width" : 1,
326       "cx" : 1
327   };
328   this._y1height = {
329       "y" : 1,
330       "y1" : 1,
331       "y2" : 1,
332       "height" : 1,
333       "cy" : 1      
334   };
335   /*String*/              this.id      = null;        //id属性の値
336   /*String*/              this.xmlbase = null;   //xml:base属性の値
337   /*SVGSVGElement*/       this.ownerSVGElement;  //ルート要素であるsvg要素
338   /*readonly SVGElement*/ this.viewportElement;  //ビューポートを形成する要素(多くはsvg要素)
339   /*readonly attribute SVGElement*/ this.nearestViewportElement  = null;
340   /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
341   
342   /*interface SVGLocatable*/
343   /*SVGRect*/     this.getBBox = function(){
344     var s = new SVGRect(),
345         data = this._tar.path.value,
346         vi = this.ownerDocument.documentElement.viewport,
347         el = vi.width,
348         et = vi.height,
349         er = 0,
350         eb = 0,
351         degis = data.match(/[0-9\-]+/g),
352         nx,
353         ny;
354     /*要素の境界領域を求める(四隅の座標を求める)
355      *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
356      *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
357      */
358     for (var i=0,degisli=degis.length;i<degisli;i+=2) {
359       nx = +(degis[i]),
360       ny = +(degis[i+1]);
361       el = el > nx ? nx : el;
362       et = et > ny ? ny : et;
363       er = er > nx ? er : nx;
364       eb = eb > ny ? eb : ny;
365     }
366     s.x      = el;
367     s.y      = et;
368     s.width  = er - el;
369     s.height = eb - et;
370     nx = ny = data = degis =el = et = er = eb = vi = void 0;
371     return s;
372   };
373
374   /*getCTMメソッド
375    *CTMとは現在の利用座標系に対する変換行列
376    *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
377    *1.2ではgetCTMが言及されていない
378    *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
379    */
380   /*SVGMatrix*/   this.getCTM = function() {
381     var s, m;
382     if (!!this._cacheMatrix) { //キャッシュがあれば
383       s = this._cacheMatrix;
384     } else {
385       m = this.transform.baseVal.consolidate();
386       if (m) {
387         m = m.matrix;
388       } else {
389         m = this.ownerDocument.documentElement.createSVGMatrix();
390       }
391       if (this.parentNode && !!this.parentNode.getCTM) {
392         s = this.parentNode.getCTM().multiply(m);
393       } else {
394         s = m;
395       }
396       m = void 0;
397       this._cacheMatrix = s; //キャッシュをためて次回で使う
398     }
399     return s;
400   };
401
402   /*SVGMatrix*/   this.getScreenCTM = function(){
403     if (!this.parentNode) {
404       return null;
405     }
406     var view = this.nearestViewportElement || this.ownerDocument.documentElement;
407     var s = view.getScreenCTM().multiply(this.getCTM());
408     view = null;
409     return s;
410   };
411
412   /*getTransformToElementメソッド
413    *これは、あるelementへの変換行列を計算して返す
414    *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
415    */
416   /*SVGMatrix*/   this.getTransformToElement = function(/*SVGElement*/ element ){
417     var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
418     return s;
419   };
420 }).apply(SVGElement.prototype);
421
422 function SVGAnimatedBoolean() {
423   /*boolean*/  this.animVal = this.baseVal = true;
424   return this;
425 };
426
427 function SVGAnimatedString() {
428   /*String*/ this.animVal = this.baseVal = "";
429   return this;
430 };
431
432 function SVGStringList() {
433   return this;
434 };
435 SVGStringList.prototype = new Array();
436 (function(){
437   /*readonly unsigned long*/ this.numberOfItems = 0;
438   /*void*/   this.clear = function(){
439     for (var i=0, tli=this.length;i<tli;++i) {
440       delete this[i];
441     }
442     this.numberOfItems = 0;
443   };
444   /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
445     this.clear();
446     this[0] = newItem;
447     this.numberOfItems = 1;
448     return newItem;
449   };
450   /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
451     if (index >= this.numberOfItems || index < 0) {
452       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
453     } else {
454       return (this[index]);
455     }
456   };
457   /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
458     if (index >= this.numberOfItems) {
459       this.appendItem(newItem);
460     } else {
461       this.splice(index, 1, newItem, this.getItem[index]);
462       ++this.numberOfItems;
463     }
464     return newItem;
465   };
466   /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
467     if (index >= this.numberOfItems || index < 0) {
468       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
469     } else {
470       this.splice(index, 1, newItem);
471     }
472     return newItem;
473   };
474                   //raises( DOMException, SVGException );
475   /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
476     if (index >= this.numberOfItems || index < 0) {
477       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
478     } else {
479       this.splice(index, 1);
480       --this.numberOfItems;
481     }
482     return newItem;
483   };
484   /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
485     this[this.numberOfItems] = newItem;
486     ++this.numberOfItems;
487   };
488 }).apply(SVGStringList.prototype);
489
490 function SVGAnimatedEnumeration() {
491   /*unsigned short*/ this.baseVal = 0;
492                          // raises DOMException on setting
493   /*readonly unsigned short*/ this.animVal = 0;
494   return this;
495 };
496 function SVGAnimatedInteger() {
497   /*long*/ this.baseVal = 0;
498                          // raises DOMException on setting
499   /*readonly long*/ this.animVal = 0;
500   return this;
501 };
502 function SVGNumber() {
503   /*float*/ this.value = 0;
504                          // raises DOMException on setting
505   return this;
506 };
507 function SVGAnimatedNumber() {
508   /*float*/ this.baseVal = this.animVal = 0;
509   return this;
510 };
511
512 function SVGNumberList() {
513   return this;
514 };
515 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
516   SVGNumberList.prototype[prop] = SVGStringList.prototype[prop];
517 }
518 function SVGAnimatedNumberList() {
519   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
520   return this;
521 };
522 /*SVGLengthクラス
523  *長さを設定する(単位pxに統一する方便として使う)
524  *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
525  */
526 function SVGLength() {
527   return this;
528 };
529 (function(t) {
530     // Length Unit Types
531   /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN    = 0;
532   /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER     = 1;
533   /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
534   /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS        = 3;
535   /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS        = 4;
536   /*const unsigned short*/ t.SVG_LENGTHTYPE_PX         = 5;
537   /*const unsigned short*/ t.SVG_LENGTHTYPE_CM         = 6;
538   /*const unsigned short*/ t.SVG_LENGTHTYPE_MM         = 7;
539   /*const unsigned short*/ t.SVG_LENGTHTYPE_IN         = 8;
540   /*const unsigned short*/ t.SVG_LENGTHTYPE_PT         = 9;
541   /*const unsigned short*/ t.SVG_LENGTHTYPE_PC         = 10;
542 })(SVGLength);
543
544 SVGLength.prototype = {
545   /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
546   /*attribute float*/          value : 0,                  //利用単位における値
547   /*attribute float*/          valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN,  //unitTypeにおける値
548   /*attribute DOMString*/      valueAsString : "0",
549   _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
550   _fontSize : 12, //単位のemとexで使われるfont-sizeの値
551 /*newValueSpedifiedUnitsメソッド
552  *新しくunitTypeにおける値を設定する
553  *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
554  */
555   newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
556     var n = 1,
557        _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
558     if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
559     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
560       _s = "px";
561     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
562       n = this._percent;
563       _s = "%"
564     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
565       n = this._fontSize;
566       _s = "em";
567     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
568       n = this._fontSize * 0.5;
569       _s = "ex";
570     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
571       n = 35.43307;
572       _s = "cm";
573     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
574       n = 3.543307;
575       _s = "mm";
576     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
577       n = 90;
578       _s = "in";
579     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
580       n = 1.25;
581       _s = "pt";
582     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
583       n = 15;
584       _s = "pc";
585     } else {
586       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
587     }
588     this.unitType = unitType;
589     this.value = valueInSpecifiedUnits * n;
590     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
591     this.valueAsString = valueInSpecifiedUnits + _s;
592     valueInSpecifiedUnits = unitType = n = _s = void 0;
593   },
594 /*convertToSpecifiedUnitsメソッド
595  *valueプロパティを書き換えずに、単位だけを変換する
596  *例:2cmをmmに変換したい場合
597  * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
598  * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
599  * alert(x.valueAsString); //20mm
600  */
601   convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
602     if (this.value === 0) {
603       this.newValueSpecifiedUnits(unitType, 0);
604       return;
605     }
606     var v = this.value;
607     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
608     v = v / this.value * this.valueInSpecifiedUnits;
609     this.newValueSpecifiedUnits(unitType, v); 
610   },
611   /*_emToUnitメソッド
612    *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
613    *単位が%の場合は、新しいvalueへと変換させておく
614    */
615   _emToUnit : function (/*float*/ fontSize) {
616     if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
617       this._fontSize = fontSize;
618       this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
619     }
620   }
621 };
622 function SVGAnimatedLength() {
623   /*readonly SVGLength*/ this.animVal;
624   this.baseVal = new SVGLength();
625   this.baseVal.unitType = 1;
626   return this;
627 };
628 function SVGLengthList() {
629   return this;
630 };
631 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
632   SVGLengthList.prototype[prop] = SVGStringList.prototype[prop];
633 }
634 function SVGAnimatedLengthList() {
635   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
636   return this;
637 };
638 function SVGAngle() { 
639   return this;
640 };
641 SVGAngle.prototype = {
642   /*readonly attribute unsigned short*/ unitType : 0,
643   /*attribute float*/     value : 0,
644                          // raises DOMException on setting
645   /*attribute float*/     valueInSpecifiedUnits : 0,
646                          // raises DOMException on setting
647   /*attribute DOMString*/ valueAsString : "0",
648                          // raises DOMException on setting
649   /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
650     var n = 1,
651         _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
652     if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
653     } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
654       _s = "deg"
655     } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
656       n =  Math.PI / 180;
657       _s = "rad";
658     } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
659       n = 9 / 10;
660       _s = "grad";
661     } else {
662       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
663     }
664     this.unitType = unitType;
665     this.value = valueInSpecifiedUnits * n;
666     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
667     this.valueAsString = valueInSpecifiedUnits + _s;
668     n = _s = void 0;
669     //raises( DOMException );
670   },
671   /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
672     if (this.value === 0) {
673       this.newValueSpecifiedUnits(unitType, 0);
674       return;
675     }
676     var v = this.value;
677     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
678     v = v / this.value * this.valueInSpecifiedUnits;
679     this.newValueSpecifiedUnits(unitType, v); 
680     //raises( DOMException );
681   }
682 };
683 // Angle Unit Types
684 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN     = 0;
685 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
686 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG         = 2;
687 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD         = 3;
688 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD        = 4;
689 function SVGAnimatedAngle() { 
690   /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
691   /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
692   return this;
693 };
694 function SVGColor() {
695   CSSValue.apply(this);
696   /*readonly css::RGBColor*/  this.rgbColor  = new RGBColor();
697   return this;
698 };
699
700   // Color Types
701 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN           = 0;
702 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR          = 1;
703 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
704 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR      = 3;
705 SVGColor.prototype = new CSSValue();  //ノードのプロトタイプチェーンを作って、継承
706 SVGColor.constructor = CSSValue;
707
708 (function(){
709   /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
710   /*readonly SVGICCColor*/    this.iccColor = null;
711   this._regD = /\d+/g;
712   this._regDP = /[\d.]+%/g;
713   /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
714   var s,
715       _parseInt,
716       r, g, b,
717       c;
718   if (!rgbColor || (typeof rgbColor !== "string")) {
719     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
720   }
721   rgbColor = this._keywords[rgbColor] || rgbColor;
722   if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
723     rgbColor = rgbColor.replace(this._regDP, function(s) {
724       return Math.round((2.55 * parseFloat(s)));
725     });
726     s = rgbColor.match(this._regD);
727   } else if (rgbColor.indexOf("#") === 0) {  //#を含む場合
728     s = [];
729     _parseInt = parseInt;
730     r = rgbColor.charAt(1);
731     g = rgbColor.charAt(2);
732     b = rgbColor.charAt(3)
733     if (rgbColor.length < 5) {
734       c = "#" + r + r + g + g + b + b;
735       rgbColor = c;
736       c = void 0;
737     }
738     s[0] = _parseInt(r+rgbColor.charAt(2), 16)+ "";
739     s[1] = _parseInt(rgbColor.charAt(3)+rgbColor.charAt(4), 16)+ "";
740     s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ "";
741     r = g = b = void 0;
742   } else {
743     s = rgbColor.match(this._regD);
744     if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
745       rgbColor = void 0;
746       throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
747     }
748   }
749   this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
750   this.rgbColor.green.setFloatValue(1, s[1]);
751   this.rgbColor.blue.setFloatValue(1, s[2]);
752   rgbColor = s = _parseInt = void 0;
753 };
754
755 //                    raises( SVGException );
756 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
757   this.colorType = colorType;
758   if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
759     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
760   } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
761     this.setRGBColor(rgbColor);
762   } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
763     this.setRGBColor(rgbColor);
764   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
765     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
766   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
767     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
768   }
769   colorType = rgbColor = void 0;
770 }
771 //                    raises( SVGException );
772 //色キーワード
773 this._keywords = {
774     aliceblue:    "rgb(240,248,255)",
775     antiquewhite: "rgb(250,235,215)",
776     aqua:         "rgb(0,255,255)",
777     aquamarine:   "rgb(127,255,212)",
778     azure:        "rgb(240,255,255)",
779     beige:        "rgb(245,245,220)",
780     bisque:       "rgb(255,228,196)",
781     black:        "rgb(0,0,0)",
782     blanchedalmond:"rgb(255,235,205)",
783     blue:         "rgb(0,0,255)",
784     blueviolet:   "rgb(138,43,226)",
785     brown:        "rgb(165,42,42)",
786     burlywood:    "rgb(222,184,135)",
787     cadetblue:    "rgb(95,158,160)",
788     chartreuse:   "rgb(127,255,0)",
789     chocolate:    "rgb(210,105,30)",
790     coral:        "rgb(255,127,80)",
791     cornflowerblue:"rgb(100,149,237)",
792     cornsilk:     "rgb(255,248,220)",
793     crimson:      "rgb(220,20,60)",
794     cyan:         "rgb(0,255,255)",
795     darkblue:     "rgb(0,0,139)",
796     darkcyan:     "rgb(0,139,139)",
797     darkgoldenrod:"rgb(184,134,11)",
798     darkgray:     "rgb(169,169,169)",
799     darkgreen:    "rgb(0,100,0)",
800     darkgrey:     "rgb(169,169,169)",
801     darkkhaki:    "rgb(189,183,107)",
802     darkmagenta:  "rgb(139,0,139)",
803     darkolivegreen:"rgb(85,107,47)",
804     darkorange:    "rgb(255,140,0)",
805     darkorchid:   "rgb(153,50,204)",
806     darkred:      "rgb(139,0,0)",
807     darksalmon:   "rgb(233,150,122)",
808     darkseagreen: "rgb(143,188,143)",
809     darkslateblue:"rgb(72,61,139)",
810     darkslategray:"rgb(47,79,79)",
811     darkslategrey:"rgb(47,79,79)",
812     darkturquoise:"rgb(0,206,209)",
813     darkviolet:   "rgb(148,0,211)",
814     deeppink:     "rgb(255,20,147)",
815     deepskyblue:  "rgb(0,191,255)",
816     dimgray:      "rgb(105,105,105)",
817     dimgrey:      "rgb(105,105,105)",
818     dodgerblue:   "rgb(30,144,255)",
819     firebrick:    "rgb(178,34,34)",
820     floralwhite:  "rgb(255,250,240)",
821     forestgreen:  "rgb(34,139,34)",
822     fuchsia:      "rgb(255,0,255)",
823     gainsboro:    "rgb(220,220,220)",
824     ghostwhite:   "rgb(248,248,255)",
825     gold:         "rgb(255,215,0)",
826     goldenrod:    "rgb(218,165,32)",
827     gray:         "rgb(128,128,128)",
828     grey:         "rgb(128,128,128)",
829     green:        "rgb(0,128,0)",
830     greenyellow:  "rgb(173,255,47)",
831     honeydew:     "rgb(240,255,240)",
832     hotpink:      "rgb(255,105,180)",
833     indianred:    "rgb(205,92,92)",
834     indigo:       "rgb(75,0,130)",
835     ivory:        "rgb(255,255,240)",
836     khaki:        "rgb(240,230,140)",
837     lavender:     "rgb(230,230,250)",
838     lavenderblush:"rgb(255,240,245)",
839     lawngreen:    "rgb(124,252,0)",
840     lemonchiffon: "rgb(255,250,205)",
841     lightblue:    "rgb(173,216,230)",
842     lightcoral:   "rgb(240,128,128)",
843     lightcyan:    "rgb(224,255,255)",
844     lightgoldenrodyellow:"rgb(250,250,210)",
845     lightgray:    "rgb(211,211,211)",
846     lightgreen:   "rgb(144,238,144)",
847     lightgrey:    "rgb(211,211,211)",
848     lightpink:    "rgb(255,182,193)",
849     lightsalmon:  "rgb(255,160,122)",
850     lightseagree: "rgb(32,178,170)",
851     lightskyblue: "rgb(135,206,250)",
852     lightslategray:"rgb(119,136,153)",
853     lightslategrey:"rgb(119,136,153)",
854     lightsteelblue:"rgb(176,196,222)",
855     lightyellow:  "rgb(255,255,224)",
856     lime:         "rgb(0,255,0)",
857     limegreen:    "rgb(50,205,50)",
858     linen:        "rgb(250,240,230)",
859     magenta:      "rgb(255,0,255)",
860     maroon:       "rgb(128,0,0)",
861     mediumaquamarine:"rgb(102,205,170)",
862     mediumblue:    "rgb(0,0,205)",
863     mediumorchid:  "rgb(186,85,211)",
864     mediumpurple:  "rgb(147,112,219)",
865     mediumseagreen:"rgb(60,179,113)",
866     mediumslateblue:"rgb(123,104,238)",
867     mediumspringgreen:"rgb(0,250,154)",
868     mediumturquoise:"rgb(72,209,204)",
869     mediumvioletred:"rgb(199,21,133)",
870     midnightblue:  "rgb(25,25,112)",
871     mintcream:     "rgb(245,255,250)",
872     mistyrose:     "rgb(255,228,225)",
873     moccasin:      "rgb(255,228,181)",
874     navajowhite:   "rgb(255,222,173)",
875     navy:          "rgb(0,0,128)",
876     oldlace:       "rgb(253,245,230)",
877     olive:         "rgb(128,128,0)",
878     olivedrab:     "rgb(107,142,35)",
879     orange:        "rgb(255,165,0)",
880     orangered:     "rgb(255,69,0)",
881     orchid:        "rgb(218,112,214)",
882     palegoldenrod: "rgb(238,232,170)",
883     palegreen:     "rgb(152,251,152)",
884     paleturquoise: "rgb(175,238,238)",
885     palevioletred: "rgb(219,112,147)",
886     papayawhip:    "rgb(255,239,213)",
887     peachpuff:     "rgb(255,218,185)",
888     peru:          "rgb(205,133,63)",
889     pink:          "rgb(255,192,203)",
890     plum:          "rgb(221,160,221)",
891     powderblue:    "rgb(176,224,230)",
892     purple:        "rgb(128,0,128)",
893     red:           "rgb(255,0,0)",
894     rosybrown:     "rgb(188,143,143)",
895     royalblue:     "rgb(65,105,225)",
896     saddlebrown:   "rgb(139,69,19)",
897     salmon:        "rgb(250,128,114)",
898     sandybrown:    "rgb(244,164,96)",
899     seagreen:      "rgb(46,139,87)",
900     seashell:      "rgb(255,245,238)",
901     sienna:        "rgb(160,82,45)",
902     silver:        "rgb(192,192,192)",
903     skyblue:       "rgb(135,206,235)",
904     slateblue:     "rgb(106,90,205)",
905     slategray:     "rgb(112,128,144)",
906     slategrey:     "rgb(112,128,144)",
907     snow:          "rgb(255,250,250)",
908     springgreen:   "rgb(0,255,127)",
909     steelblue:     "rgb(70,130,180)",
910     tan:           "rgb(210,180,140)",
911     teal:          "rgb(0,128,128)",
912     thistle:       "rgb(216,191,216)",
913     tomato:        "rgb(255,99,71)",
914     turquoise:     "rgb(64,224,208)",
915     violet:        "rgb(238,130,238)",
916     wheat:         "rgb(245,222,179)",
917     white:         "rgb(255,255,255)",
918     whitesmoke:    "rgb(245,245,245)",
919     yellow:        "rgb(255,255,0)",
920     yellowgreen:   "rgb(154,205,50)"
921 };
922 }).apply(SVGColor.prototype);
923
924 function SVGRect() { 
925   /*float*/ this.x      = 0;
926                          // raises DOMException on setting
927   /*float*/ this.y      = 0;
928                          // raises DOMException on setting
929   /*float*/ this.width  = 0;
930                          // raises DOMException on setting
931   /*float*/ this.height = 0;
932                          // raises DOMException on setting
933   return this;
934 };
935
936 function SVGAnimatedRect() { 
937   /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
938   return this;
939 };
940
941 SVGUnitTypes = { 
942   // Unit Types
943   /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN           : 0,
944   /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE    : 1,
945   /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
946 };
947 function SVGStylable() {
948   /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
949   /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
950   this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
951   //styleのcssTextプロパティを解析するリスナーを登録しておく
952 };
953 /*getPresentationAttributeメソッド
954  *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
955  */
956 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
957   var s = this._attributeStyle.getPropertyCSSValue(name);
958   if (s) {
959     return s;
960   } else {
961     return null;
962   }
963 };
964
965 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
966  *SIEでは、もっぱらXLink言語の処理を行う
967  */
968 function SVGURIReference() {
969   /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
970   this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
971   this._text = "";
972   this.addEventListener("DOMAttrModified", function(evt){
973     if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
974       evt.target.href.baseVal = evt.newValue;
975       /*_svgload_limitedを+1とすることで、
976        *SVGLoadイベントは発火されなくなる。1を引く必要がある
977        */
978       evt.target.ownerDocument.documentElement._svgload_limited++;
979     }
980     evt = void 0;
981   }, false);
982   this.addEventListener("DOMNodeInserted", function(evt){
983     var tar = evt.target;
984     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
985       return; //強制終了させる
986     }
987     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
988       var tar = evt.target,
989           base,
990           href = tar.href.baseVal,
991           show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
992       /*xlink:href属性とxml:base属性を手がかりに、
993        *ハイパーリンクのURIを決定する処理を行う
994        */
995       if (href !== "") { //xlink:href属性が指定されたとき
996         egbase = tar.xmlbase;
997         if (!egbase) {
998           ep = tar.parentNode;
999           b = null;
1000           while (!b && ep) {
1001             b = ep.xmlbase;
1002             ep = ep.parentNode;
1003           }
1004           base = b;
1005           if (!b) {                        //xml:baseの指定がなければ
1006             if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
1007               lh = location.href;
1008               base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
1009             } else {
1010               base = location.href;
1011             }
1012           }
1013         } else {
1014           base = egbase;
1015         }
1016         if (href.indexOf(":") !== -1) { //絶対URIの場合
1017           base =  "";
1018         }
1019         uri = base + href;
1020         show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
1021         if (href.indexOf(".") === 0) {  //相対URIの場合
1022           uri = href;
1023         }
1024         if (show === "replace") {
1025           tar._tar.setAttribute("href", uri);
1026         } else if (show === "new") {
1027           tar._tar.setAttribute("target", "_blank");
1028           tar._tar.setAttribute("href", uri);
1029         } else if (show === "embed") {
1030           xmlhttp = NAIBU.xmlhttp;
1031           ui = uri.indexOf("#");
1032           if (ui > -1) {
1033             id = uri.slice(ui+1);
1034             uri = uri.replace(/#.+$/, "");
1035           } else {
1036             id = null;
1037           }
1038           if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
1039             doc = tar.ownerDocument;
1040             ele = doc.getElementById(id);
1041             tar._instance = ele;
1042             ev = doc.createEvent("SVGEvents");
1043             ev.initEvent("S_Load", false, false);
1044             tar.dispatchEvent(ev);
1045             tar = xmlhttp = void 0;
1046           } else if (uri.indexOf("data:") > -1) {
1047             tar._tar.src = uri;
1048             tar = xmlhttp = void 0;
1049           } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
1050             if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
1051               tar._tar.src = uri;
1052             } else {
1053               /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
1054               tar.ownerDocument.documentElement._svgload_limited++;
1055               xmlhttp.open("GET", uri, false);
1056               xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1057               xmlhttp.onreadystatechange = function() {
1058                 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
1059                   var type = xmlhttp.getResponseHeader('Content-Type') || "text",
1060                       doc, str, ele, ev;
1061                   if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
1062                     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
1063                      *ここでは、responseTextを用いる
1064                      */
1065                     /*script要素とstyle要素は、
1066                      *_textプロパティに読み込んだテキストを格納しておく
1067                      *それら以外は、_instanceプロパティにDOMツリーを格納しておく
1068                      */
1069                     if (tar.localName !== "script" && tar.localName !== "style") {
1070                       doc = new ActiveXObject("MSXML2.DomDocument");
1071                       str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
1072                       NAIBU.doc.async = false;
1073                       NAIBU.doc.validateOnParse = false;
1074                       NAIBU.doc.resolveExternals = false;
1075                       NAIBU.doc.preserveWhiteSpace = false;
1076                       doc.loadXML(str);
1077                       ele = doc.documentElement;
1078                       tar._instance = tar.ownerDocument.importNode(ele, true);
1079                       if (id) {
1080                         tar._instance = tar._instance.ownerDocument.getElementById(id);
1081                       }
1082                     } else {
1083                       tar._text = xmlhttp.responseText;
1084                     }
1085                   } else if (!!tar._tar) {
1086                     tar._tar.src = uri;
1087                   }
1088                   /*S_LoadイベントとはSIE独自のイベント。
1089                    *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
1090                    */
1091                   ev = tar.ownerDocument.createEvent("SVGEvents");
1092                   ev.initEvent("S_Load", false, false);
1093                   tar.dispatchEvent(ev);
1094                   tar.ownerDocument.documentElement._svgload_limited--;
1095                   /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
1096                   if (tar.ownerDocument.documentElement._svgload_limited < 0) {
1097                     ev = tar.ownerDocument.createEvent("SVGEvents");
1098                     ev.initEvent("SVGLoad", false, false);
1099                     tar.ownerDocument.documentElement.dispatchEvent(ev);
1100                   }
1101                   tar = type = doc = str = ev = void 0;
1102                   /*IEのメモリリーク対策として、空関数を入力*/
1103                   xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1104                   xmlhttp = void 0;
1105                 }
1106               };
1107               xmlhttp.send(null);
1108             }
1109           }
1110         }
1111         tar.ownerDocument.documentElement._svgload_limited--;
1112       }
1113       evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
1114     }, false);
1115     tar = evt = void 0;
1116   }, false);
1117   return this;
1118 };
1119 function SVGCSSRule() { 
1120   CSSRule.apply(this, arguments);
1121   // Additional CSS RuleType to support ICC color specifications
1122   /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
1123   return this;
1124 };
1125 SVGCSSRule.constructor = CSSRule;
1126 SVGCSSRule.prototype = new CSSRule();  //ノードのプロトタイプチェーンを作って、継承
1127
1128 /*SVGDocument
1129  *SVGの文書オブジェクト
1130  */
1131 function SVGDocument(){
1132   Document.apply(this);
1133   DocumentStyle.apply(this);
1134   /*readonly DOMString*/     this.title    = "";
1135   /*readonly DOMString*/     this.referrer = document.referrer;
1136   /*readonly DOMString*/     this.domain   = document.domain;
1137   /*readonly DOMString*/     this.URL      = document.location;
1138   /*readonly SVGSVGElement*/ this.rootElement;
1139   return this;
1140 };
1141 SVGDocument.constructor = Document;
1142 SVGDocument.prototype = new Document();  //ノードのプロトタイプチェーンを作って、継承
1143
1144 /*SVGSVGElement
1145  *svg要素をあらわすオブジェクト
1146  */
1147 function SVGSVGElement(_doc) {
1148   SVGElement.apply(this, arguments);
1149   this._tar = _doc.createElement("v:group");
1150   _doc = void 0;
1151   /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
1152    * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
1153   this._svgload_limited = 0;
1154 /*                SVGElement,
1155                 SVGTests,
1156                 SVGLangSpace,
1157                 SVGExternalResourcesRequired,
1158                 SVGStylable,
1159                 SVGLocatable,
1160                 SVGFitToViewBox,
1161                 SVGZoomAndPan,
1162                 events::EventTarget,
1163                 events::DocumentEvent,
1164                 css::ViewCSS,
1165                 css::DocumentCSS {*/
1166   /*以下のx,y,width,heightプロパティは
1167    *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
1168    *1000というのは、W3Cで触れていないため、独自の初期値を採用
1169    */
1170   var slen = SVGAnimatedLength;
1171   /*readonly SVGAnimatedLength*/ this.x      = new slen();
1172   /*readonly SVGAnimatedLength*/ this.y      = new slen();
1173   /*readonly SVGAnimatedLength*/ this.width  = new slen();
1174   /*readonly SVGAnimatedLength*/ this.height = new slen();
1175   slen = void 0;
1176   /*DOMString*/                  this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
1177   /*DOMString*/                  this.contentStyleType  = "text/css";
1178   /*readonly SVGRect*/           this.viewport          = this.createSVGRect();
1179   /*useCurrentViewプロパティ
1180    * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
1181    */
1182   /*boolean*/                    this.useCurrentView    = false;
1183   /*currentViewプロパティ
1184    * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
1185    */
1186   /*readonly SVGViewSpec*/       this.currentView       = new SVGViewSpec(this);
1187   /*もし、画像をズームやパンしたとき、どのような倍率になるかを
1188    *以下のプロパティを使って次の行列で示すことができる
1189    *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y] 
1190    */
1191   /*float*/                      this.currentScale     = 1;
1192   /*readonly SVGPoint*/          this.currentTranslate = this.createSVGPoint();
1193   /*以下は、SVGFitToViewBoxのインターフェースを用いる
1194    *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
1195    */
1196   /*readonly SVGAnimatedRect*/   this.viewBox = this.currentView.viewBox;
1197   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
1198   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
1199   this._tx = 0;
1200   this._ty = 0;
1201   /*int*/                       this._currentTime = 0;
1202   /*DOMAttrModifiedイベントを利用して、
1203    *随時、属性の値をDOMプロパティに変換しておくリスナー登録
1204    */
1205   this.addEventListener("DOMAttrModified", function(evt){
1206     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1207       return; //強制終了させる
1208     }
1209     var tar = evt.target,
1210         name = evt.attrName,
1211         tv, ovb, par, tp, sa, mos;
1212     if (name === "viewBox") {
1213       tar._cacheScreenCTM = null;
1214       tv = tar.viewBox.baseVal;
1215       ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
1216       tv.x = parseFloat(ovb[0]);
1217       tv.y = parseFloat(ovb[1]);
1218       tv.width = parseFloat(ovb[2]);
1219       tv.height = parseFloat(ovb[3]);
1220       tar.viewBox.baseVal._isUsed = 1;
1221     } else if (name === "preserveAspectRatio") {
1222       tar._cacheScreenCTM = null;
1223       par = evt.newValue;
1224       tp = tar.preserveAspectRatio.baseVal;
1225       sa = 1;
1226       mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
1227       if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
1228         switch (RegExp.$1) {
1229           case "Min":
1230             sa += 1;
1231           break;
1232           case "Mid":
1233             sa += 2;
1234           break;
1235           case "Max":
1236             sa += 3;
1237           break;
1238         }
1239         switch (RegExp.$2) {
1240           case "Min":
1241           break;
1242           case "Mid":
1243             sa += 3;
1244           break;
1245           case "Max":
1246             sa += 6;
1247           break;
1248         }
1249         if (RegExp.$3 === "slice") {
1250           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
1251         } else {
1252           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
1253         }
1254       }
1255       tp.align = sa;
1256       tp.meetOrSlice = mos;
1257     } else if (name === "width") {
1258       /*viewportを更新する*/
1259       tar.viewport.width = tar.width.baseVal.value;
1260     } else if (name === "height") {
1261       tar.viewport.height = tar.height.baseVal.value;
1262     }
1263     evt = name = tv = ovb = par = tp = sa = mos = void 0;
1264   }, false);
1265   this.addEventListener("SVGLoad", function(evt){
1266     /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
1267      *処理を書いたもの。属性が書き換わるたびに、再描画される
1268      */
1269     evt.target.addEventListener("DOMAttrModified", function(evt){
1270       var tar,
1271           evtt, tce, slist;
1272       if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1273         tar = evt.target;
1274         if (tar.parentNode) {
1275           evtt = tar.ownerDocument.createEvent("MutationEvents");
1276           evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1277           evtt.target = tar;
1278           evtt.eventPhase = /*Event.AT_TARGET*/ 2;
1279           tce = tar._capter; //tceは登録しておいたリスナーのリスト
1280           for (var j=0,tcli=tce.length;j<tcli;++j){
1281             if (tce[j]) {
1282               tce[j].handleEvent(evtt);
1283             }
1284           }
1285           if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
1286             tar._cacheMatrix = void 0; //キャッシュを消去
1287             if (tar.firstChild) {
1288               slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
1289               for (var i=0,sli=slist.length;i<sli;++i) {
1290                 tar = slist[i];
1291                 tar._cacheMatrix = void 0;
1292                 evtt = tar.ownerDocument.createEvent("MutationEvents");
1293                 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1294                 evtt.target = tar;
1295                 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
1296                 tce = tar._capter; //tceは登録しておいたリスナーのリスト
1297                 for (var j=0,tcli=tce.length;j<tcli;++j){
1298                   if (tce[j]) {
1299                     tce[j].handleEvent(evtt);
1300                   }
1301                 }
1302               }
1303             }
1304           }
1305         }
1306       }
1307       evtt = tar = evt = tce = slist = void 0;
1308     }, false);
1309     evt = void 0;
1310   }, false);
1311   return this;
1312 };
1313 SVGSVGElement.constructor = SVGElement;
1314 SVGSVGElement.prototype = new SVGElement();
1315 /*void*/          SVGSVGElement.prototype.forceRedraw = function() {
1316 };
1317 /*float*/         SVGSVGElement.prototype.getCurrentTime = function(){
1318   return (this._currentTime);
1319 };
1320 /*void*/          SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
1321   this._currentTime = seconds;
1322 };
1323 /*SVGNumber*/     SVGSVGElement.prototype.createSVGNumber = function(){
1324   var s = new SVGNumber();
1325   s.value = 0;
1326   return s;
1327 };
1328 /*SVGAngle*/     SVGSVGElement.prototype.createSVGAngle = function(){
1329   var s = new SVGAngle();
1330   s.value = 0;
1331   s.unitType = 1;
1332   return s;
1333 };
1334 /*SVGLength*/     SVGSVGElement.prototype.createSVGLength = function(){
1335   var s = new SVGLength();
1336   s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
1337   return s;
1338 };
1339 /*SVGPoint*/      SVGSVGElement.prototype.createSVGPoint = function(){
1340   return new SVGPoint();
1341 };
1342 /*SVGMatrix*/     SVGSVGElement.prototype.createSVGMatrix = function(){
1343   //単位行列を作成
1344   return new SVGMatrix();
1345 };
1346 /*SVGRect*/       SVGSVGElement.prototype.createSVGRect = function(){
1347   return new SVGRect();
1348 };
1349 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransform = function(){
1350   var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
1351   return s;
1352 };
1353 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
1354   var s = new SVGTransform();
1355   s.setMatrix(matrix);
1356   return s;
1357 };
1358 /*getScreenCTM
1359  *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
1360  */
1361 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
1362   if (!!this._cacheScreenCTM) { //キャッシュがあれば
1363     return (this._cacheScreenCTM);
1364   }
1365   var vw = this.viewport.width,
1366       vh = this.viewport.height,
1367       vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
1368   if (!this.useCurrentView) {
1369     vB = this.viewBox.baseVal;
1370     par = this.preserveAspectRatio.baseVal;    
1371   } else {
1372     vB = this.currentView.viewBox.baseVal;
1373     par = this.currentView.preserveAspectRatio.baseVal;
1374   }
1375   if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
1376     this._tx = this._ty = 0;
1377     m = this.createSVGMatrix();
1378     this._cacheScreenCTM = m; //キャッシュを作っておく
1379     return m;
1380   } else {
1381     vbx = vB.x;
1382     vby = vB.y;
1383     vbw = vB.width;
1384     vbh = vB.height;
1385     rw = vw / vbw;
1386     rh = vh / vbh;
1387     xr = 1;
1388     yr = 1;
1389     tx = 0;
1390     ty = 0;
1391     if (par.align === 1) { //none
1392       xr = rw;
1393       yr = rh;
1394       tx = -vbx * xr;
1395       ty = -vby * yr;
1396     } else {
1397       var ax = (par.align + 1) % 3 + 1;
1398       var ay = Math.round(par.align / 3);
1399       switch (par.meetOrSlice) {
1400         case 1: //meet
1401           xr = yr = Math.min(rw, rh);
1402         break;
1403         case 2: //slice
1404           xr = yr = Math.max(rw, rh);
1405         break;
1406       }
1407       tx = -vbx * xr;
1408       ty = -vby * yr;
1409       switch (ax) {
1410         case 1: //xMin
1411         break;
1412         case 2: //xMid
1413           tx += (vw - vbw * xr) / 2;
1414         break;
1415         case 3: //xMax
1416           tx += vw - vbw * xr;
1417         break;
1418       }
1419       switch (ay) {
1420         case 1: //YMin
1421         break;
1422         case 2: //YMid
1423           ty += (vh - vbh * yr) / 2;
1424         break;
1425         case 3: //YMax
1426           ty += vh - vbh * yr;
1427         break;
1428       }
1429     }
1430   }
1431   //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
1432   this._tx = tx;
1433   this._ty = ty;
1434   ttps =  this._tar.style;
1435   ttps.marginLeft = tx+ "px";
1436   ttps.marginTop = ty+ "px";
1437   m = this.createSVGMatrix();
1438   m.a = xr;
1439   m.d = yr;
1440   this._cacheScreenCTM = m; //キャッシュを作っておく
1441   vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
1442   return m;
1443 };
1444
1445   /*interface SVGZoomAndPan*/
1446   // Zoom and Pan Types
1447 SVGZoomAndPan = {
1448   /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
1449   /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
1450   /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
1451 };
1452
1453 function SVGFitToViewBox() {
1454   /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
1455   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
1456   return this;
1457 };
1458 function SVGViewSpec(ele) {
1459   SVGFitToViewBox.apply(this, arguments);
1460   /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
1461   /*readonly SVGElement*/       this.viewTarget = ele;
1462   /*readonly DOMString*/        this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
1463   return this;
1464 };
1465 SVGViewSpec.constructor = SVGFitToViewBox;
1466 SVGViewSpec.prototype = new SVGFitToViewBox();
1467
1468 function SVGGElement(_doc) {
1469   SVGElement.apply(this);
1470   this._tar = _doc.createElement("v:group");
1471   _doc = void 0;
1472   /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
1473    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
1474    */
1475   this.addEventListener("DOMNodeInserted", function(evt){
1476     var tar = evt.target;
1477     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1478       return; //強制終了させる
1479     }
1480     var tnext = tar.nextSibling,
1481         tpart = tar.parentNode._tar,
1482         isLast = true;
1483     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
1484       tpart.insertBefore(tar._tar, tnext._tar);
1485     } else if (tnext && !tnext._tar && tpart) {
1486       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
1487        *use要素や実体参照などは_tarプロパティがないことに注意
1488        */
1489       while (tnext) {
1490         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
1491           tpart.insertBefore(tar._tar, tnext._tar);
1492           isLast = false;
1493         } 
1494         tnext = tnext.nextSibling;
1495       }
1496       if (isLast) {
1497         tpart.appendChild(tar._tar);
1498       }
1499     } else if (!tnext && tpart) {
1500       tpart.appendChild(tar._tar);      
1501     }
1502     tnext = tpart = isLast = evt = tar = void 0;
1503   }, false);
1504   return this;
1505 };
1506 SVGGElement.constructor = SVGElement;
1507 SVGGElement.prototype = new SVGElement();
1508
1509 function SVGDefsElement() {
1510   SVGElement.apply(this, arguments);
1511   this.style.setProperty("display", "none");
1512   return this;
1513 };
1514 SVGDefsElement.constructor = SVGElement;
1515 SVGDefsElement.prototype = new SVGElement();
1516
1517 function SVGDescElement() {
1518   SVGElement.apply(this, arguments);
1519   return this;
1520 }
1521 SVGDescElement.constructor = SVGElement;
1522 SVGDescElement.prototype = new SVGElement();
1523
1524 function SVGTitleElement() {
1525   SVGElement.apply(this, arguments);
1526   this.addEventListener("DOMCharacterDataModified", function(evt){
1527     evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
1528   }, false);
1529   return this;
1530 }
1531 SVGTitleElement.constructor = SVGElement;
1532 SVGTitleElement.prototype = new SVGElement();
1533
1534 function SVGSymbolElement() {
1535   SVGElement.apply(this, arguments);
1536   SVGURIReference.apply(this);
1537   return this;
1538 }
1539 SVGDefsElement.constructor = SVGElement;
1540 SVGDefsElement.prototype = new SVGElement();
1541
1542 function SVGUseElement() {
1543   SVGGElement.apply(this, arguments);
1544   var slen = SVGAnimatedLength;
1545   /*readonly SVGAnimatedLength*/   this.x = new slen();           //use要素のx属性に対応(以下、同様)
1546   /*readonly SVGAnimatedLength*/   this.y = new slen();
1547   /*readonly SVGAnimatedLength*/   this.width = new slen();
1548   /*readonly SVGAnimatedLength*/   this.height = new slen();
1549   slen = void 0;
1550   /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
1551   /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
1552   this.addEventListener("DOMNodeInserted", function(evt){
1553     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1554       return; //強制終了させる
1555     }
1556     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
1557   }, false);
1558   this.addEventListener("S_Load", function(evt){
1559     var tar = evt.target,
1560         style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
1561         fontSize = parseFloat(style.getPropertyValue("font-size")),
1562         tgtb = tar.transform.baseVal,
1563         trans = tar.ownerDocument.documentElement.createSVGTransform();
1564     tar.x.baseVal._emToUnit(fontSize);
1565     tar.y.baseVal._emToUnit(fontSize);
1566     tar.width.baseVal._emToUnit(fontSize);
1567     tar.height.baseVal._emToUnit(fontSize);
1568     tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true);
1569     trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
1570     tgtb.appendItem(trans);
1571     tar.appendChild(tar.instanceRoot);
1572     evt = trans = tar = evtt = tgtb = style = fontSize = void 0;
1573   }, false);
1574   SVGURIReference.apply(this);
1575   return this;
1576 };
1577 SVGUseElement.constructor = SVGElement;
1578 SVGUseElement.prototype = new SVGElement();
1579
1580 function SVGElementInstance() {
1581   /*EventTargetの代用として
1582    *Nodeオブジェクトを継承させる
1583    */
1584   Node.apply(this, arguments);
1585   /*readonly SVGElement*/ this.correspondingElement;       //use要素で使われる参照先の要素
1586   /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
1587   /*readonly SVGElementInstance*/ this.parentNode;
1588   /*readonly SVGElementInstanceList*/ this.childNodes;
1589   /*readonly SVGElementInstance*/ this.firstChild;
1590   /*readonly SVGElementInstance*/ this.lastChild;
1591   /*readonly SVGElementInstance*/ this.previousSibling;
1592   /*readonly SVGElementInstance*/ this.nextSibling;
1593   return this;
1594 };
1595 SVGElementInstance.prototype = new Node();
1596 /*SVGElementInstanceList
1597  */
1598 function SVGElementInstanceList() { 
1599   /*readonly unsigned long*/ this.length = 0;
1600   return this;
1601 };
1602 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
1603   return (this[index]);
1604 }
1605 function SVGImageElement(_doc) {
1606   SVGElement.apply(this, arguments);
1607   this._tar = _doc.createElement("v:image");
1608   //以下は、与えられた属性の値に対応する
1609   var slen = SVGAnimatedLength;
1610   /*readonly SVGAnimatedLength*/ this.x = new slen();
1611   /*readonly SVGAnimatedLength*/ this.y = new slen();
1612   /*readonly SVGAnimatedLength*/ this.width = new slen();
1613   /*readonly SVGAnimatedLength*/ this.height = new slen();
1614   _doc = slen = void 0;
1615   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
1616   this.addEventListener("DOMNodeInserted", function(evt){
1617     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1618       return; //強制終了させる
1619     }
1620     var tar = evt.target;
1621     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
1622     if (tar.nextSibling) {
1623       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
1624         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
1625       }
1626     } else if (!!tar.parentNode._tar){
1627       tar.parentNode._tar.appendChild(tar._tar);
1628     }
1629     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
1630       var tar = evt.target,
1631           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
1632           fontSize = parseFloat(style.getPropertyValue("font-size")),
1633           ts = tar._tar.style,
1634           ctm = tar.getScreenCTM(),
1635           po = tar.ownerDocument.documentElement.createSVGPoint(),
1636           fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
1637           ttfia;
1638       tar.x.baseVal._emToUnit(fontSize);
1639       tar.y.baseVal._emToUnit(fontSize);
1640       tar.width.baseVal._emToUnit(fontSize);
1641       tar.height.baseVal._emToUnit(fontSize);
1642       ts.position = "absolute";
1643       po.x = tar.x.baseVal.value;
1644       po.y = tar.y.baseVal.value;
1645       po = po.matrixTransform(ctm);
1646       ts.left = po.x + "px";
1647       ts.top = po.y + "px";
1648       ts.width = tar.width.baseVal.value * ctm.a + "px";
1649       ts.height = tar.height.baseVal.value * ctm.d + "px";
1650       if (fillOpacity !== 1) {
1651         ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
1652         ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
1653         ttfia.Style = 0;
1654         ttfia.Opacity = fillOpacity * 100;
1655         ttfia = void 0;
1656       }
1657       evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
1658     }, false);
1659     evt = tar = void 0;
1660   }, false);
1661   SVGURIReference.apply(this);
1662   return this;
1663 };
1664 SVGImageElement.constructor = SVGElement;
1665 SVGImageElement.prototype = new SVGElement();
1666
1667 function SVGSwitchElement() {
1668   SVGElement.apply(this, arguments);
1669   return this;
1670 };
1671 SVGSwitchElement.constructor = SVGElement;
1672 SVGSwitchElement.prototype = new SVGElement();
1673
1674 //bookmarkletから呼び出されたらtrue
1675 var sieb_s;
1676 function GetSVGDocument(ele) {
1677   this._tar = ele;
1678   this._next = null;
1679   return this;
1680 }
1681 function _ca_() {
1682   if ((NAIBU._that.xmlhttp.readyState === 4)  &&  (NAIBU._that.xmlhttp.status === 200)) {
1683     NAIBU._that._ca();
1684   }
1685 };
1686  GetSVGDocument.prototype = {
1687   /*_initメソッド
1688    *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
1689    */
1690   _init : function() {
1691     /*objeiはobject要素かembed要素*/
1692     var xmlhttp = NAIBU.xmlhttp,
1693         objei = this._tar,
1694         data;
1695     if (this._tar.nodeName === "OBJECT") {
1696       data = "data";
1697     } else {
1698       data = "src";
1699     }
1700     xmlhttp.open("GET", objei.getAttribute(data), true);
1701     objei.style.display = "none";
1702     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1703     this.xmlhttp = xmlhttp;
1704     /*クロージャを利用しないことで、軽量化を計る*/
1705     NAIBU._that = this;
1706     xmlhttp.onreadystatechange = _ca_;
1707     xmlhttp.send(null);
1708     xmlhttp = objei = data = void 0;
1709   },
1710   /*コール関数。全処理を担う*/
1711   _ca : function() {
1712     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
1713      *ここでは、responseTextを用いる
1714      */
1715     var dsd = new Date();
1716     var ifr = this._tar.previousSibling,
1717         ifcw = ifr.contentWindow,
1718         _doc;
1719     if (ifcw) {
1720       ifr.contentWindow.screen.updateInterval = 999;
1721       _doc = ifr.contentWindow.document;
1722       _doc.write("");
1723       _doc.close(); // これがないと document.body は null になる
1724     } else {        //インラインSVGの場合
1725       _doc = document;
1726     }
1727     if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
1728       _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
1729       _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
1730       var st = _doc.createStyleSheet(),
1731           vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
1732       st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
1733         + "dn\\:defs{display:none}"
1734         + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
1735         + "v\\:shape{width:100%;height:100%;" +vmlUrl;
1736       st = vmlUrl = void 0;
1737     }
1738     DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
1739     var str = this.xmlhttp.responseText,
1740         objei = this._tar,
1741         s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
1742         tar = s.documentElement,
1743         tview = tar.viewport,
1744         objw, objh, fi, n, attr, att, w, h,
1745         sdt = tar._tar,
1746         sp = _doc.createElement("div"),
1747         dcp = _doc.createElement("v:group"),
1748         backr = _doc.createElement("v:rect"),
1749         style, fontSize, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, backdown, backright,
1750         bfl, bft, bl, text,
1751         _parseFloat = parseFloat,
1752         ndoc = NAIBU.doc || this.xmlhttp.responseXML,
1753           oba = _doc.createElement("div"); //obaはradialGradient要素で使う
1754     if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
1755       this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1756       return;
1757     }
1758     s._iframe = ifr;                     //_iframeプロパティはSVGAElementでリンク置換のときに扱う
1759     oba.setAttribute("id","_NAIBU_outline");
1760     _doc.body.appendChild(oba);
1761     sp.style.margin = "-1px,0px,0px,-1px"
1762     if (ifcw) {
1763        _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
1764     }
1765     ndoc.async = false;
1766     /*下記のプロパティについては、Microsoftのサイトを参照
1767      *ResolveExternals Property [Second-level DOM]
1768      * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
1769      *ValidateOnParse Property [Second-level DOM]
1770      * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
1771      */
1772     ndoc.validateOnParse = false;
1773     ndoc.resolveExternals = false;
1774     ndoc.preserveWhiteSpace = true;
1775     ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
1776     /*IE6-8のみで使えるupdateIntervalは、
1777      *描画間隔の調整が可能。デフォルトは0。
1778      *スクロール時にバグが起きるので、0に戻してやる必要がある。
1779      */
1780     screen.updateInterval = 999;
1781     if (/&[^;]+;/.test(str)) {
1782       /*以下の処理は、実体参照を使ったとき
1783        *代替の処理を用いて、実体参照を処理するもの
1784        */
1785       var tmp = str;
1786       var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
1787       for (var i=0; i<enti.length; i++) {
1788       var map = enti.item(i);
1789       var regex = new RegExp("&"+map.nodeName+";", "g");
1790       tmp = tmp.replace(regex, map.firstChild.xml);
1791       }
1792       ndoc.loadXML(tmp);
1793       tmp = void 0;
1794     }
1795     tview.top = 0;
1796     tview.left = 0;
1797     tview.width = objei.clientWidth;
1798     tview.height = objei.clientHeight;
1799     if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
1800       tview.height = screen.availHeight;
1801     }
1802     if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
1803       tar.viewport.height = screen.width;
1804     }
1805     objw = objei.getAttribute("width");
1806     objh = objei.getAttribute("height");
1807     if (objw) {
1808       tar.setAttributeNS(null, "width", objw);
1809     }
1810     if (objh) {
1811       tar.setAttributeNS(null, "height", objh);
1812     }
1813     fi = ndoc.documentElement.firstChild;
1814     attr = ndoc.documentElement.attributes;
1815     /*ルート要素のNamedNodeMapを検索する*/
1816     for (var i=0,atli=attr.length;i<atli;++i) {
1817       att = s.importNode(attr[i], false);
1818       tar.setAttributeNodeNS(att);
1819     }
1820     str = attr = void 0;
1821     dcp.style.width = tview.width+ "px";
1822     dcp.style.height = tview.height+ "px";
1823     dcp.coordsize = tview.width+ " " +tview.height;
1824     sp.appendChild(dcp);
1825     if (ifcw) {
1826       _doc.body.appendChild(sp);
1827     } else {
1828       this._tar.parentNode.insertBefore(sp, this._tar);
1829     }
1830     dcp.appendChild(sdt);
1831     while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
1832       n = s.importNode(fi, true);
1833       tar.appendChild(n);
1834       fi = fi.nextSibling;
1835     }
1836     fi = void 0;
1837     /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
1838      *ドキュメントにそのオブジェクトを結び付けておく
1839      */
1840     s._window = ifcw;
1841     /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
1842      *作り出す作業を行う。これは必須
1843      */
1844     style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
1845     fontSize = _parseFloat(style.getPropertyValue("font-size"));
1846     tar.x.baseVal._emToUnit(fontSize);
1847     tar.y.baseVal._emToUnit(fontSize);
1848     tar.width.baseVal._emToUnit(fontSize);
1849     tar.height.baseVal._emToUnit(fontSize);
1850     sw = tar.width.baseVal.value;
1851     sh = tar.height.baseVal.value;
1852     backr.style.position = "absolute";
1853     w = tview.width;
1854     h = tview.height;
1855     backr.style.width = w+ "px";
1856     backr.style.height = h+ "px";
1857     backr.style.zIndex = -1;
1858     backr.stroked = "false";
1859     backr.filled = "false";
1860     tar._tar.appendChild(backr);
1861     trstyle = tar._tar.style;
1862     tpstyle = objei.style;
1863     trstyle.visibility = "visible";
1864     trstyle.position = "absolute";
1865     /*以下、画像を切り取り*/
1866     trstyle.overflow = "hidden";
1867     /*ウィンドウ枠の長さを決定する*/
1868     viewWidth = w > sw ? sw : w;
1869     viewHeight = h > sh ? sh : h;
1870     backrs = backr.currentStyle;
1871     bfl = _parseFloat(backrs.left);
1872     bft = _parseFloat(backrs.top);
1873     bl = -tar._tx;                  //blやbtは、ずれを調整するのに使う
1874     bt = -tar._ty;
1875     if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
1876       bl = bfl;
1877       dcp.style.left = -bl+ "px";
1878     }
1879     if (bft !== 0 && !isNaN(bfl)) {
1880       bt = bft;
1881       dcp.style.top = -bt+ "px";
1882     }
1883     backright = bl + viewWidth + 1;
1884     backdown = bt + viewHeight + 1;
1885     trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
1886     this._document = s;
1887     if ("_svgload_limited" in s.documentElement) {
1888       /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
1889        *xlink:href属性が指定されるたびに+1となる。
1890        *0以外は、SVGLoadイベントが発火されない仕組みとなっている
1891        *
1892        *目的:
1893        * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
1894        */
1895       s.documentElement._svgload_limited--;
1896       if (s.documentElement._svgload_limited < 0) {
1897         var evt = s.createEvent("SVGEvents");
1898         evt.initEvent("SVGLoad", false, false);
1899         s.documentElement.dispatchEvent(evt);
1900       }
1901     }
1902     //以下、テキストの位置を修正
1903     text = s.documentElement._tar.getElementsByTagName("div");
1904     for (var i=0, texti;text[i];++i) {
1905       texti = text[i];
1906       if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
1907         var tis = texti.style;
1908         tis.left = _parseFloat(tis.left) + bl + "px";
1909         tis.top = _parseFloat(tis.top) + bt + "px";
1910         tis = void 0;
1911       }
1912     }
1913     //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
1914     ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
1915     s._isLoaded = 1;  //_isLoadedプロパティはevents::dispatchEventメソッドで使う
1916     s.defaultView._cache = s.defaultView._cache_ele = null;
1917     oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
1918     trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
1919     /*IEのメモリリーク対策として、空関数を入力*/
1920     this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1921     alert(+(new Date()) - dsd);
1922     if (this._next) {
1923       ifcw && (ifr.contentWindow.screen.updateInterval = 0);
1924       ifr = ifcw = s = void 0;
1925       this._next._init();
1926     } else {
1927       /*全要素の読み込みが終了した場合*/
1928       if (s.implementation._buffer_) {
1929         screen.updateInterval = 0;
1930         /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
1931         NAIBU._buff_num = 0;
1932         NAIBU._buff = setInterval(function(){
1933           var n = NAIBU._buff_num,
1934               dbuf = DOMImplementation._buffer_,
1935               dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
1936               s, evt;
1937           if (dbufli === 0) {
1938             clearInterval(NAIBU._buff);              
1939           } else {
1940             for (var i=0;i<50;++i) {
1941               s = dbuf[n];
1942               evt = dbuf[n+1];
1943               s.dispatchEvent(evt);
1944               n += 2;
1945               s = evt = void 0;
1946               if (n >= dbufli) {
1947                 clearInterval(NAIBU._buff);
1948                 DOMImplementation._buffer_ = null;
1949                 NAIBU.Time.start();
1950                 dbuf = n = dbufli = void 0;
1951                 return;
1952               }
1953             }
1954             NAIBU._buff_num = n;
1955           }
1956           dbuf = n = dbufli = void 0;
1957         }, 1);
1958         ifr = ifcw = s = void 0;
1959       } else {
1960         ifr = ifcw = s = void 0;
1961         NAIBU.Time.start();
1962       }
1963       delete NAIBU.doc;
1964     }
1965   },
1966   /*SVGDocument*/  getSVGDocument : function() {
1967     return (this._document);
1968   }
1969 };
1970 /*空関数(IEのメモリリーク対策)*/
1971 NAIBU.emptyFunction = function() {};
1972
1973 /*SVGStyleElement
1974  *style要素をあらわすオブジェクト
1975  */
1976 function SVGStyleElement(_doc) {
1977   SVGElement.apply(this);
1978   LinkStyle.apply(this);
1979   /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
1980    *CSS2 1. Document Object Model Style Sheets
1981    * 1.3. Document Extensions
1982    *   Interface LinkStyle (introduced in DOM Level 2)
1983    * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
1984    */
1985   /*以下はそれぞれ、属性の値に対応している*/
1986   /*DOMString*/ this.xmlspace;
1987   /*DOMString*/ this.type = "text/css";
1988   /*DOMString*/ this.media;
1989   /*DOMString*/ this.title;
1990   SVGURIReference.apply(this);
1991   this.addEventListener("DOMAttrModified", function(evt){
1992     if (evt.attrName === "type") {
1993       evt.target.type = evt.newValue;
1994     } else if (evt.attrName === "title") {
1995       evt.target.title = evt.newValue;
1996     }
1997     evt = void 0;
1998   }, false);
1999   this.addEventListener("S_Load", function(evt){
2000     var tar = evt.target,
2001         sheet = tar.sheet,
2002         styleText = tar._text,
2003         tod = tar.ownerDocument,
2004         style = _doc.createElement("style"),
2005         ri, rsc, scri, rsi;
2006     NAIBU._temp_doc = tod;
2007     sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
2008     sheet.ownerNode = tar;
2009     /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
2010     _doc.documentElement.firstChild.appendChild(style);
2011     style.styleSheet.cssText = styleText;
2012     for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
2013       ri = rules[i];
2014       scri = new CSSStyleRule();
2015       scri.selectorText = ri.selectorText;
2016       scri.style.cssText = ri.style.cssText;
2017       rsc = scri.style.cssText.split(";");
2018       for (var j=0, rsli=rsc.length;j<rsli;++j) {
2019         rsi = rsc[j].split(": ");
2020         scri.style.setProperty(rsi[0], rsi[1]);
2021       }
2022       sheet.cssRules[sheet.cssRules.length] = scri;
2023     }
2024     tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
2025       var tar = evt.target,
2026           doc = tar.ownerDocument,
2027           rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
2028           selector, ru, tcb = tar.className.baseVal || ".,.";
2029       for (var i=0, rli=rules.length;i<rli;++i) {
2030         selector = rules[i].selectorText;
2031         /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
2032         ru = tar._rules || [];
2033         if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
2034             || (tar.nodeName === selector)) {
2035           ru[ru.length] = rules[i];
2036         }
2037         tar._rules = ru;
2038       }
2039       tar = doc = rules = void 0;
2040     }, true);
2041     tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
2042   }, false);
2043   this.addEventListener("DOMNodeInserted", function(evt){
2044     var tar = evt.target;
2045     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2046       if (tar.nodeName === "#cdata-section") {
2047         evt.currentTarget._text = tar.data;
2048       }
2049       return;
2050     }
2051     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
2052       var tar = evt.target;
2053       if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
2054         var evtt = tar.ownerDocument.createEvent("SVGEvents");
2055         evtt.initEvent("S_Load", false, false);
2056         evt.currentTarget.dispatchEvent(evtt);
2057       }
2058       tar = evt = void 0;
2059     }, false);
2060   }, false);
2061   return this;
2062 };
2063 SVGStyleElement.constructor = SVGElement;
2064 SVGStyleElement.prototype = new SVGElement();
2065
2066 /*SVGPoint
2067  *2次元座標の点(x,y)を表すオブジェクト
2068  */
2069 function SVGPoint() { 
2070   return this;
2071 };
2072 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
2073 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
2074   /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
2075   var s = new SVGPoint();
2076   s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
2077   s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
2078   return s;
2079 };
2080
2081 function SVGPointList() { 
2082   return this;
2083 };
2084 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2085   SVGPointList.prototype[prop] = SVGStringList.prototype[prop];
2086 }
2087
2088 /*SVGMatrix
2089  *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
2090  *[a c e]
2091  *[b d f]
2092  *[0 0 1]
2093  */
2094 function SVGMatrix() { 
2095   return this;
2096 };
2097 SVGMatrix.prototype = {
2098   /*float*/ a : 1,
2099   /*float*/ b : 0,
2100   /*float*/ c : 0,
2101   /*float*/ d : 1,
2102   /*float*/ e : 0,
2103   /*float*/ f : 0,
2104   /*multiplyメソッド
2105    *行列の積を求めて返す
2106    */
2107   /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
2108     var s = new SVGMatrix(), m = secondMatrix;
2109     if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
2110       throw (new Error("引数の値がNumber型ではありません"));
2111     }
2112     s.a = this.a * m.a + this.c * m.b;
2113     s.b = this.b * m.a + this.d * m.b;
2114     s.c = this.a * m.c + this.c * m.d;
2115     s.d = this.b * m.c + this.d * m.d;
2116     s.e = this.a * m.e + this.c * m.f + this.e;
2117     s.f = this.b * m.e + this.d * m.f + this.f;
2118     m = secondMatrix = void 0;
2119     return s;
2120   },
2121   /*inverseメソッド
2122    *逆行列を返す
2123    */
2124   /*SVGMatrix*/ inverse : function() {
2125     var s = new SVGMatrix(), n = this._determinant();
2126     if (n !== 0) {
2127       s.a = this.d / n;
2128       s.b = -this.b / n;
2129       s.c = -this.c / n;
2130       s.d = this.a / n;
2131       s.e = (this.c * this.f - this.d * this.e) / n;
2132       s.f = (this.b * this.e - this.a * this.f) / n;
2133       return s;
2134     } else {
2135       throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
2136     }
2137   },
2138   /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
2139     var m = new SVGMatrix();
2140     m.e = x;
2141     m.f = y;
2142     var s =  this.multiply(m);
2143     m = void 0;
2144     return s;
2145   },
2146   /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
2147     var m = new SVGMatrix();
2148     m.a = scaleFactor;
2149     m.d = scaleFactor;
2150     var s =  this.multiply(m);
2151     m = void 0;
2152     return s;
2153   },
2154   /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
2155     var m = new SVGMatrix();
2156     m.a = scaleFactorX;
2157     m.d = scaleFactorY;
2158     var s =  this.multiply(m);
2159     m = void 0;
2160     return s;
2161   },
2162   /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
2163     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
2164     m.a = Math.cos(rad);
2165     m.b = Math.sin(rad);
2166     m.c = -m.b;
2167     m.d = m.a;
2168     var s =  this.multiply(m);
2169     m = rad = void 0;
2170     return s;
2171   },
2172   //座標(x, y)と原点の角度の分だけ、回転する
2173   /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
2174     if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
2175       throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
2176     }
2177     var m = new SVGMatrix(), rad = Math.atan2(y, x);
2178     m.a = Math.cos(rad);
2179     m.b = Math.sin(rad);
2180     m.c = -m.b;
2181     m.d = m.a;
2182     var s =  this.multiply(m);
2183     m = rad = void 0;
2184     return s;
2185   },
2186   /*SVGMatrix*/ flipX : function() {
2187     var m = new SVGMatrix();
2188     m.a = -m.a;
2189     var s =  this.multiply(m);
2190     m = void 0;
2191     return s;
2192   },
2193   /*SVGMatrix*/ flipY : function() {
2194     var m = new SVGMatrix();
2195     m.d = -m.d;
2196     var s =  this.multiply(m);
2197     m = void 0;
2198     return s;
2199   },
2200   /*SVGMatrix*/ skewX : function(/*float*/ angle ){
2201     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
2202     m.c = Math.tan(rad);
2203     var s =  this.multiply(m);
2204     m = void 0;
2205     return s;
2206   },
2207   /*SVGMatrix*/ skewY : function(/*float*/ angle ){
2208     var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
2209     m.b = Math.tan(rad);
2210     var s =  this.multiply(m);
2211     m = void 0;
2212     return s;
2213   },
2214   //行列式
2215   /*float*/ _determinant : function() {
2216     return (this.a * this.d - this.b * this.c);
2217   }
2218 };
2219
2220 function SVGTransform() { 
2221   /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
2222   return this;
2223 };
2224     // Transform Types
2225   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN   = 0;
2226   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX    = 1;
2227   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
2228   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE     = 3;
2229   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE    = 4;
2230   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX     = 5;
2231   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY     = 6;
2232 SVGTransform.prototype = {
2233   /*ダミーの単位行列。各メソッドで使う*/
2234   _matrix : (new SVGMatrix()),
2235   /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
2236   /*readonly float*/ angle : 0,
2237   /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
2238     this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
2239     this.matrix = this._matrix.multiply(matrix);
2240   },
2241   /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
2242     this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
2243     this.matrix = this._matrix.translate(tx, ty);
2244   },
2245   /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
2246     this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
2247     this.matrix = this._matrix.scaleNonUniform(sx, sy);
2248   },
2249   /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
2250     this.angle = angle;
2251     this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
2252     this.matrix = this._matrix.rotate(angle);
2253     this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
2254     this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
2255   },
2256   /*void*/ setSkewX : function(/*float*/ angle ) {
2257     this.angle = angle;
2258     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
2259     this.matrix = this._matrix.skewX(angle);
2260   },
2261   /*void*/ setSkewY : function(/*float*/ angle ) {
2262     this.angle = angle;
2263     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
2264     this.matrix = this._matrix.skewY(angle);
2265   }
2266 };
2267
2268 function SVGTransformList() { 
2269   return this;
2270 };
2271 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2272   SVGTransformList.prototype[prop] = SVGStringList.prototype[prop];
2273 }
2274 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
2275   var t = new SVGTransform();
2276   t.setMatrix(matrix);
2277   return t;
2278 }
2279 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
2280   if(this.numberOfItems === 0) {
2281     return null;
2282   } else {
2283     var s = this.getItem(0), m = s.matrix;
2284     for (var i=1,nli=this.numberOfItems;i<nli;++i) {
2285       m = m.multiply(this.getItem(i).matrix);
2286     }
2287     s.setMatrix(m);
2288     this.initialize(s);
2289     return s;
2290   }
2291 }
2292
2293 function SVGAnimatedTransformList() { 
2294   /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
2295   return this;
2296 };
2297 function SVGPreserveAspectRatio() { 
2298   /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
2299   /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
2300   return this;
2301 };
2302 (function(t) {
2303     // Alignment Types
2304   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN  = 0;
2305   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE     = 1;
2306   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
2307   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
2308   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
2309   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
2310   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
2311   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
2312   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
2313   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
2314   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
2315     // Meet-or-slice Types
2316   /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN   = 0;
2317   /*unsigned short*/ t.SVG_MEETORSLICE_MEET  = 1;
2318   /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
2319 })(SVGPreserveAspectRatio);
2320
2321 function SVGAnimatedPreserveAspectRatio() { 
2322   /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
2323   return this;
2324 };
2325
2326 function SVGPathSeg() { 
2327   /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
2328   /*readonly DOMString*/      this.pathSegTypeAsLetter = null;
2329   return this;
2330 };
2331
2332 (function(t) {
2333     // Path Segment Types
2334   /*unsigned short*/ t.PATHSEG_UNKNOWN                      = 0;
2335   /*unsigned short*/ t.PATHSEG_CLOSEPATH                    = 1;
2336   /*unsigned short*/ t.PATHSEG_MOVETO_ABS                   = 2;
2337   /*unsigned short*/ t.PATHSEG_MOVETO_REL                   = 3;
2338   /*unsigned short*/ t.PATHSEG_LINETO_ABS                   = 4;
2339   /*unsigned short*/ t.PATHSEG_LINETO_REL                   = 5;
2340   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS            = 6;
2341   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL            = 7;
2342   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS        = 8;
2343   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL        = 9;
2344   /*unsigned short*/ t.PATHSEG_ARC_ABS                      = 10;
2345   /*unsigned short*/ t.PATHSEG_ARC_REL                      = 11;
2346   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS        = 12;
2347   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL        = 13;
2348   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS          = 14;
2349   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL          = 15;
2350   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS     = 16;
2351   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL     = 17;
2352   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
2353   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
2354 })(SVGPathSeg);
2355 /*SVGPathSegxx
2356  *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
2357  */
2358 function SVGPathSegClosePath() {
2359   return this;
2360 };
2361 SVGPathSegClosePath.prototype = {
2362   pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
2363   pathSegTypeAsLetter : "z"
2364 };
2365 function SVGPathSegMovetoAbs() { 
2366   /*float* this.x;
2367   /*float* this.y;*/
2368   return this;
2369 };
2370 SVGPathSegMovetoAbs.prototype = {
2371   pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
2372   pathSegTypeAsLetter : "M"
2373 };
2374 function SVGPathSegMovetoRel() { 
2375   /*float*/ this.x;
2376   /*float*/ this.y;
2377   return this;
2378 };
2379 SVGPathSegMovetoRel.prototype = {
2380   pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
2381   pathSegTypeAsLetter : "m"
2382 };
2383 function SVGPathSegLinetoAbs() { 
2384   /*float* this.x;
2385   /*float* this.y;*/
2386   return this;
2387 };
2388 SVGPathSegLinetoAbs.prototype = {
2389   pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
2390   pathSegTypeAsLetter : "L"
2391 };
2392 function SVGPathSegLinetoRel() { 
2393   /*float*/ this.x;
2394   /*float*/ this.y;
2395   return this;
2396 };
2397 SVGPathSegLinetoRel.prototype = {
2398   pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
2399   pathSegTypeAsLetter : "l"
2400 };
2401 function SVGPathSegCurvetoCubicAbs() { 
2402   /*float* this.x;
2403   /*float* this.y;
2404   /*float* this.x1;
2405   /*float* this.y1;
2406   /*float* this.x2;
2407   /*float* this.y2;*/
2408   return this;
2409 };
2410 SVGPathSegCurvetoCubicAbs.prototype = {
2411   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
2412   pathSegTypeAsLetter : "C"
2413 };
2414 function SVGPathSegCurvetoCubicRel() { 
2415   /*float* this.x;
2416   /*float* this.y;
2417   /*float* this.x1;
2418   /*float* this.y1;
2419   /*float* this.x2;
2420   /*float* this.y2;*/
2421   return this;
2422 };
2423 SVGPathSegCurvetoCubicRel.prototype = {
2424   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
2425   pathSegTypeAsLetter : "c"
2426 };
2427 function SVGPathSegCurvetoQuadraticAbs() { 
2428   /*float*/ this.x;
2429   /*float*/ this.y;
2430   /*float*/ this.x1;
2431   /*float*/ this.y1;
2432   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
2433   this.pathSegTypeAsLetter = "Q";
2434   return this;
2435 };
2436 function SVGPathSegCurvetoQuadraticRel() { 
2437   /*float*/ this.x;
2438   /*float*/ this.y;
2439   /*float*/ this.x1;
2440   /*float*/ this.y1;
2441   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
2442   this.pathSegTypeAsLetter = "q";
2443   return this;
2444 };
2445
2446 function SVGPathSegArcAbs() { 
2447   /*float*/ this.x;
2448   /*float*/ this.y;
2449   /*float*/ this.r1;
2450   /*float*/ this.r2;
2451   /*float*/ this.angle;
2452   return this;
2453 };
2454 SVGPathSegArcAbs.prototype = {
2455   /*boolean*/ largeArcFlag : true,
2456   /*boolean*/ sweepFlag : true,
2457   pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
2458   pathSegTypeAsLetter : "A"
2459 };
2460 function SVGPathSegArcRel() { 
2461   /*float*/ this.x;
2462   /*float*/ this.y;
2463   /*float*/ this.r1;
2464   /*float*/ this.r2;
2465   /*float*/ this.angle;
2466   return this;
2467 };
2468 SVGPathSegArcRel.prototype = {
2469   /*boolean*/ largeArcFlag : true,
2470   /*boolean*/ sweepFlag : true,
2471   pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
2472   pathSegTypeAsLetter : "a"
2473 };
2474 function SVGPathSegLinetoHorizontalAbs() { 
2475   /*float*/ this.x;
2476   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
2477   this.pathSegTypeAsLetter = "H";
2478   return this;
2479 };
2480 function SVGPathSegLinetoHorizontalRel() { 
2481   /*float*/ this.x;
2482   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
2483   this.pathSegTypeAsLetter = "h";
2484   return this;
2485 };
2486 function SVGPathSegLinetoVerticalAbs() { 
2487   /*float*/ this.y;
2488   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
2489   this.pathSegTypeAsLetter = "V";
2490   return this;
2491 };
2492 function SVGPathSegLinetoVerticalRel() { 
2493   /*float*/ this.y;
2494   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
2495   this.pathSegTypeAsLetter = "v";
2496   return this;
2497 };
2498 function SVGPathSegCurvetoCubicSmoothAbs() { 
2499   /*float*/ this.x;
2500   /*float*/ this.y;
2501   /*float*/ this.x2;
2502   /*float*/ this.y2;
2503   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
2504   this.pathSegTypeAsLetter = "S";
2505   return this;
2506 };
2507 function SVGPathSegCurvetoCubicSmoothRel() {
2508   /*float*/ this.x;
2509   /*float*/ this.y;
2510   /*float*/ this.x2;
2511   /*float*/ this.y2;
2512   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
2513   this.pathSegTypeAsLetter = "s";
2514   return this;
2515 };
2516 function SVGPathSegCurvetoQuadraticSmoothAbs() {
2517   /*float*/ this.x;
2518   /*float*/ this.y;
2519   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
2520   this.pathSegTypeAsLetter = "T";
2521   return this;
2522 };
2523 function SVGPathSegCurvetoQuadraticSmoothRel() {
2524   /*float*/ this.x;
2525   /*float*/ this.y;
2526   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
2527   this.pathSegTypeAsLetter = "t";
2528   return this;
2529 };
2530 function SVGPathSegList() {
2531   return this;
2532 };
2533 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2534   SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
2535 };
2536
2537 /*documentは引数の変数として登録しておく*/
2538 (function(_doc, _math) {
2539 //freeArg関数はunloadで使う解放処理
2540 NAIBU.freeArg = function() {
2541   SVGPathElement = _doc = _math = void 0;
2542 };
2543 //仮のfill属性とstroke属性の処理
2544 NAIBU._setPaint = function(tar, matrix) {
2545   /*以下では、スタイルシートを用いて、fill-とstroke-関連の
2546    *処理を行う。SVGPaintインターフェースをも用いる
2547    */
2548   var tod = tar.ownerDocument,
2549       _doc = tod._document_,
2550       el = tar._tar,
2551       style = tod.defaultView.getComputedStyle(tar, ""),
2552       fill = style.getPropertyCSSValue("fill"),
2553       stroke = style.getPropertyCSSValue("stroke"),
2554       fp = fill.paintType,
2555       sp = stroke.paintType,
2556       fillElement, fc,
2557       num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
2558       t, evtt, fillOpacity, strs, cursor, vis, disp,
2559       strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
2560   if (!el) {
2561     return;
2562   }
2563   /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
2564   while (el.firstChild) {
2565     el.removeChild(el.firstChild);
2566   }
2567   if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
2568     if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
2569       /*再度、設定。css.jsのsetPropertyを参照*/
2570       style.setProperty("color", style.getPropertyValue("color"));
2571     }
2572     fillElement = _doc.createElement("v:fill");
2573     fc = fill.rgbColor;
2574     num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2575     fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
2576     fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
2577     if (fillOpacity < 1) {
2578       fillElement.setAttribute("opacity", fillOpacity+"");
2579     }
2580     el.appendChild(fillElement);
2581     fillElement = fc = fillOpacity = void 0;
2582   } else if (fill.uri) {
2583     /*以下では、Gradation関連の要素に、イベントを渡すことで、
2584      *この要素の、グラデーション描画を行う
2585      */
2586     t = tod.getElementById(fill.uri);
2587     if (t) {
2588       evtt = tod.createEvent("MutationEvents");
2589       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
2590       evtt._tar = _doc.createElement("v:fill");
2591       evtt._style = style;
2592       evtt._ttar = tar;
2593       t.dispatchEvent(evtt);
2594       if (t.localName !== "radialGradient") {
2595         el.appendChild(evtt._tar);
2596       }
2597       t = evtt = void 0;
2598     }
2599   } else {
2600     el.filled = "false";
2601   }
2602   if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
2603     if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
2604       /*再度、設定。css.jsのsetPropertyを参照*/
2605       style.setProperty("color", style.getPropertyValue("color"));
2606     }
2607     strokeElement = _doc.createElement("v:stroke");
2608     sgsw = style.getPropertyCSSValue("stroke-width");
2609     w = tod.documentElement.viewport.width;
2610     h = tod.documentElement.viewport.height;
2611     sgsw._percent = _math.sqrt((w*w + h*h) / 2);
2612     swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
2613     strokeElement.setAttribute("weight", swx + "px");
2614     sgsw = w = h = void 0;
2615     if (!stroke.uri) {
2616       fc = stroke.rgbColor;
2617       strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
2618       strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
2619       if (swx < 1) {
2620         strokeOpacity *= swx; //太さが1px未満なら色を薄くする
2621       }
2622       if (strokeOpacity < 1) {
2623         strokeElement.setAttribute("opacity", strokeOpacity+"");
2624       }
2625       fc = strokeOpacity = void 0;
2626     }
2627     strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
2628     strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
2629     if (style.getPropertyValue("stroke-linecap") === "butt") {
2630       strokeElement.setAttribute("endcap", "flat");
2631     } else {
2632       strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
2633     }
2634     tsd = style.getPropertyValue("stroke-dasharray");
2635     if (tsd !== "none") {
2636       if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
2637         strs = tsd.split(",");
2638         for (var i = 0, sli = strs.length; i < sli; ++i) {
2639           strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
2640         }
2641         strokedasharray = strs.join(" ");
2642         if (strs.length % 2 === 1) {
2643           strokedasharray += " " + strokedasharray;
2644         }
2645       }
2646       strokeElement.setAttribute("dashstyle", strokedasharray);
2647       tsd = strs = void 0;
2648     }
2649     el.appendChild(strokeElement);
2650     strokeElement = tsd = void 0;
2651   } else {
2652     el.stroked = "false";
2653   }
2654   cursor = style.getPropertyCSSValue("cursor");
2655   if (cursor && !cursor._isDefault) { //初期値でないならば
2656     el.style.cursor = cursor.cssText.split(":")[1];
2657   }
2658   vis = style.getPropertyCSSValue("visibility");
2659   if (vis && !vis._isDefault) {
2660     el.style.visibility = vis.cssText.split(":")[1];
2661   }
2662   disp = style.getPropertyCSSValue("display");
2663   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
2664     el.style.display = "none";
2665    } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
2666     el.style.display = "inline-block";
2667   }
2668   tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
2669 };
2670
2671 function SVGPathElement(_doc) {
2672   SVGElement.apply(this);
2673   this._tar = _doc.createElement("v:shape");
2674   //interface SVGAnimatedPathData
2675   var sp = SVGPathSegList;
2676   /*readonly SVGPathSegList*/ this.pathSegList = new sp();
2677   this.animatedPathSegList = this.pathSegList;
2678   /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
2679   sp = _doc = void 0;
2680   this.animatedNormalizedPathSegList = this.normalizedPathSegList;
2681   /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
2682   //以下は、d属性に変更があった場合の処理
2683   this.addEventListener("DOMAttrModified", this._attrModi, false);
2684   /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
2685    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
2686    */
2687   this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
2688   return this;
2689 };
2690 SVGPathElement.constructor = SVGElement;
2691 SVGPathElement.prototype = new SVGElement();
2692 (function(_sproto) {
2693 _sproto._attrModi = function(evt){
2694   var tar = evt.target;
2695   if (evt.attrName === "d" && evt.newValue !== ""){
2696     /* d属性の値が空の場合は、描画を行わないようにする
2697      * 
2698      *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
2699      */
2700     var tnl = tar.normalizedPathSegList,
2701         tlist = tar.pathSegList;
2702     if (tnl.numberOfItems > 0) {
2703       tnl.clear();
2704       tlist.clear();
2705     }
2706     /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
2707      *JSONにおける表現は以下のとおり
2708      *D = [["M", 20, 30], ["L", 20 40]]
2709      */
2710     var taco = tar._com,
2711         sgs = taco.isSp,
2712         dd = evt.newValue
2713     .replace(taco.isRa, " -")
2714     .replace(taco.isRb, " ")
2715     .replace(taco.isRc, ",$1 ")
2716     .replace(taco.isRd, ",$1 1")
2717     .replace(taco.isRe, "")
2718     .split(","),
2719         dli=dd.length,
2720         isZ = taco._isZ,
2721         isM = taco._isM,
2722         isC = taco._isC,
2723         isL = taco._isL,
2724         tcc = tar.createSVGPathSegCurvetoCubicAbs,
2725         tcll = tar.createSVGPathSegLinetoAbs;
2726     for (var i=0;i<dli;++i) {
2727       var di = dd[i].match(sgs),
2728           s;
2729       for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
2730         if (isC[dii]) {
2731           s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
2732           j += 5;
2733         } else if (isL[dii]) {
2734           s = tcll(+di[j], +di[j+1]);
2735           ++j;
2736         } else if (isM[dii]) {
2737           s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
2738           ++j;
2739         } else if (isZ[dii]) {
2740           s = tar.createSVGPathSegClosePath();
2741         } else if (dii === "A") {
2742           s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
2743           j += 6;
2744         } else if (dii === "m") {
2745           s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
2746           ++j;
2747         } else if (dii === "l") {
2748           s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
2749           ++j;
2750         } else if (dii === "c") {
2751           s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
2752           j += 5;
2753         } else if (dii === "Q") {
2754           s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2755           j += 3;
2756         } else if (dii === "q") {
2757           s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2758           j += 3;
2759         } else if (dii === "a") {
2760           s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
2761           j += 6;
2762         } else if (dii === "S") {
2763           s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2764           j += 3;
2765         } else if (dii === "s") {
2766           s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2767           j += 3;
2768         } else if (dii === "T") {
2769           s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
2770           ++j;
2771         } else if (dii === "t") {
2772           s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
2773           ++j;
2774         } else if (dii === "H") {
2775           s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
2776         } else if (dii === "h") {
2777           s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
2778         } else if (dii === "V") {
2779           s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
2780         } else if (dii === "v") {
2781           s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
2782         } else {
2783           s = new SVGPathSeg();
2784         }
2785         tlist.appendItem(s);
2786       }
2787     }
2788     di = s = sgs = dd = void 0;
2789     /*以下の処理は、pathSegListからnormalizedPathSegListへの
2790      *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
2791      */
2792     var cx = 0, cy = 0,         //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
2793         xn = 0, yn = 0,         //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
2794         startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
2795     for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
2796       var ti = tlist.getItem(j),
2797           ts = ti.pathSegType,
2798           dii = ti.pathSegTypeAsLetter;
2799       if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
2800       } else {
2801         var rx = cx, ry = cy;   //rx, ryは前のセグメントの終了点
2802         if (ts % 2 === 1) {     //相対座標ならば
2803           cx += ti.x;
2804           cy += ti.y;
2805         } else {
2806           cx = ti.x;
2807           cy = ti.y;
2808         }
2809         if (isC[dii]) {
2810           tnl.appendItem(ti);
2811         } else if (isL[dii]) {
2812           tnl.appendItem(ti);
2813         } else if (isM[dii]) {
2814           if (j !== 0) {
2815             /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
2816              *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
2817              *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
2818              */
2819             var tg = tlist.getItem(j-1);
2820             if (tg.pathSegTypeAsLetter === "M") {
2821               tnl.appendItem(tcll(cx, cy));
2822               continue;
2823             }
2824           }
2825           startx = cx;
2826           starty = cy;
2827           tnl.appendItem(ti);
2828         } else if (dii === "m") {
2829           if (j !== 0) {
2830             var tg = tlist.getItem(j-1);
2831             if (tg.pathSegTypeAsLetter === "m") {
2832               tnl.appendItem(tcll(cx, cy));
2833               continue;
2834             }
2835           }
2836           startx = cx;
2837           starty = cy;
2838           tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
2839         } else if (dii === "l") {
2840           tnl.appendItem(tcll(cx, cy));
2841         } else if (dii === "c") {
2842           tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
2843         } else if (isZ[dii]) {
2844           cx = startx;
2845           cy = starty;
2846           tnl.appendItem(ti);
2847         } else if (dii === "Q") {
2848           xn = 2*cx - ti.x1;
2849           yn = 2*cy - ti.y1;
2850           //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
2851           tnl.appendItem(tcc(cx, cy, (rx + 2*ti.x1) / 3, (ry + 2*ti.y1) / 3, (2*ti.x1 + cx) / 3, (2*ti.y1 + cy) / 3));
2852         } else if (dii === "q") {
2853           var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
2854           xn = 2*cx - x1;
2855           yn = 2*cy - y1;
2856           tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
2857           x1 = y1 = void 0;
2858         } else if (dii === "A" || dii === "a") {
2859           (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
2860             /*以下は、Arctoを複数のCuvetoに変換する処理
2861              *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
2862              *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
2863              */
2864             if (ti.r1 === 0 || ti.r2 === 0) {
2865               return;
2866             }
2867             var fS = ti.sweepFlag,
2868                 psai = ti.angle,
2869                 r1 = _math.abs(ti.r1),
2870                 r2 = _math.abs(ti.r2),
2871                 ctx = (rx - cx) / 2,  cty = (ry - cy) / 2,
2872                 cpsi = _math.cos(psai * _math.PI / 180),
2873                 spsi = _math.sin(psai * _math.PI / 180),
2874                 rxd = cpsi*ctx + spsi*cty,
2875                 ryd = -1*spsi*ctx + cpsi*cty,
2876                 rxdd = rxd * rxd, rydd = ryd * ryd,
2877                 r1x = r1 * r1,
2878                 r2y = r2 * r2,
2879                 lamda = rxdd/r1x + rydd/r2y,
2880                 sds;
2881             if (lamda > 1) {
2882               r1 = _math.sqrt(lamda) * r1;
2883               r2 = _math.sqrt(lamda) * r2;
2884               sds = 0;
2885             }  else{
2886               var seif = 1;
2887               if (ti.largeArcFlag === fS) {
2888                 seif = -1;
2889               }
2890               sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
2891             }
2892             var txd = sds*r1*ryd / r2,
2893                 tyd = -1 * sds*r2*rxd / r1,
2894                 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
2895                 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
2896                 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
2897                 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
2898                 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
2899                 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
2900             if (!fS  &&  dr > 0) {
2901               dr -=   2*_math.PI;
2902             } else if (fS  &&  dr < 0) {
2903               dr += 2*_math.PI;
2904             }
2905             var sse = dr * 2 / _math.PI,
2906                 seg = _math.ceil(sse<0 ? -1*sse  :  sse),
2907                 segr = dr / seg,
2908                 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
2909                 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
2910                 spsir1 = spsi * r1, spsir2 = spsi * r2,
2911                 mc = _math.cos(s1),
2912                 ms = _math.sin(s1),
2913                 x2 = rx - t * (cpsir1*ms + spsir2*mc),
2914                 y2 = ry - t * (spsir1*ms - cpsir2*mc);
2915             for (var n = 0; n < seg; ++n) {
2916               s1 += segr;
2917               mc = _math.cos(s1);
2918               ms = _math.sin(s1);
2919               var x3 = cpsir1*mc - spsir2*ms + tx,
2920                   y3 = spsir1*mc + cpsir2*ms + ty,
2921                   dx = -t * (cpsir1*ms + spsir2*mc),
2922                   dy = -t * (spsir1*ms - cpsir2*mc);
2923               tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
2924               x2 = x3 + dx;
2925               y2 = y3 + dy;
2926             }
2927             ti= cx= cy= rx= ry= tar= tnl = void 0;
2928           })(ti, cx, cy, rx, ry, tar, tnl);
2929         } else if (dii === "S") {
2930           if (j !== 0) {
2931             var tg = tnl.getItem(tnl.numberOfItems-1);
2932             if (tg.pathSegTypeAsLetter === "C") {
2933               var x1 = 2*tg.x - tg.x2,
2934                   y1 = 2*tg.y - tg.y2;
2935             } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
2936               var x1 = rx,
2937                   y1 = ry;
2938             }
2939           } else {
2940             var x1 = rx,
2941                 y1 = ry;
2942           }
2943           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
2944           x1 = y1 = void 0;
2945         } else if (dii === "s") {
2946           if (j !== 0) {
2947             var tg = tnl.getItem(tnl.numberOfItems-1);
2948             if (tg.pathSegTypeAsLetter === "C") {
2949               var x1 = 2*tg.x - tg.x2,
2950                   y1 = 2*tg.y - tg.y2;
2951             } else {
2952               var x1 = rx,
2953                   y1 = ry;
2954             }
2955           } else {
2956             var x1 = rx,
2957                 y1 = ry;
2958           }
2959           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
2960           x1 = y1 = void 0;
2961         } else if (dii === "T" || dii === "t") {
2962           if (j !== 0) {
2963             var tg = tlist.getItem(j-1);
2964             if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
2965              } else {
2966               xn = rx, yn = ry;
2967             }
2968           } else {
2969             xn = rx, yn = ry;
2970           }
2971           tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
2972           xn = 2*cx - xn;
2973           yn = 2*cy - yn;
2974           xx1 = yy1 = void 0;
2975         } else if (dii === "H" || dii === "h") {
2976           tnl.appendItem(tcll(cx, ry));
2977           cy = ry; //勝手にti.yが0としているため
2978         } else if (dii === "V" || dii === "v") {
2979           tnl.appendItem(tcll(rx, cy));
2980           cx = rx;
2981         }
2982       }
2983     }
2984   }
2985   evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
2986 };
2987 _sproto._nodeInsert = function(evt){
2988   var tar = evt.target;
2989   if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2990     return; //強制終了させる
2991   }
2992   var tnext = tar.nextSibling,
2993       tpart = tar.parentNode._tar,
2994       isLast = true;
2995   if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
2996     tpart.insertBefore(tar._tar, tnext._tar);
2997   } else if (tnext && !tnext._tar && tpart) {
2998     /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
2999      *use要素や実体参照などは_tarプロパティがないことに注意
3000      */
3001     while (tnext) {
3002       if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3003         tpart.insertBefore(tar._tar, tnext._tar);
3004         isLast = false;
3005       } 
3006       tnext = tnext.nextSibling;
3007     }
3008     if (isLast) {
3009       tpart.appendChild(tar._tar);
3010     }
3011   } else if (!tnext && tpart) {
3012     tpart.appendChild(tar._tar);      
3013   }
3014   tnext = tpart = isLast = void 0;
3015   tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
3016   evt = tar = void 0;
3017 };
3018 _sproto._nodeInsertInto = function(evt){
3019   /*以下の処理は、normalizedpathSegListとCTMに基づいて、
3020    *SVGのd属性をVMLに変換していく処理である。
3021    */
3022   var tar = evt.target,
3023       matrix = tar.getScreenCTM(),
3024       tlist = tar.normalizedPathSegList,
3025       dat = [],
3026       ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
3027       cname = tar._com._nameCom,
3028       isZ = tar._com._isZ, isC = tar._com._isC,
3029       mr = _math.round;
3030   for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
3031     var ti = tlist[i],
3032         tx = ti.x,
3033         ty = ti.y,
3034         tps = ti.pathSegTypeAsLetter,
3035         t = cname[tps];
3036     if (isC[tps]) {
3037       /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
3038        *[ma mc me]   [x]
3039        *[mb md mf] * [y]
3040        *[0  0  1 ]   [1]
3041        */
3042       t += [mr(ma*ti.x1 + mc*ti.y1 + me),
3043              mr(mb*ti.x1 + md*ti.y1 + mf),
3044              mr(ma*ti.x2 + mc*ti.y2 + me),
3045              mr(mb*ti.x2 + md*ti.y2 + mf),
3046              mr(ma*tx + mc*ty + me),
3047              mr(mb*tx + md*ty + mf)].join(" ");
3048     } else if (!isZ[tps]) {
3049       t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
3050     }
3051     dat[i] = t;
3052   }
3053   var vi = tar.ownerDocument.documentElement,
3054       tt = tar._tar;
3055   dat.push(" e");
3056   tt.path = dat.join(" ");
3057   tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
3058   NAIBU._setPaint(tar, matrix);
3059   delete tar._cacheMatrix;
3060   evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
3061 };
3062 _sproto._com = {
3063   _nameCom : {
3064     z : " x ",
3065     Z : " x ",
3066     C : "c",
3067     L : "l",
3068     M : "m"
3069   },
3070   _isZ : {
3071     z : 1,
3072     Z : 1
3073   },
3074   _isC : {
3075     C : 1
3076   },
3077   _isL : {
3078     L : 1
3079   },
3080   _isM : {
3081     M : 1
3082   },
3083   isRa : /\-/g,
3084   isRb : /,/g,
3085   isRc : /([a-yA-Y])/g,
3086   isRd : /([zZ])/g,
3087   isRe : /,/,
3088   isSp : /\S+/g
3089 };
3090   /*float*/         _sproto.getTotalLength = function() {
3091     var s = 0,
3092         nl = this.normalizedPathSegList;
3093     for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
3094       var seg = nl.getItem(i);
3095       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3096         var ps = nl.getItem(i-1);
3097         s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3098       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3099         var ps = nl.getItem(i-1), dd = 0;
3100         /*2点のハンドルを結んだ線分の3辺と、
3101          *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
3102          *
3103          *注意
3104          *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
3105          *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
3106          */
3107         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3108         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3109         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3110         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3111         s += dd / 2;
3112       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3113         var ps = nl.getItem(i-1), ms = nl.getItem(0);
3114         s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
3115       }
3116
3117     }
3118     this.pathLength.baseVal = s;
3119     return s;
3120   };
3121   /*SVGPoint*/      _sproto.getPointAtLength = function(/*float*/ distance ) {
3122     var segn = this.getPathSegAtLength(distance),
3123         x = 0,
3124         y = 0,
3125         nl = this.normalizedPathSegList,
3126         seg = nl.getItem(segn),
3127         s = this.ownerDocument.documentElement.createSVGPoint();
3128     if ((segn-1) <= 0) {
3129       s.x = seg.x;
3130       s.y = seg.y;
3131       return s;
3132     }
3133     var ps = nl.getItem(segn-1);
3134     if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3135       var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3136       var t = (segl + this._dis) / segl;
3137       s.x = ps.x + t * (seg.x-ps.x);
3138       s.y = ps.y + t * (seg.y-ps.y);
3139     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3140       var dd = 0;
3141       dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3142       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3143       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3144       dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3145       var segl = dd / 2;
3146       var t = (segl + this._dis) / segl;
3147       /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
3148        *使って、ポイントの座標を演算する
3149        */
3150       s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
3151            +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
3152            +3*(seg.x1 - ps.x) * t
3153            +ps.x;
3154       s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
3155            +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
3156            +3*(seg.y1 - ps.y) * t
3157            +ps.y;
3158     } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
3159       s.x = seg.x;
3160       s.y = seg.y;
3161     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3162       var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
3163       var t = (segl + this._dis) / segl;
3164       s.x = ms.x + t * (seg.x-ms.x);
3165       s.y = ms.y + t * (seg.y-ms.y);
3166     }
3167     return s;
3168   };
3169   /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
3170     var nl = this.normalizedPathSegList; //仕様ではpathSegList
3171     for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
3172       var seg = nl.getItem(i);
3173       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3174         var ps = nl.getItem(i-1);
3175         distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3176       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3177         var ps = nl.getItem(i-1), dd = 0;
3178         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3179         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3180         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3181         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3182         distance -= dd / 2;
3183         dd = void 0;
3184       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3185         var ps = nl.getItem(i-1), ms = nl.getItem(0);
3186         distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
3187       }
3188       if (distance <= 0) {
3189         /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
3190         this._dis = distance;
3191         distance = void 0;
3192         return i;
3193       }
3194     }
3195     /*もし、distanceがパスの距離よりも長い場合、
3196      *最後のセグメントの番号を返す
3197      *なお、これはSVG1.1の仕様の想定外のこと
3198      */
3199     return (nl.numberOfItems - 1);
3200   };
3201   /*SVGPathSegClosePath*/    _sproto.createSVGPathSegClosePath = function() {
3202     var _SVGPathSegClosePath = SVGPathSegClosePath;
3203     return (new _SVGPathSegClosePath());
3204   };
3205   /*SVGPathSegMovetoAbs*/    _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
3206     var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
3207     s.x = x;
3208     s.y = y;
3209     return s;
3210   };
3211   /*SVGPathSegMovetoRel*/    _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
3212     var s = new SVGPathSegMovetoRel();
3213     s.x = x;
3214     s.y = y;
3215     return s;
3216   };
3217   /*SVGPathSegLinetoAbs*/    _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
3218     var s = new SVGPathSegLinetoAbs();
3219     s.x = x;
3220     s.y = y;
3221     return s;
3222   };
3223   /*SVGPathSegLinetoRel*/    _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
3224     var s = new SVGPathSegLinetoRel();
3225     s.x = x;
3226     s.y = y;
3227     return s;
3228   };
3229   /*SVGPathSegCurvetoCubicAbs*/    _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
3230     var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
3231     s.x = x;
3232     s.y = y;
3233     s.x1 = x1;
3234     s.y1 = y1;
3235     s.x2 = x2;
3236     s.y2 = y2;
3237     return s;
3238   };
3239   /*SVGPathSegCurvetoCubicRel*/    _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
3240     var s = new SVGPathSegCurvetoCubicRel();
3241     s.x = x;
3242     s.y = y;
3243     s.x1 = x1;
3244     s.y1 = y1;
3245     s.x2 = x2;
3246     s.y2 = y2;
3247     return s;
3248   };
3249   /*SVGPathSegCurvetoQuadraticAbs*/    _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
3250     var s = new SVGPathSegCurvetoQuadraticAbs();
3251     s.x = x;
3252     s.y = y;
3253     s.x1 = x1;
3254     s.y1 = y1;
3255     return s;
3256   };
3257   /*SVGPathSegCurvetoQuadraticRel*/    _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
3258     var s = new SVGPathSegCurvetoQuadraticRel();
3259     s.x = x;
3260     s.y = y;
3261     s.x1 = x1;
3262     s.y1 = y1;
3263     return s;
3264   };
3265   /*SVGPathSegArcAbs*/    _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
3266     var s = new SVGPathSegArcAbs();
3267     s.x = x;
3268     s.y = y;
3269     s.r1 = r1;
3270     s.r2 = r2;
3271     s.angle = angle;
3272     s.largeArcFlag = largeArcFlag;
3273     s.sweepFlag = sweepFlag;
3274     return s;
3275   };
3276   /*SVGPathSegArcRel*/    _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
3277     var s = new SVGPathSegArcRel();
3278     s.x = x;
3279     s.y = y;
3280     s.r1 = r1;
3281     s.r2 = r2;
3282     s.angle = angle;
3283     s.largeArcFlag = largeArcFlag;
3284     s.sweepFlag = sweepFlag;
3285     return s;
3286   };
3287   /*SVGPathSegLinetoHorizontalAbs*/    _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
3288     var s = new SVGPathSegLinetoHorizontalAbs();
3289     s.x = x;
3290     s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
3291     return s;
3292   };
3293   /*SVGPathSegLinetoHorizontalRel*/    _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
3294     var s = new SVGPathSegLinetoHorizontalRel();
3295     s.x = x;
3296     s.y = 0;
3297     return s;
3298   };
3299   /*SVGPathSegLinetoVerticalAbs*/    _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
3300     var s = new SVGPathSegLinetoVerticalAbs();
3301     s.x = 0;
3302     s.y = y;
3303     return s;
3304   };
3305   /*SVGPathSegLinetoVerticalRel*/    _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
3306     var s = new SVGPathSegLinetoVerticalRel();
3307     s.x = 0;
3308     s.y = y;
3309     return s;
3310   };
3311   /*SVGPathSegCurvetoCubicSmoothAbs*/    _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
3312     var s = new SVGPathSegCurvetoCubicSmoothAbs();
3313     s.x = x;
3314     s.y = y;
3315     s.x2 = x2;
3316     s.y2 = y2;
3317     return s;
3318   };
3319   /*SVGPathSegCurvetoCubicSmoothRel*/    _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
3320     var s = new SVGPathSegCurvetoCubicSmoothRel();
3321     s.x = x;
3322     s.y = y;
3323     s.x2 = x2;
3324     s.y2 = y2;
3325     return s;
3326   };
3327   /*SVGPathSegCurvetoQuadraticSmoothAbs*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
3328     var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
3329     s.x = x;
3330     s.y = y;
3331     return s;
3332   };
3333   /*SVGPathSegCurvetoQuadraticSmoothRel*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
3334     var s = new SVGPathSegCurvetoQuadraticSmoothRel();
3335     s.x = x;
3336     s.y = y;
3337     return s;
3338   };
3339 })(SVGPathElement.prototype)
3340   NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
3341 })(document, Math);
3342
3343 function SVGRectElement(_doc) {
3344   SVGElement.apply(this);
3345   this._tar = _doc.createElement("v:shape");
3346   var slen = SVGAnimatedLength;
3347   /*readonly SVGAnimatedLength*/ this.x = new slen();
3348   /*readonly SVGAnimatedLength*/ this.y = new slen();
3349   /*readonly SVGAnimatedLength*/ this.width = new slen();
3350   /*readonly SVGAnimatedLength*/ this.height = new slen();
3351   /*readonly SVGAnimatedLength*/ this.rx = new slen();
3352   /*readonly SVGAnimatedLength*/ this.ry = new slen();
3353   _doc = slen = void 0;
3354   this.addEventListener("DOMNodeInserted", function(evt){
3355     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3356       return; //強制終了させる
3357     }
3358     var tar = evt.target,
3359         tnext = tar.nextSibling,
3360         tpart = tar.parentNode._tar,
3361         isLast = true;
3362     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3363       tpart.insertBefore(tar._tar, tnext._tar);
3364     } else if (tnext && !tnext._tar && tpart) {
3365       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3366        *use要素や実体参照などは_tarプロパティがないことに注意
3367        */
3368       while (tnext) {
3369         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3370           tpart.insertBefore(tar._tar, tnext._tar);
3371           isLast = false;
3372         } 
3373         tnext = tnext.nextSibling;
3374       }
3375       if (isLast) {
3376         tpart.appendChild(tar._tar);
3377       }
3378     } else if (!tnext && tpart) {
3379       tpart.appendChild(tar._tar);      
3380     }
3381     tnext = tpart = isLast = void 0;
3382     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3383       var tar = evt.target,
3384           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3385           fontSize = parseFloat(style.getPropertyValue("font-size"));
3386       tar.x.baseVal._emToUnit(fontSize);
3387       tar.y.baseVal._emToUnit(fontSize);
3388       tar.width.baseVal._emToUnit(fontSize);
3389       tar.height.baseVal._emToUnit(fontSize);
3390       var rx = tar.getAttributeNS(null, "rx"),
3391           ry = tar.getAttributeNS(null, "ry"),
3392           x = tar.x.baseVal.value,
3393           y = tar.y.baseVal.value,
3394           xw = x + tar.width.baseVal.value,
3395           yh = y + tar.height.baseVal.value,
3396           list;
3397       if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
3398         tar.rx.baseVal._emToUnit(fontSize);
3399         tar.ry.baseVal._emToUnit(fontSize);
3400         var thrx = tar.rx.baseVal,
3401             thry = tar.ry.baseVal,
3402             twidth = tar.width.baseVal.value,
3403             theight = tar.height.baseVal.value;
3404         thrx.value = rx ? thrx.value : thry.value;
3405         thry.value = ry ? thry.value : thrx.value;
3406         //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
3407         if (thrx.value > twidth / 2) {
3408           thrx.value = twidth / 2;
3409         }
3410         if (thry.value > theight / 2) {
3411           thry.value = theight / 2;
3412         }
3413         var rxv = thrx.value,
3414             ryv = thry.value,
3415             rrx = rxv * 0.55228,
3416             rry = ryv * 0.55228,
3417             a = xw - rxv,
3418             b = x + rxv,
3419             c = y + ryv,
3420             d = yh - ryv;
3421         list = ["m",b,y, "l",a,y, "c",a+rrx,y,xw,c-rry,xw,c, "l",xw,d, "c",xw,d+rry,a+rrx,yh,a,yh, "l",b,yh, "c",b-rrx,yh,x,d+rry,x,d, "l",x,c, "c",x,c-rry,b-rrx,y,b,y];
3422       } else {
3423         list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
3424       }
3425       //以下は、配列listそのものをCTMで座標変換していく処理
3426       var par = tar.ownerDocument.documentElement,
3427           ctm = tar.getScreenCTM(),
3428           dat, p, pmt,
3429           ele = tar._tar,
3430           vi = tar.ownerDocument.documentElement,
3431           w = vi.width.baseVal.value,
3432           h = vi.height.baseVal.value,
3433           mr = Math.round;
3434       for (var i=0, lili=list.length;i<lili;) {
3435         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3436           ++i;
3437           continue;
3438         }
3439         p = par.createSVGPoint();
3440         p.x = list[i];
3441         p.y = list[i+1];
3442         pmt = p.matrixTransform(ctm);
3443         list[i] = mr(pmt.x);
3444         ++i;
3445         list[i] = mr(pmt.y);
3446         ++i;
3447         p = pmt = void 0;
3448       }
3449       dat = list.join(" ");
3450       //VMLに結び付けていく
3451       ele.path = dat;
3452       ele.coordsize = w + " " + h;
3453       NAIBU._setPaint(tar, ctm);
3454       delete tar._cacheMatrix;
3455       evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
3456     }, false);
3457     evt = tar = void 0;
3458   }, false);
3459   return this;
3460 };
3461 SVGRectElement.constructor = SVGElement;
3462 SVGRectElement.prototype = new SVGElement();
3463
3464 function SVGCircleElement(_doc) { 
3465   SVGElement.apply(this);
3466   this._tar = _doc.createElement("v:shape");
3467   var sl = SVGAnimatedLength;
3468   /*readonly SVGAnimatedLength*/ this.cx = new sl();
3469   /*readonly SVGAnimatedLength*/ this.cy = new sl();
3470   /*readonly SVGAnimatedLength*/ this.r = new sl();
3471   _doc = sl = void 0;
3472   this.addEventListener("DOMNodeInserted", function(evt){
3473     var tar = evt.target;
3474     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3475       return; //強制終了させる
3476     }
3477     var tnext = tar.nextSibling,
3478         tpart = tar.parentNode._tar,
3479         isLast = true;
3480     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3481       tpart.insertBefore(tar._tar, tnext._tar);
3482     } else if (tnext && !tnext._tar && tpart) {
3483       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3484        *use要素や実体参照などは_tarプロパティがないことに注意
3485        */
3486       while (tnext) {
3487         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3488           tpart.insertBefore(tar._tar, tnext._tar);
3489           isLast = false;
3490         } 
3491         tnext = tnext.nextSibling;
3492       }
3493       if (isLast) {
3494         tpart.appendChild(tar._tar);
3495       }
3496     } else if (!tnext && tpart) {
3497       tpart.appendChild(tar._tar);      
3498     }
3499     tnext = tpart = isLast = void 0;
3500     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3501       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3502       var fontSize = parseFloat(style.getPropertyValue("font-size"));
3503       tar.cx.baseVal._emToUnit(fontSize);
3504       tar.cy.baseVal._emToUnit(fontSize);
3505       tar.r.baseVal._emToUnit(fontSize);
3506       var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value;
3507       var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
3508         var rrx = rx * 0.55228, rry = ry * 0.55228;
3509         var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
3510         //以下は、配列listそのものをCTMで座標変換していく処理
3511         var par = tar.ownerDocument.documentElement,
3512             ctm = tar.getScreenCTM(),
3513             mr = Math.round;
3514         for (var i=0, lili=list.length;i<lili;) {
3515           if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3516             ++i;
3517             continue;
3518           }
3519           var p = par.createSVGPoint();
3520           p.x = list[i];
3521           p.y = list[i+1];
3522           var pmt = p.matrixTransform(ctm);
3523           list[i] = mr(pmt.x);
3524           ++i;
3525           list[i] = mr(pmt.y);
3526           ++i;
3527           p = pmt = void 0;
3528         }
3529         var dat = list.join(" ");
3530         //VMLに結び付けていく
3531         var ele = tar._tar, vi = tar.ownerDocument.documentElement;
3532         var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3533         ele.path = dat;
3534         ele.coordsize = w + " " + h;
3535         NAIBU._setPaint(tar, ctm);
3536         delete tar._cacheMatrix;
3537         evt = tar = list = mr = style = fontSize = dat = ele = void 0;
3538     }, false);
3539     evt = tar = void 0;
3540   }, false);
3541   return this;
3542 };
3543 SVGCircleElement.constructor = SVGElement;
3544 SVGCircleElement.prototype = new SVGElement();
3545
3546 function SVGEllipseElement(_doc) { 
3547   SVGElement.apply(this);
3548   this._tar = _doc.createElement("v:shape");
3549   var sl = SVGAnimatedLength;
3550   /*readonly SVGAnimatedLength*/ this.cx = new sl();
3551   /*readonly SVGAnimatedLength*/ this.cy = new sl();
3552   /*readonly SVGAnimatedLength*/ this.rx = new sl();
3553   /*readonly SVGAnimatedLength*/ this.ry = new sl();
3554   _doc = sl = void 0;
3555   this.addEventListener("DOMNodeInserted", function(evt){
3556     var tar = evt.target;
3557     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3558       return; //強制終了させる
3559     }
3560     var tnext = tar.nextSibling,
3561     tpart = tar.parentNode._tar,
3562     isLast = true;
3563     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3564       tpart.insertBefore(tar._tar, tnext._tar);
3565     } else if (tnext && !tnext._tar && tpart) {
3566       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3567        *use要素や実体参照などは_tarプロパティがないことに注意
3568        */
3569       while (tnext) {
3570         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3571           tpart.insertBefore(tar._tar, tnext._tar);
3572           isLast = false;
3573         } 
3574         tnext = tnext.nextSibling;
3575       }
3576       if (isLast) {
3577         tpart.appendChild(tar._tar);
3578       }
3579     } else if (!tnext && tpart) {
3580       tpart.appendChild(tar._tar);      
3581     }
3582     tnext = tpart = isLast = void 0;
3583     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3584       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3585       var fontSize = parseFloat(style.getPropertyValue("font-size"));
3586       tar.cx.baseVal._emToUnit(fontSize);
3587       tar.cy.baseVal._emToUnit(fontSize);
3588       tar.rx.baseVal._emToUnit(fontSize);
3589       tar.ry.baseVal._emToUnit(fontSize);
3590       var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value;
3591       var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
3592       var rrx = rx * 0.55228, rry = ry * 0.55228;
3593       var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
3594       //以下は、配列listそのものをCTMで座標変換していく処理
3595       var par = tar.ownerDocument.documentElement,
3596           ctm = tar.getScreenCTM(),
3597           mr = Math.round;
3598       for (var i=0, lili=list.length;i<lili;) {
3599         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3600           ++i;
3601           continue;
3602         }
3603         var p = par.createSVGPoint();
3604         p.x = list[i];
3605         p.y = list[i+1];
3606         var pmt = p.matrixTransform(ctm);
3607         list[i] = mr(pmt.x);
3608         ++i;
3609         list[i] = mr(pmt.y);
3610         ++i;
3611         p = pmt = void 0;
3612       }
3613       var dat = list.join(" ");
3614       //VMLに結び付けていく
3615       var ele = tar._tar, vi = tar.ownerDocument.documentElement;
3616       var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3617       ele.path = dat;
3618       ele.coordsize = w + " " + h;
3619       NAIBU._setPaint(tar, ctm);
3620       delete tar._cacheMatrix;
3621       evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
3622     }, false);
3623     evt = tar = void 0;
3624   }, false);
3625   return this;
3626 };
3627 SVGEllipseElement.constructor = SVGElement;
3628 SVGEllipseElement.prototype = new SVGElement();
3629
3630 function SVGLineElement(_doc) { 
3631   SVGElement.apply(this);
3632   this._tar = _doc.createElement("v:shape");
3633   var sl = SVGAnimatedLength;
3634   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
3635   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
3636   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
3637   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
3638   _doc = sl = void 0;
3639   this.addEventListener("DOMNodeInserted", function(evt){
3640     var tar = evt.target;
3641     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3642       return; //強制終了させる
3643     }
3644     var tnext = tar.nextSibling,
3645         tpart = tar.parentNode._tar,
3646         isLast = true;
3647     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3648       tpart.insertBefore(tar._tar, tnext._tar);
3649     } else if (tnext && !tnext._tar && tpart) {
3650       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3651        *use要素や実体参照などは_tarプロパティがないことに注意
3652        */
3653       while (tnext) {
3654         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3655           tpart.insertBefore(tar._tar, tnext._tar);
3656           isLast = false;
3657         } 
3658         tnext = tnext.nextSibling;
3659       }
3660       if (isLast) {
3661         tpart.appendChild(tar._tar);
3662       }
3663     } else if (!tnext && tpart) {
3664       tpart.appendChild(tar._tar);      
3665     }
3666     tnext = tpart = isLast = void 0;
3667     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3668       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3669       var fontSize = parseFloat(style.getPropertyValue("font-size"));
3670       tar.x1.baseVal._emToUnit(fontSize);
3671       tar.y1.baseVal._emToUnit(fontSize);
3672       tar.x2.baseVal._emToUnit(fontSize);
3673       tar.y2.baseVal._emToUnit(fontSize);
3674       //以下は、配列listそのものをCTMで座標変換していく処理
3675       var vi = tar.ownerDocument.documentElement,
3676           ctm = tar.getScreenCTM(),
3677           dat = "m ",
3678           mr = Math.round,
3679           p = vi.createSVGPoint();
3680       p.x = tar.x1.baseVal.value;
3681       p.y = tar.y1.baseVal.value;
3682       var pmt = p.matrixTransform(ctm);
3683       dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
3684       p.x = tar.x2.baseVal.value;
3685       p.y = tar.y2.baseVal.value;
3686       pmt = p.matrixTransform(ctm);
3687       dat += mr(pmt.x)+ " " +mr(pmt.y);
3688       p = pmt = void 0;
3689       //VMLに結び付けていく
3690       var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3691       ele.path = dat;
3692       ele.coordsize = w + " " + h;
3693       NAIBU._setPaint(tar, ctm);
3694       delete tar._cacheMatrix;
3695       evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
3696     }, false);
3697     evt = tar = void 0;
3698   }, false);
3699   return this;
3700 };
3701 SVGLineElement.constructor = SVGElement;
3702 SVGLineElement.prototype = new SVGElement();
3703
3704 /*_GenericSVGPolyElementインターフェース
3705  * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
3706  * ファイルサイズを軽量にすることができる
3707  */
3708 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
3709   SVGElement.apply(this);
3710   this._tar = _doc.createElement("v:shape");
3711   _doc = void 0;
3712   //interface SVGAnimatedPoints
3713   /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
3714   this.addEventListener("DOMAttrModified", function(evt){
3715     var tar = evt.target;
3716     if (evt.attrName === "points") {
3717       var tp = tar.points, par = tar.ownerDocument.documentElement;
3718       var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3719       for (var i=0, p, lili=list.length;i<lili;i+=2) {
3720         if (isNaN(list[i])) {
3721           --i;
3722           continue;
3723         }
3724         p = par.createSVGPoint();
3725         p.x = parseFloat(list[i]);
3726         p.y = parseFloat(list[i+1]);
3727         tp.appendItem(p);
3728       }
3729     }
3730     evt = tar = list = tp = par = p = void 0;
3731   }, false);
3732   this.addEventListener("DOMNodeInserted", function(evt){
3733     var tar = evt.target;
3734     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3735       return; //強制終了させる
3736     }
3737     var tnext = tar.nextSibling,
3738         tpart = tar.parentNode._tar,
3739         isLast = true;
3740     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3741       tpart.insertBefore(tar._tar, tnext._tar);
3742     } else if (tnext && !tnext._tar && tpart) {
3743       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3744        *use要素や実体参照などは_tarプロパティがないことに注意
3745        */
3746       while (tnext) {
3747         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3748           tpart.insertBefore(tar._tar, tnext._tar);
3749           isLast = false;
3750         } 
3751         tnext = tnext.nextSibling;
3752       }
3753       if (isLast) {
3754         tpart.appendChild(tar._tar);
3755       }
3756     } else if (!tnext && tpart) {
3757       tpart.appendChild(tar._tar);      
3758     }
3759     tnext = tpart = isLast = void 0;
3760     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3761       var tar = evt.target,
3762           tp = tar.points,
3763           ctm = tar.getScreenCTM(),
3764           mr = Math.round;
3765       //以下は、配列listそのものをCTMで座標変換していく処理
3766       for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
3767         var p = tp.getItem(i),
3768             pmt = p.matrixTransform(ctm);
3769         list[2*i] = mr(pmt.x);
3770         list[2*i + 1] = mr(pmt.y);
3771         p = pmt = void 0;
3772       }
3773       list.splice(2, 0, "l");
3774       var dat = "m" + list.join(" ") + xclose,
3775           ele = tar._tar,
3776           vi = tar.ownerDocument.documentElement;
3777           w = vi.width.baseVal.value,
3778           h = vi.height.baseVal.value;
3779       //VMLに結び付けていく
3780       ele.path = dat;
3781       ele.coordsize = w + " " + h;
3782       NAIBU._setPaint(tar, ctm);
3783       delete tar._cacheMatrix;
3784       evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
3785     }, false);
3786     evt = tar = void 0;
3787   }, false);
3788   return this;
3789 }
3790 function SVGPolylineElement(_doc) {
3791   NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
3792   _doc = void 0;
3793   return this;
3794 };
3795 SVGPolylineElement.constructor = SVGElement;
3796 SVGPolylineElement.prototype = new SVGElement();
3797
3798 function SVGPolygonElement(_doc) {
3799   NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
3800   _doc = void 0;
3801   return this;
3802 };
3803 SVGPolygonElement.constructor = SVGElement;
3804 SVGPolygonElement.prototype = new SVGElement();
3805
3806 function SVGTextContentElement(_doc) { 
3807   SVGElement.apply(this);
3808   /*readonly SVGAnimatedLength*/      this.textLength = new SVGAnimatedLength();
3809   /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
3810   this.addEventListener("DOMNodeInserted", function(evt){
3811     var tar = evt.target, cur = evt.currentTarget;
3812     /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
3813      *あらかじめ、Capturingフェーズで処理しておく
3814      */
3815     if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
3816       /*a要素の場合はtarをすりかえておく*/
3817       tar = tar.firstChild;
3818     }
3819     if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
3820       /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
3821       tar._tars = [];
3822       var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
3823       tar.data = data;
3824       data = data.split('');
3825       for (var i=0, tdli=data.length;i<tdli;++i) {
3826         var d = _doc.createElement("div"),
3827             dstyle = d.style;
3828         dstyle.position = "absolute";
3829         dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = "0px";
3830         dstyle.paddingTop = dstyle.paddingLeft = "0px";
3831         dstyle.whiteSpace = "nowrap";
3832         dstyle.textIndent = "0px";
3833         d.appendChild(_doc.createTextNode(data[i]));
3834         tar._tars[tar._tars.length] = d;
3835       }
3836       data = void 0;
3837       cur._length += tar._tars.length;
3838     } else if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar instanceof SVGTextContentElement) && !!!tar._tars) {
3839       cur._length += tar._length;
3840     }
3841     evt = tar = cur = void 0;
3842   }, true);
3843  return this;
3844 };
3845
3846 (function(t) {
3847 t.constructor = SVGElement;
3848 t.prototype = new SVGElement();
3849     // lengthAdjust Types
3850   /*unsigned short*/ t.LENGTHADJUST_UNKNOWN           = 0;
3851   /*unsigned short*/ t.LENGTHADJUST_SPACING           = 1;
3852   /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS  = 2;
3853   t.prototype._list = null;         //文字の位置を格納しておくリストのキャッシュ
3854   t.prototype._length = 0;          //全文字数
3855   t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
3856   t.prototype._chars = 0;           //tspan (tref)要素が全体の何文字目から始まっているか
3857   t.prototype._isYokogaki = true;          //横書きかどうか
3858 /*long*/     t.prototype.getNumberOfChars = function() {
3859   return (this._length);
3860 };
3861 /*float*/    t.prototype.getComputedTextLength = function() {
3862   var l = this.textLength.baseVal;
3863   if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
3864     /*何も設定されていない場合のみ、初期化を行う*/
3865     l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
3866   }
3867   l = void 0;
3868   return (this.textLength.baseVal.value);
3869 };
3870 /*getSubStringLengthメソッド
3871  *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
3872  */
3873 /*float*/    t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
3874   if (nchars === 0) {
3875     return 0;
3876   }
3877   var tg = this.getNumberOfChars();
3878   if (tg < (nchars+charnum)) {
3879     /*ncharsが文字列の長さよりも長くなってしまったときには、
3880      *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
3881      */
3882     nchars = tg - charnum + 1;
3883   }
3884   var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
3885   if (this._isYokogaki) {
3886     var s = end.x - st.x;
3887   } else {
3888     var s = end.y - st.y;
3889   }
3890   tg = end = st = void 0;
3891   return s;
3892 }
3893 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
3894   if (charnum > this.getNumberOfChars() || charnum < 0) {
3895     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
3896   } else {
3897     var tar = this,
3898         ti = tar.firstChild,
3899         tp = tar.parentNode;
3900     if (!!!tar._list) {
3901       tar._list = [];
3902       var chars = tar._chars, //現在、何文字目にあるのか
3903           x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
3904           style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
3905           isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
3906           fontSize = parseFloat(style.getPropertyValue("font-size")),
3907           tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
3908       /*親要素の属性も参照しておく*/
3909       if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
3910         var ptx = tp.x.baseVal,
3911             pty = tp.y.baseVal,
3912             ptdx = tp.dx.baseVal,
3913             ptdy = tp.dy.baseVal;
3914       } else {
3915         var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
3916       }
3917       var kern = "f ijltIr.,:;'-\"()",
3918           akern = "1234567890abcdeghknopquvxyz",
3919           tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
3920       if (isYokogaki && (tar.localName === "text")) {
3921         y += fontSize * 0.2;
3922       } else if (tar.localName === "text"){
3923         x -= fontSize * 0.5;
3924       }
3925       while (ti) {
3926         if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
3927           tt = ti._tars;
3928           /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
3929            *使う。また、属性が指定されていないときも同様に祖先や親を使う。
3930            *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
3931            *この処理はdx属性やdy、y属性でも同様とする
3932            *参照資料SVG1.1 Text
3933            *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
3934            *
3935            *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
3936            */
3937           for (var i=0, tli=tt.length;i<tli;++i) {
3938             if (n < ptx.numberOfItems - chars) {
3939               x = ptx.getItem(n).value;
3940               if (!isYokogaki) {
3941                 x -= fontSize * 0.5;
3942               }
3943             } else if (n < tx.numberOfItems) {
3944               x = tx.getItem(n).value;
3945               if (!isYokogaki) {
3946                 x -= fontSize * 0.5;
3947               }
3948             }
3949             if (n < pty.numberOfItems - chars) {
3950               y = pty.getItem(n).value;
3951               if (isYokogaki) {
3952                 y += fontSize * 0.2;
3953               }
3954             } else if (n < ty.numberOfItems) {
3955               y = ty.getItem(n).value;
3956               if (isYokogaki) {
3957                 y += fontSize * 0.2;
3958               }
3959             }
3960             if (n < ptdx.numberOfItems - chars) {
3961               x += ptdx.getItem(n).value;
3962             } else if (n < tdx.numberOfItems) {
3963               x += tdx.getItem(n).value;
3964             }
3965             if (n < ptdy.numberOfItems - chars) {
3966               y += ptdy.getItem(n).value;
3967             } else if (n < tdy.numberOfItems) {
3968               y += tdy.getItem(n).value;
3969             }
3970             alm = 0;
3971             if (isYokogaki) {
3972               //カーニングを求めて、字の幅を文字ごとに調整する
3973               tdc = ti.data.charAt(i);
3974               if (kern.indexOf(tdc) > -1) {
3975                 alm = fontSize * 0.68;
3976               } else if (tdc === "s"){
3977                 alm = fontSize * 0.52;
3978               } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
3979                 alm = fontSize * 0.2;
3980               } else if (akern.indexOf(tdc) > -1){
3981                 alm = fontSize * 0.45;
3982               } else {
3983                 alm = fontSize * 0.3;
3984               }
3985               tcca = tdc.charCodeAt(0);
3986               if ((12288 <= tcca) && (tcca <= 65533)) {
3987                 alm = -fontSize * 0.01;
3988                 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
3989                   alm += fontSize * 0.2;
3990                 }
3991               }
3992             }
3993             tlist = tar._list;
3994             tlist[tlist.length] = x;
3995             tlist[tlist.length] = y;
3996             tlist[tlist.length] = fontSize - alm;
3997             if (isYokogaki) {
3998               x += fontSize;
3999               x -= alm;
4000             } else {
4001               y += fontSize;
4002             }
4003             ++n;
4004           }
4005           chars += tli;
4006           if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
4007             ti = ti.parentNode;
4008           }
4009           ti = ti.nextSibling;
4010         } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
4011             && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4012           /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
4013            *さらに、現在のテキスト位置を更新する
4014            */
4015           ti._stx = x;
4016           ti._sty = y;
4017           ti._chars = chars;
4018           p = ti.getStartPositionOfChar(ti.getNumberOfChars());
4019           almx = 0;
4020           almy = 0;
4021           tlist = ti._list;
4022           if (isYokogaki) {
4023             almx = tlist[tlist.length-1];
4024           } else {
4025             almy = tlist[tlist.length-1];
4026           }
4027           x = tlist[tlist.length-3] + almx;
4028           y = tlist[tlist.length-2] + almy;
4029           tar._list = tar._list.concat(tlist);
4030           tg = ti.getNumberOfChars();
4031           n += tg;
4032           chars += tg;
4033           ti = ti.nextSibling;
4034         } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4035           /*a要素のテキストノードも処理する*/
4036           ti = ti.firstChild;
4037         } else {
4038           ti = ti.nextSibling;
4039         }
4040       }
4041       tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
4042     }
4043     tar = ti = tp = ptx = pty = tx = ty = chars = style = x = y = isYokogaki = kern = akern = tt = alm = tdc = tcca = p = almx = almy = tlist = tg = void 0;
4044     var s = this.ownerDocument.documentElement.createSVGPoint();
4045     s.x = this._list[charnum*3];
4046     s.y = this._list[charnum*3 + 1];
4047     s = s.matrixTransform(this.getScreenCTM());
4048     return s;
4049   }
4050 };
4051 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
4052   if (charnum > this.getNumberOfChars() || charnum < 0) {
4053     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
4054   } else {
4055     var s = this.getStartPositionOfChar(charnum);
4056     //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
4057     var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
4058     if (this._isYokogaki) {
4059       s.x += n;
4060     } else {
4061       s.y += n;
4062     }
4063     return s;
4064   }
4065 };
4066 /*SVGRect*/  t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
4067   
4068 };
4069 /*float*/    t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
4070   
4071 };
4072 /*long*/     t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
4073   
4074 };
4075 /*void*/     t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
4076   
4077 };
4078 })(SVGTextContentElement);
4079
4080 function SVGTextPositioningElement(_doc) { 
4081   SVGTextContentElement.apply(this, arguments);
4082   var sl = SVGAnimatedLengthList;
4083   /*readonly SVGAnimatedLengthList*/ this.x = new sl();
4084   /*readonly SVGAnimatedLengthList*/ this.y = new sl();
4085   /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
4086   /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
4087   sl = void 0;
4088   /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
4089   this.addEventListener("DOMAttrModified", function(evt){
4090     var tar = evt.target,
4091         name = evt.attrName,
4092         tod = tar.ownerDocument.documentElement,
4093         _parseFloat = parseFloat;
4094     if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
4095       var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
4096           teas = tar[name].baseVal;
4097       for (var i=0, tli=enr.length;i<tli;++i) {
4098         var tea = tod.createSVGLength(),
4099             n = enr[i].slice(-1),
4100             type = 0;
4101         if (n >= "0" && n <= "9") {
4102           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
4103         } else if (n === "%") {
4104           if ((name === "x") || (name === "dx")) {
4105             tea._percent *= tod.viewport.width;
4106           } else if ((name === "y") || (name === "dy")) {
4107             tea._percent *= tod.viewport.height;
4108           }
4109           type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
4110         } else {
4111           n = enr[i].slice(-2);
4112           if (n === "em") {
4113             var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
4114             tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
4115             style = void 0;
4116             type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
4117           } else if (n === "ex") {
4118             type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
4119           } else if (n === "px") {
4120             type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
4121           } else if (n === "cm") {
4122             type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
4123           } else if (n === "mm") {
4124             type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
4125           } else if (n === "in") {
4126             type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
4127           } else if (n === "pt") {
4128             type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
4129           } else if (n === "pc") {
4130             type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
4131           }
4132         }
4133         var s = _parseFloat(enr[i]);
4134         s = isNaN(s) ? 0 : s;
4135         tea.newValueSpecifiedUnits(type, s);
4136         teas.appendItem(tea);
4137       }
4138       tar._list = null;
4139     }
4140     evt = tar = void 0;
4141   }, false);
4142   this.addEventListener("DOMNodeInserted", function(evt){
4143     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4144       var tar = evt.target;
4145       if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
4146         tar._list = void 0;
4147         evt.currentTarget._list = null;
4148       }
4149       evt = tar = void 0;
4150     }
4151   }, false);
4152   if (_doc) {
4153     this._tar = _doc.createElement("v:group");
4154     this._doc = _doc; //_docプロパティは_texto関数内で使われる
4155   }
4156   this.addEventListener("DOMNodeInserted", function(evt){
4157     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4158       return; //強制終了させる
4159     }
4160     var tar = evt.target,
4161         tnext = tar.nextSibling,
4162         tpart = tar.parentNode._tar,
4163         isLast = true;
4164     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
4165       tpart.insertBefore(tar._tar, tnext._tar);
4166     } else if (tnext && !tnext._tar && tpart) {
4167       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
4168        *use要素や実体参照などは_tarプロパティがないことに注意
4169        */
4170       while (tnext) {
4171         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
4172           tpart.insertBefore(tar._tar, tnext._tar);
4173           isLast = false;
4174         } 
4175         tnext = tnext.nextSibling;
4176       }
4177       if (isLast) {
4178         tpart.appendChild(tar._tar);
4179       }
4180     } else if (!tnext && tpart) {
4181       tpart.appendChild(tar._tar);      
4182     }
4183     tnext = tpart = isLast = void 0;
4184     tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
4185     evt = tar = void 0;
4186   },false);
4187   return this;
4188 };
4189 SVGTextPositioningElement.constructor = SVGTextContentElement;
4190 SVGTextPositioningElement.prototype = new SVGTextContentElement();
4191 SVGTextPositioningElement.prototype._texto = function(evt) {
4192   var tar = evt.target,
4193       ti = tar.firstChild,
4194       ttp = tar._tar,
4195       style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
4196       n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
4197       tod = tar.ownerDocument.documentElement,
4198       ttpc = ttp, //ttpcはttpのキャッシュ
4199       tlen = tar.getComputedTextLength(),
4200       anchor = style.getPropertyValue("text-anchor"),
4201       tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
4202       ttps = ttp.style,
4203       ae = [];
4204   ttps.fontSize = n + "px";
4205   ttps.fontFamily = style.getPropertyValue("font-family");
4206   ttps.fontStyle = style.getPropertyValue("font-style");
4207   ttps.fontWeight = style.getPropertyValue("font-weight");
4208   /*ここでの変数jは前回ノードまでの総文字数*/
4209   for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
4210     if (ti) {
4211       if (!!ti._tars && (ti._tars.length !== 0)) {
4212         var ij = (i > j) ? i - j : j - i
4213         var sty = ti._tars[ij].style,
4214             p = tar.getStartPositionOfChar(i);
4215         sty.position = "absolute";
4216         if (tar._isYokogaki) {
4217           if (anchor === "middle") {
4218             p.x -= tlen / 2;
4219           } else if (anchor === "end") {
4220             p.x -= tlen;
4221           }
4222         } else {
4223           if (anchor === "middle") {
4224             p.y -= tlen / 2;
4225           } else if (anchor === "end") {
4226             p.y -= tlen;
4227           }
4228         }
4229         sty.left = p.x + "px";
4230         sty.top = p.y + "px";
4231         sty.width = "0px";
4232         sty.height = "0px";
4233         sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
4234         sty.lineHeight = n+10+ "px";
4235         sty.textDecoration = tedeco;
4236         sty.display = "none"
4237         ttp.appendChild(ti._tars[ij]);
4238         sty = p = void 0;
4239       }
4240       if (ti.nodeName === "#text") {
4241         if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
4242           j = j + ti.data.length;
4243           if (ti.parentNode.localName === "a") {
4244             ti =  ti.parentNode;
4245             ttp = ttpc;
4246           }
4247           ti = ti.nextSibling;
4248         }
4249       } else if (!!ti.getNumberOfChars) {
4250           if ((ti.getNumberOfChars()+j) <= i+1) {
4251             j = j + ti.getNumberOfChars();
4252             ti = ti.nextSibling;
4253           }
4254       } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4255         ttp = ti._tar;
4256         ti = ti.firstChild;
4257         ae[ae.length] = ti;
4258         i-=2;
4259       }
4260     }
4261   }
4262   var color = style.getPropertyValue("fill"),
4263       cursor = style.getPropertyCSSValue("cursor"),
4264       vis = style.getPropertyCSSValue("visibility"),
4265       disp = style.getPropertyCSSValue("display"),
4266       tts = tar._tar.style,
4267       tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
4268       ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
4269       tfti;
4270   if (color === "none"){
4271     tts.color = "transparent";
4272   } else if (color.indexOf("url") === -1) {
4273     tts.color = color;
4274   } else {
4275     tts.color = "black";
4276   }
4277   if (cursor && !cursor._isDefault) { //初期値でないならば
4278     var tc = cursor.cssText;
4279     tts.cursor = tc.split(":")[1];
4280     tc = void 0;
4281   }
4282   if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
4283       && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
4284     /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
4285      *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
4286      */
4287     for (var i=1, tli=tft.length;i<tli;++i) {
4288       tfti = tft[i];
4289       ttt += tfti.innerText;
4290       tfti.parentNode.removeChild(tfti);
4291     }
4292     //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
4293     if (tft[0] && tft[0].replaceChild) {
4294       tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
4295     }
4296     ttt = void 0;
4297   }
4298   var isRect = true,
4299       di = "block";
4300   if (ttp.lastChild) {
4301     if (ttp.lastChild.nodeName !== "rect") {
4302       isRect = false;
4303     }
4304   } else {
4305     isRect = false;
4306   }
4307   if (!isRect) {
4308     var backr = tar._doc.createElement("v:rect"),
4309         backrs = backr.style; //ずれを修正するためのもの
4310     backrs.width = backrs.height = "1px";
4311     backrs.left = backrs.top = "0px";
4312     backr.stroked = backr.filled = "false";
4313     ttp.appendChild(backr);
4314   }
4315   if (vis && !vis._isDefault) {
4316     tts.visibility = vis.cssText.split(":")[1];
4317   }
4318   /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
4319    *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
4320    */
4321   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4322     di = "none";
4323         } else if (disp && !disp._isDefault) {
4324     di = "block";
4325   }
4326   var jt = tar._tar.firstChild,
4327       j = 0;
4328   while (jt) {
4329     jt.style.display = di;
4330     jt = jt.nextSibling;
4331   }
4332   while (ae[j]) { //要素内部にあるa要素の処理
4333     for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
4334       ae[j]._tars[l].style.display = di;
4335     }
4336     l = void 0;
4337     ++j;
4338   }
4339   delete tar._cacheMatrix;
4340   ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
4341 };
4342
4343 function SVGTextElement(_doc) {
4344   SVGTextPositioningElement.apply(this, arguments);
4345   return this;
4346 };
4347 SVGTextElement.constructor = SVGTextPositioningElement;
4348 SVGTextElement.prototype = new SVGTextPositioningElement();
4349
4350 function SVGTSpanElement() {
4351   SVGTextElement.apply(this, arguments);
4352   return this;
4353 };
4354 SVGTSpanElement.constructor = SVGTextPositioningElement;
4355 SVGTSpanElement.prototype = new SVGTextPositioningElement();
4356
4357 function SVGTRefElement(_doc) {
4358   SVGTextPositioningElement.apply(this, arguments);
4359   this.addEventListener("DOMNodeInserted", function(evt){
4360     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4361       return; //強制終了させる
4362     }
4363     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
4364   }, false);
4365   this.addEventListener("S_Load", function(evt){
4366     var tar = evt.target,
4367         tic = tar._instance.firstChild;
4368     /*textノードのデータだけを処理*/
4369     while (tic && (tic.nodeName !== "#text")) {
4370       tic = tic.nextSibling;
4371     }
4372     tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
4373     evt.target = tar.parentNode;
4374     tar.parentNode._texto(evt);
4375     tar = tic = evtt = void 0;
4376   }, false);
4377   SVGURIReference.apply(this, arguments);
4378   return this;
4379 };
4380 SVGTRefElement.constructor = SVGTextPositioningElement;
4381 SVGTRefElement.prototype = new SVGTextPositioningElement();
4382
4383 function SVGTextPathElement() { 
4384   SVGTextContentElement.apply(this, arguments);
4385   /*readonly SVGAnimatedLength*/      this.startOffset;
4386   /*readonly SVGAnimatedEnumeration*/ this.method;
4387   /*readonly SVGAnimatedEnumeration*/ this.spacing;
4388   SVGURIReference.apply(this, arguments);
4389   return this;
4390 };
4391 SVGTextPathElement.constructor = SVGTextContentElement;
4392 SVGTextPathElement.prototype = new SVGTextContentElement();
4393
4394 (function(t){
4395     // textPath Method Types
4396   /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN   = 0;
4397   /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN     = 1;
4398   /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH     = 2;
4399     // textPath Spacing Types
4400   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN   = 0;
4401   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO     = 1;
4402   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT     = 2;
4403 })(SVGTextPathElement);
4404
4405 function SVGAltGlyphElement() { 
4406   SVGTextPositioningElement.apply(this, arguments);
4407   /*DOMString*/ this.glyphRef;
4408   /*DOMString*/ this.format;
4409   SVGURIReference.apply(this, arguments);
4410   return this;
4411 };
4412 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
4413 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
4414
4415 function SVGAltGlyphDefElement() {
4416   SVGElement.apply(this, arguments);
4417   return this;
4418 };
4419 SVGAltGlyphDefElement.constructor = SVGElement;
4420 SVGAltGlyphDefElement.prototype = new SVGElement();
4421
4422 function SVGAltGlyphItemElement() {
4423   SVGElement.apply(this, arguments);
4424   return this;
4425 };
4426 SVGAltGlyphItemElement.constructor = SVGElement;
4427 SVGAltGlyphItemElement.prototype = new SVGElement();
4428
4429 function SVGGlyphRefElement() { 
4430   SVGElement.apply(this, arguments);
4431   /*DOMString*/ this.glyphRef;
4432   /*DOMString*/ this.format;
4433   /*float*/    this.x;
4434   /*float*/    this.y;
4435   /*float*/    this.dx;
4436   /*float*/    this.dy;
4437   SVGURIReference.apply(this, arguments);
4438   return this;
4439 };
4440 SVGGlyphRefElement.constructor = SVGElement;
4441 SVGGlyphRefElement.prototype = new SVGElement();
4442
4443 function SVGPaint() { 
4444   SVGColor.apply(this, arguments);
4445   return this;
4446 };
4447
4448 (function(t){
4449 t.constructor = SVGColor;
4450 t.prototype = new SVGColor();
4451     // Paint Types
4452   /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN               = 0;
4453   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR              = 1;
4454   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR     = 2;
4455   /*unsigned short*/ t.SVG_PAINTTYPE_NONE                  = 101;
4456   /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR          = 102;
4457   /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE              = 103;
4458   /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR      = 104;
4459   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR          = 105;
4460   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
4461   /*unsigned short*/ t.SVG_PAINTTYPE_URI                   = 107;
4462   /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
4463   /*readonly DOMString*/      t.prototype.uri = null;
4464 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
4465   this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
4466 };
4467 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
4468   if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
4469     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
4470   }
4471   this.uri = uri;
4472   this.paintType = paintType;
4473   if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4474     paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
4475   }
4476   this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
4477 };
4478 //                    raises( SVGException );
4479 t = void 0;
4480 })(SVGPaint);
4481
4482 function SVGMarkerElement(){ 
4483   SVGElement.apply(this);
4484   var sl = SVGAnimatedLength;
4485   /*readonly SVGAnimatedLength*/      this.refX = new sl();
4486   /*readonly SVGAnimatedLength*/      this.refY = new sl();
4487   /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
4488   /*readonly SVGAnimatedLength*/      this.markerWidth = new sl();
4489   /*readonly SVGAnimatedLength*/      this.markerHeight = new sl();
4490   sl = void 0;
4491   /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
4492   /*readonly SVGAnimatedAngle*/       this.orientAngle = new SVGAnimatedAngle();
4493     //SVGFitToViewBoxのインターフェースを用いる
4494   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
4495   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
4496   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
4497   return this;
4498 };
4499 (function(t){
4500     // Marker Unit Types
4501   /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN        = 0;
4502   /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
4503   /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH    = 2;
4504     // Marker Orientation Types
4505   /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN      = 0;
4506   /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO         = 1;
4507   /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE        = 2;
4508 t.constructor = SVGElement;
4509 t.prototype = new SVGElement();
4510 /*void*/ t.prototype.setOrientToAuto = function() {
4511   
4512 };
4513 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
4514   
4515 };
4516 })(SVGMarkerElement);
4517 function SVGColorProfileElement() { 
4518   SVGElement.apply(this);
4519   /*DOMString*/      this._local;
4520                          // raises DOMException on setting
4521                        // (NOTE: is prefixed by "_"
4522                        // as "local" is an IDL keyword. The
4523                        // prefix will be removed upon processing)
4524   /*DOMString*/      this.name;
4525   /*unsigned short*/ this.renderingIntent;
4526   SVGURIReference.apply(this, arguments);
4527   return this;
4528 };
4529 SVGColorProfileElement.constructor = SVGElement;
4530 SVGColorProfileElement.prototype = new SVGElement();
4531
4532 function SVGColorProfileRule() { 
4533   SVGCSSRule.apply(this);
4534   /*DOMString*/      this.src;
4535   /*DOMString*/      this.name;
4536   /*unsigned short*/ this.renderingIntent;
4537   return this;
4538 };
4539 SVGColorProfileRule.constructor = SVGCSSRule;
4540 SVGColorProfileRule.prototype = new SVGCSSRule();
4541
4542 function SVGGradientElement() { 
4543   SVGElement.apply(this);
4544   SVGURIReference.apply(this);
4545   /*readonly SVGAnimatedEnumeration*/   this.gradientUnits = new SVGAnimatedEnumeration();
4546   /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
4547   /*readonly SVGAnimatedEnumeration*/   this.spreadMethod = new SVGAnimatedEnumeration();
4548   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4549     var grad = evt.target,
4550         ele = evt._tar,
4551         t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
4552         grad2 = grad,
4553         href, stops, length,
4554         color = [],
4555         colors = [],
4556         opacity = [],
4557         stop, sstyle, ci;
4558     if (!ele || !grad) { //まだ、path要素などが設定されていない場合
4559       grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
4560       return;
4561     }
4562     if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
4563       grad2 = grad._instance;
4564     }
4565     stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
4566     if (!stops) {
4567       ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
4568       return;
4569     }
4570     length = stops.length;
4571     for (var i = 0; i < length; ++i) {
4572       stop = stops[i];
4573       sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
4574       ci = sstyle.getPropertyCSSValue("stop-color");
4575       if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
4576         /*再度、設定。css.jsのsetPropertyを参照*/
4577         sstyle.setProperty("color", sstyle.getPropertyValue("color"));
4578       }
4579       color[i] =  "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
4580       colors[i] = stop.offset.baseVal + " " + color[i];
4581       opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
4582     }
4583     ele["method"] = "none";
4584     ele["color"] = color[0];
4585     ele["color2"] = color[length-1];
4586     ele["colors"] = colors.join(",");
4587     // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
4588     ele["opacity"] = opacity[length-1]+ "";
4589     ele["o:opacity2"] = opacity[0]+ "";
4590     /*SVGRadialGradientElementインターフェースで利用する*/
4591     grad._color = color;
4592     var gt = grad2.getAttributeNS(null, "gradientTransform");
4593     if (gt) {
4594       grad.setAttributeNS(null, "transform", gt);
4595     }
4596     grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
4597   }, false);
4598   return this;
4599 };
4600 SVGGradientElement.constructor = SVGElement;
4601 SVGGradientElement.prototype = new SVGElement();
4602     // Spread Method Types
4603   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
4604   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD     = 1;
4605   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
4606   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT  = 3;
4607
4608 function SVGLinearGradientElement() { 
4609   SVGGradientElement.apply(this);
4610   var sl = SVGAnimatedLength;
4611   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
4612   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
4613   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
4614   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
4615   sl = void 0;
4616   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4617     var grad = evt.target, ele = evt._tar, angle = 270;
4618     if (!!!ele) { //まだ、path要素などが設定されていない場合
4619       return;
4620     }
4621     var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
4622     var fontSize = parseFloat(style.getPropertyValue("font-size"));
4623     grad.x1.baseVal._emToUnit(fontSize);
4624     grad.y1.baseVal._emToUnit(fontSize);
4625     grad.x2.baseVal._emToUnit(fontSize);
4626     grad.y2.baseVal._emToUnit(fontSize);
4627     angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
4628     if (angle >= 360) {
4629       angle -= 360;
4630     }
4631     ele.setAttribute("type", "gradient");
4632     ele.setAttribute("angle", angle + "");
4633     evt = ele = grad = angle = style = fontSize = void 0;
4634   }, false);
4635   return this;
4636 };
4637 SVGLinearGradientElement.constructor = SVGGradientElement;
4638 SVGLinearGradientElement.prototype = new SVGGradientElement();
4639
4640 function SVGRadialGradientElement(_doc) { 
4641   SVGGradientElement.apply(this);
4642   var sl = SVGAnimatedLength;
4643   /*readonly SVGAnimatedLength*/ this.cx = new sl();
4644   /*readonly SVGAnimatedLength*/ this.cy = new sl();
4645   /*readonly SVGAnimatedLength*/ this.r = new sl();
4646   /*readonly SVGAnimatedLength*/ this.fx = new sl();
4647   /*readonly SVGAnimatedLength*/ this.fy = new sl();
4648   sl = void 0;
4649   this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
4650   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4651     var grad = evt.target,
4652         ele = evt._tar,
4653         tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
4654     if (!!!ele) { //まだ、path要素などが設定されていない場合
4655       return;
4656     }
4657     ele.setAttribute("type", "gradientTitle");
4658     ele.setAttribute("focus", "100%");
4659     ele.setAttribute("focusposition", "0.5 0.5");
4660     if (tar.localName === "rect") {
4661       /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
4662        *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
4663        */
4664       var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
4665           fontSize = parseFloat(style.getPropertyValue("font-size"));
4666       grad.cx.baseVal._emToUnit(fontSize);
4667       grad.cy.baseVal._emToUnit(fontSize);
4668       grad.r.baseVal._emToUnit(fontSize);
4669       grad.fx.baseVal._emToUnit(fontSize);
4670       grad.fy.baseVal._emToUnit(fontSize);
4671       var cx = grad.cx.baseVal.value,
4672           cy = grad.cy.baseVal.value,
4673           r = grad.r.baseVal.value,
4674           mr = Math.round,
4675           rx, ry;
4676       rx = ry = r;
4677       var tarrect = tar.getBBox(),
4678           vi = tar.ownerDocument.documentElement.viewport,
4679           el = mr(vi.width),
4680           et = mr(vi.height),
4681           er = 0,
4682           eb = 0,
4683           units = grad.getAttributeNS(null, "gradientUnits");
4684       if (!units || units === "objectBoundingBox") {
4685         //%の場合は小数点に変換(10% -> 0.1)
4686         cx = cx > 1 ? cx/100 : cx;
4687         cy = cy > 1 ? cy/100 : cy;
4688         r = r > 1 ? r/100 : r;
4689         //要素の境界領域を求める(四隅の座標を求める)
4690         var nx = tarrect.x,
4691             ny = tarrect.y,
4692             wid = tarrect.width,
4693             hei = tarrect.height;
4694         cx = cx*wid + nx;
4695         cy = cy*hei + ny;
4696         rx = r*wid;
4697         ry = r*hei;
4698         nx = ny = wid = hei = void 0;
4699       }
4700       var matrix = tar.getScreenCTM().multiply(grad.getCTM());
4701       el = cx - rx;
4702       et = cy - ry;
4703       er = cx + rx;
4704       eb = cy + ry;
4705       var rrx = rx * 0.55228,
4706           rry = ry * 0.55228,
4707           list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"];
4708       for (var i = 0, lili = list.length; i < lili;) {
4709         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
4710           ++i;
4711           continue;
4712         }
4713         var p = grad.ownerDocument.documentElement.createSVGPoint();
4714         p.x = parseFloat(list[i]);
4715         p.y = parseFloat(list[i+1]);
4716         var pmt = p.matrixTransform(matrix);
4717         list[i] = mr(pmt.x);
4718         i++;
4719         list[i] = mr(pmt.y);
4720         i++;
4721         p = pmt = void 0;
4722       }
4723       var ellipse = list.join(" "),
4724           outline = _doc.getElementById("_NAIBU_outline"),
4725           background = _doc.createElement("div"),
4726           bstyle = background.style;
4727       bstyle.position = "absolute";
4728       bstyle.display = "inline-block";
4729       var w = vi.width,
4730           h = vi.height;
4731       bstyle.textAlign = "left";
4732       bstyle.top = "0px";
4733       bstyle.left = "0px";
4734       bstyle.width = w+ "px";
4735       bstyle.height = h+ "px";
4736       outline.appendChild(background);
4737       bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
4738       background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
4739       var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>',
4740           data = tar._tar.path.value;
4741       background.innerHTML = '<v:shape style="display:inline-block; position:relative; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +data+ '" stroked="f" fillcolor="' +grad._color[grad._color.length-1]+ '" ></v:shape>';
4742       background.filters[0].apply();
4743       background.innerHTML = circle;
4744       background.filters[0].play();
4745       tar._tar.parentNode.insertBefore(background, tar._tar);
4746       tar._tar.filled = "false";
4747       ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
4748     } else if (!ele.parentNode){
4749       tar._tar.appendChild(ele);
4750     }
4751     evt = tar = ele = gard = void 0;
4752   }, false);
4753   return this;
4754 };
4755 SVGRadialGradientElement.constructor = SVGGradientElement;
4756 SVGRadialGradientElement.prototype = new SVGGradientElement();
4757
4758 function SVGStopElement() { 
4759   SVGElement.apply(this, arguments);
4760   /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
4761   this.addEventListener("DOMAttrModified", function(evt) {
4762     if (evt.attrName === "offset") {
4763       evt.target.offset.baseVal = parseFloat(evt.newValue);
4764     }
4765     evt = void 0;
4766   }, false);
4767   return this;
4768 };
4769 SVGStopElement.constructor = SVGElement;
4770 SVGStopElement.prototype = new SVGElement();
4771
4772 function SVGPatternElement() { 
4773   SVGElement.apply(this);
4774   var sl = SVGAnimatedLength;
4775   /*readonly SVGAnimatedEnumeration*/   this.patternUnits = new SVGAnimatedEnumeration();
4776   /*readonly SVGAnimatedEnumeration*/   this.patternContentUnits = new SVGAnimatedEnumeration();
4777   /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
4778   /*readonly SVGAnimatedLength*/        this.x = new sl();
4779   /*readonly SVGAnimatedLength*/        this.y = new sl();
4780   /*readonly SVGAnimatedLength*/        this.width = new sl();
4781   /*readonly SVGAnimatedLength*/        this.height = new sl();
4782   sl = void 0;
4783   SVGURIReference.apply(this, arguments);
4784     //SVGFitToViewBoxのインターフェースを用いる
4785   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
4786   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
4787   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
4788   return this;
4789 };
4790 SVGPatternElement.constructor = SVGElement;
4791 SVGPatternElement.prototype = new SVGElement();
4792
4793 function SVGClipPathElement() { 
4794   SVGElement.apply(this, arguments);
4795   /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
4796   return this;
4797 };
4798 SVGClipPathElement.constructor = SVGElement;
4799 SVGClipPathElement.prototype = new SVGElement();
4800
4801 function SVGMaskElement() { 
4802   SVGElement.apply(this);
4803   var sl = SVGAnimatedLength;
4804   /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
4805   /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
4806   /*readonly SVGAnimatedLength*/      this.x = new sl();
4807   /*readonly SVGAnimatedLength*/      this.y = new sl();
4808   /*readonly SVGAnimatedLength*/      this.width = new sl();
4809   /*readonly SVGAnimatedLength*/      this.height = new sl();
4810   sl = void 0;
4811   return this;
4812 };
4813 SVGMaskElement.constructor = SVGElement;
4814 SVGMaskElement.prototype = new SVGElement();
4815
4816 function SVGFilterElement() { 
4817   SVGElement.apply(this);
4818   var sl = SVGAnimatedLength;
4819   /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
4820   /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
4821   /*readonly SVGAnimatedLength*/      this.x = new sl();
4822   /*readonly SVGAnimatedLength*/      this.y = new sl();
4823   /*readonly SVGAnimatedLength*/      this.width = new sl();
4824   /*readonly SVGAnimatedLength*/      this.height = new sl();
4825   sl = void 0;
4826   /*readonly SVGAnimatedInteger*/     this.filterResX = new SVGAnimatedInteger();
4827   /*readonly SVGAnimatedInteger*/     this.filterResY = new SVGAnimatedInteger();
4828   SVGURIReference.apply(this, arguments);
4829   //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
4830   return this;
4831 };
4832 SVGFilterElement.constructor = SVGElement;
4833 SVGFilterElement.prototype = new SVGElement();
4834
4835 function SVGFilterPrimitiveStandardAttributes(ele) { 
4836   SVGStylable.apply(this, arguments);
4837   this._tar = ele;
4838   var sl = SVGAnimatedLength;
4839   /*readonly SVGAnimatedLength*/ this.x = new sl();
4840   /*readonly SVGAnimatedLength*/ this.y = new sl();
4841   /*readonly SVGAnimatedLength*/ this.width = new sl();
4842   /*readonly SVGAnimatedLength*/ this.height = new sl();
4843   /*readonly SVGAnimatedString*/ this.result = new sl();
4844   sl = void 0;
4845   };
4846 SVGFilterPrimitiveStandardAttributes.constructor = SVGStylable;
4847 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
4848
4849 function SVGFEBlendElement() {
4850   SVGElement.apply(this, arguments);
4851   /*readonly SVGAnimatedString*/      this.in1 = new SVGAnimatedString();
4852   /*readonly SVGAnimatedString*/      this.in2 = new SVGAnimatedString();
4853   /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
4854   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
4855   return this;
4856 };
4857 SVGFEBlendElement.constructor = SVGElement;
4858 SVGFEBlendElement.prototype = new SVGElement();
4859     // Blend Mode Types
4860   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN  = 0;
4861   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL   = 1;
4862   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
4863   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN   = 3;
4864   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN   = 4;
4865   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN  = 5;
4866
4867 function SVGFEGaussianBlurElement() { 
4868   SVGElement.apply(this, arguments);
4869   /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
4870   /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
4871   /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
4872   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
4873   return this;
4874 };
4875 SVGFEGaussianBlurElement.constructor = SVGElement;
4876 SVGFEGaussianBlurElement.prototype = new SVGElement();
4877 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
4878   
4879 };
4880
4881 function SVGCursorElement() { 
4882   SVGElement.apply(this, arguments);
4883   /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
4884   /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
4885   SVGURIReference.apply(this, arguments);
4886   return this;
4887 };
4888 SVGCursorElement.constructor = SVGElement;
4889 SVGCursorElement.prototype = new SVGElement();
4890
4891 function SVGAElement(_doc) {
4892   SVGElement.apply(this);
4893   this._tar = _doc.createElement("a");
4894   _doc = void 0;
4895   /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
4896   this.target.baseVal = "_self";
4897   this.addEventListener("DOMAttrModified", function(evt){
4898     var tar = evt.target;
4899     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4900       return; //強制終了させる
4901     }
4902     if (evt.attrName === "target") {
4903       tar.target.baseVal = evt.newValue;
4904     } else if (evt.attrName === "xlink:title") {
4905       tar._tar.setAttribute("title", evt.newValue);
4906     }
4907     evt = void 0;
4908   }, false);
4909   this.addEventListener("DOMNodeInserted", function(evt){
4910     var tar = evt.target;
4911     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4912       return; //強制終了させる
4913     }
4914     if (tar.nextSibling) {
4915       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
4916         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
4917       }
4918     } else if (!!tar.parentNode._tar){
4919       tar.parentNode._tar.appendChild(tar._tar);
4920     }
4921     var txts = tar._tar.style;
4922     txts.cursor = "hand";
4923     txts.left = "0px";
4924     txts.top = "0px";
4925     txts.textDecoration = "none";
4926     txts = void 0;
4927     var t = tar.target.baseVal;
4928     var st = "replace";
4929     if (t === "_blank") {
4930       st = "new";
4931     }
4932     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
4933     tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
4934     tar = evt = void 0;
4935   }, false);
4936   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4937     var tar = evt.target;
4938     if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
4939       var txts = tar._tar.style;
4940       txts.cursor = "hand";
4941       txts.textDecoration = "none";
4942       txts = void 0;
4943     }
4944     tar = evt = void 0;
4945     return; //強制終了させる
4946   }, true);
4947   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4948     var tar = evt.target;
4949     tar._tar.setAttribute("target", tar.target.baseVal);
4950     if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
4951       tar.addEventListener("click", function(evt){
4952           var tar = evt.target,
4953               sd = document.body,
4954               ob, nd;
4955           sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
4956           if (tar.target.baseVal === "_self") {
4957             nd = tar.ownerDocument._iframe;
4958             nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
4959             ob = nd.nextSibling;
4960             if (ob && (ob.tagName === "OBJECT")) {
4961               nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
4962               nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
4963               nd.parentNode.removeChild(ob);
4964             }
4965             ob = NAIBU._search([nd.previousSibling]);
4966             nd.parentNode.removeChild(nd);
4967           } else {
4968             sd.appendChild(sd.lastChild.firstChild);
4969             while (sd.firstChild !== sd.lastChild) {     //オブジェクト要素以外を除去
4970               sd.removeChild(sd.firstChild);
4971             }
4972             ob = NAIBU._search([sd.lastChild]);
4973           }
4974           NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
4975           evt.preventDefault();
4976           ob._next = {
4977             _init: (function (ob) {
4978               return (function(){
4979                 document.title = ob.getSVGDocument().title;
4980                 ob = void 0;
4981               });
4982             })(ob)
4983           };
4984           ob._init();
4985           sd = ob = nd = void 0;
4986       }, false);
4987     }
4988     tar = void 0;
4989   }, false);
4990   SVGURIReference.apply(this, arguments);
4991   return this;
4992 };
4993 SVGAElement.constructor = SVGElement;
4994 SVGAElement.prototype = new SVGElement();
4995
4996 function SVGViewElement() { 
4997   SVGElement.apply(this, arguments);
4998   /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
4999       //SVGFitToViewBoxのインターフェースを用いる
5000   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
5001   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
5002   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
5003   return this;
5004 };
5005 SVGViewElement.constructor = SVGElement;
5006 SVGViewElement.prototype = new SVGElement();
5007
5008 function SVGScriptElement() { 
5009   SVGElement.apply(this);
5010   /*DOMString*/ this.type;
5011   SVGURIReference.apply(this, arguments);
5012   this.addEventListener("DOMAttrModified", function(evt){
5013     if (evt.attrName === "type") {
5014       evt.target.type = evt.newValue;
5015     }
5016     evt = void 0;
5017   }, false);
5018   this.addEventListener("S_Load", function(evt){
5019     var tar = evt.target, script = tar._text;
5020     var tod = tar.ownerDocument;
5021     NAIBU._temp_doc = tod;
5022     script = script.replace(/function\s+(\w+)/g, "$1 = function");
5023     script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
5024     try {
5025       eval(script);
5026     } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
5027       script = script.replace(/function\(document\){/, "function() {");
5028       eval(script);
5029     }
5030     tar = evt = script = void 0;
5031   }, false);
5032   this.addEventListener("DOMNodeInserted", function(evt){
5033     var tar = evt.target;
5034     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5035       if (tar.nodeName === "#cdata-section") {
5036         evt.currentTarget._text = tar.data;
5037       }
5038       return;
5039     }
5040     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5041       var tar = evt.target;
5042       if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
5043         var evtt = tar.ownerDocument.createEvent("SVGEvents");
5044         evtt.initEvent("S_Load", false, false);
5045         evt.currentTarget.dispatchEvent(evtt);
5046       }
5047       tar = evt = void 0;
5048     }, false);
5049   }, false);
5050   return this;
5051 };
5052 SVGScriptElement.constructor = SVGElement;
5053 SVGScriptElement.prototype = new SVGElement();
5054
5055 function SVGEvent() {
5056   Event.apply(this, arguments);
5057   return this;
5058 };
5059 SVGEvent.constructor = Event;
5060 SVGEvent.prototype = new Event();
5061
5062 function SVGZoomEvent() { 
5063   UIEvent.apply(this, arguments);
5064   /*readonly SVGRect*/  this.zoomRectScreen = new SVGRect();
5065   /*readonly float*/    this.previousScale = 1;
5066   /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
5067   /*readonly float*/    this.newScale = 1;
5068   /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
5069   return this;
5070 };
5071 SVGZoomEvent.constructor = UIEvent;
5072 SVGZoomEvent.prototype = new UIEvent();
5073
5074 function SVGAnimationElement(es) {
5075   if (!!es) {
5076     return this;
5077   }
5078   SVGElement.apply(this);
5079   /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
5080    *styleのsetPropertyメソッドを無効化させておく必要がある
5081    */
5082   this.style.setProperty = function(){};
5083   this._tar = null;
5084   /*readonly SVGElement*/ this.targetElement;
5085   /*それぞれのプロパティは、_を除いた属性に対応している*/
5086   this._begin = this._end = this._repeatCount = this._repeatDur = null;
5087   this._dur = "indefinite";
5088   this._currentFrame = 0;
5089   /*_maxCountはrepeatCount属性で指定された数値
5090    *_maxDurはrepeatDur属性で指定された数値
5091    */
5092   this._maxCount = 0;
5093   this._maxDur = 0;
5094   /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
5095   this._isRepeat = false;
5096   this._numRepeat = 0;
5097   /*_startと_finishプロパティはミリ秒数を収納する。
5098    *_startはアニメ開始時の秒数。_finishはアニメ終了時の秒数。
5099    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
5100    */
5101   this._start = this._finish = null;
5102   this._from = this._to = this._values = this._by = null;
5103   this._keyTimes = null;
5104   this.addEventListener("beginEvent", function(evt) {
5105     try {
5106       var tar = evt.target,
5107       be = tar._start,
5108       dur = tar.getSimpleDuration(),
5109       durv = tar._dur,
5110       end = tar._finish,
5111       endv= tar._end,
5112       td = tar._repeatDur,
5113       tc = tar._repeatCount,
5114       ac = 0;
5115       /*Activate Duration (活性持続時間と呼ぶことにする)を計算
5116        *計算方法は以下を参照のこと
5117        *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
5118        *3.3.4. Computing the active duration
5119        */
5120       if ((td === "indefinte") || (tc === "indefinte")) {
5121         if (endv) {
5122           ac = end - begin;
5123         } else {
5124           /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/
5125         }
5126       } else if (durv === "indefinte") {
5127         if (!tc && !endv) {
5128           /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/   
5129         } else if (tc && !endv) {
5130           ac = tar._getOffset(td);
5131         } else if (!tc && endv) {
5132           ac = end - begin;
5133         } else {
5134           ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
5135         }
5136       } else if (durv && !td && !tc && !endv) {
5137         ac = dur;
5138       } else if (durv && !td && tc && !endv) {
5139         ac = dur * (+tc);
5140       } else if (durv && td && !tc && !endv) {
5141         ac = tar._getOffset(td);
5142       } else if (durv && !td && !tc && endv) {
5143         ac = (dur > (end - begin)) ? dur : (end - begin);
5144       } else if (durv && td && tc && !endv) {
5145         ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
5146       } else if (durv && td && tc && endv) {
5147         ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
5148       } else if (durv && td && !tc && endv) {
5149         ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
5150       } else if (durv && !td && tc && endv) {
5151         ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
5152       }
5153     } catch (e) {
5154       throw new DOMException(DOMException.INVALID_STATE_ERR);
5155     }
5156     tar.endElementAt(ac);
5157   }, false);
5158   this.addEventListener("DOMAttrModified", function(evt){
5159     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5160       return;
5161     }
5162     var tar = evt.target,
5163         name = evt.attrName,
5164         evtv = evt.newValue;
5165     if (name === "begin") {
5166       tar._begin = evtv;
5167     } else if (name === "end") {
5168       tar._end = evtv;
5169     } else if (name === "dur") {
5170       tar._dur = evtv;
5171     } else if (name === "repeatCount") {
5172       tar._maxCount = parseFloat(evtv);
5173       tar._repeatCount = evtv;
5174       tar._isRepeat = true;
5175     } else if (name === "repeatDur") {
5176       tar._maxDur = parseFloat(evtv);
5177       tar._repeatCount = evtv;
5178       tar._isRepeat = true;
5179     } else if (name === "from") {
5180       tar._from = evtv;
5181     } else if (name === "to") {
5182       tar._to = evtv;
5183     } else if (name === "values") {
5184       tar._values = evtv.split(";");
5185     } else if (name === "by") {
5186       tar._by = evtv;
5187     } else if (name === "keyTimes") {
5188       var s = evtv.split(";");
5189       tar._keyTimes = []; //_keyTimesプロパティを初期化
5190       for (var i=0;i<s.length;++i) {
5191         tar._keyTimes[i] = parseFloat(s[i]);
5192       }
5193       s = void 0;
5194     }
5195     evt = evtv = void 0;
5196   }, false);
5197   this.addEventListener("DOMNodeInserted", function(evt){
5198     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5199       return; //強制終了させる
5200     }
5201     var tar = evt.target;
5202     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5203       var tar = evt.target;
5204       /*以降の場合分けルールに関しては、下記の仕様を参照
5205        *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
5206        */
5207       if (tar._values) {
5208       } else if (tar._from && tar._to) {
5209         tar._values = [tar._from, tar._to];
5210       } else if (tar._from && tar._by) {
5211         var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
5212         tar._values = [tar._from, n+tanni[0]];
5213       } else if (tar._to) {
5214         tar._values = [null, tar._to];
5215       } else if (tar._by) {
5216         tar._values = [null, null, tar._by];
5217       } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
5218         /*アニメーションの効果が出ないように調整する
5219          *SMILアニメーションの仕様を参照
5220          *
5221          *>if none of the from, to, by or values attributes are specified, the animation will have no effect
5222          *「3.2.2. Animation function values」より引用
5223          *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
5224          */
5225         return this;
5226       }
5227       /*begin属性とend属性を処理する*/
5228       var that = tar,
5229           timing = function(val, name, offset) {
5230         /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
5231          *まず、idを検出するためのsearcIdローカル関数を作る
5232          */
5233         var searchId = function () {
5234               var n = val.indexOf(".");
5235               if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
5236                 return (val.slice(0, n));
5237               }
5238               n = nn = void 0;
5239               return "";
5240             },
5241             id;
5242         /*
5243          *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
5244          */
5245         if (isFinite(parseFloat(val))) { //1) offset-valueの場合
5246           that[name](offset);
5247         } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
5248           var inte = parseFloat(val.slice(7)),
5249               ds = function (evt) {
5250                 if (inte === evt.target._numRepeat) {
5251                   that[name](offset);
5252                 }
5253               };
5254               id = searchId();
5255               if (id) {
5256                 that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
5257               } else {
5258                 that.addEventListener("repeatEvent", ds);
5259               }
5260         } else if ((/\.(begin|end)/).test(val)) { //3) syncbase-valueの場合
5261           id = searchId();
5262           if (id) {
5263             var ds = function (evt) {
5264                   that[name](offset);
5265                 },
5266                 ev = "";
5267             if (RegExp.$1 === "begin") {
5268               ev = "beginEvent";
5269             } else if (RegExp.$1 === "end") {
5270               ev = "endEvent";
5271             }
5272             that.ownerDocument.getElementById(id).addEventListener(ev, ds);
5273           }
5274         } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
5275           
5276         } else if (val === "indefinte") { //5) indefinteの場合
5277         } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
5278           
5279         } else { //7) event-valueの場合
5280           id = searchId();
5281           var ds = function (evt) {
5282                that[name](offset);
5283               };
5284           if (id && val.match(/\.([a-z]+)/i)) {
5285             that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
5286           } else if (val){
5287             that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
5288           }
5289         }
5290         val = searchId = id = void 0;
5291       };
5292       if (tar._begin) {
5293         timing(tar._begin, "beginElementAt", tar._getOffset(tar._begin));
5294       } else {
5295         tar.beginElement();
5296       }
5297       tar._end && timing(tar._end, "endElementAt", tar._getOffset(tar._end));
5298       that = void 0;
5299       if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
5300         tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
5301       } else {
5302         tar.targetElement = tar.parentNode;
5303       }
5304       evt = tar = void 0;
5305     }, false);
5306     evt = tar = void 0;
5307   }, false);
5308   return this;
5309 };
5310 SVGAnimationElement.constructor = SVGElement;
5311 SVGAnimationElement.prototype = new SVGElement();
5312 /*以下のメソッド(beginElementなど)については、
5313  *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
5314  */
5315 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
5316   var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
5317   evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
5318   this.dispatchEvent(evt);
5319 };
5320 /*void*/ SVGAnimationElement.prototype.endElement = function() {
5321   var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
5322   evt.initTimeEvent("endEvent", ttd.defaultView, 0);
5323   this.dispatchEvent(evt);
5324 };
5325 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
5326   var ntc = this.ownerDocument.documentElement.getCurrentTime();
5327   this._start = offset + ntc;
5328 };
5329 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
5330   var ntc = this.ownerDocument.documentElement.getCurrentTime();
5331   this._finish = offset + ntc;
5332 };
5333 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
5334 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?;?/;
5335 SVGAnimationElement.prototype._unit = {
5336     "h"   : 2880000,
5337     "min" : 48000,
5338     "s"   : 800,
5339     "ms"  : 0.8
5340 };
5341 /*_getOffsetメソッド
5342  * どれだけズレの時間があるかを計測するメソッド
5343  *tに数値が使われていないときは0を返す
5344  *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
5345  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
5346  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
5347  ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
5348  */
5349 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
5350   var n = parseFloat((t.match(this._timeRegExp) || "0")),
5351       offset = 0;
5352   if (isFinite(n) && RegExp.$1) {
5353     var offset = n * this._unit[RegExp.$1]
5354   } else if (isFinite(n)) {
5355     offset = n;
5356   }
5357   n = t = void 0;
5358   return offset;
5359 };
5360
5361 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
5362   if (this._start || (this._start === 0)) {
5363     return (this._start);
5364   } else {
5365     throw new DOMException(DOMException.INVALID_STATE_ERR);
5366   }
5367 };
5368 /*getCurrentTimeメソッド
5369  *現在の時間コンテナ内での時刻であり、
5370  *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
5371  */
5372 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
5373   return (this._currentFrame * 125 * 0.8);
5374 };
5375 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
5376   if (!this._dur && !this._finish && (this._dur === "indefinte")) {
5377     throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
5378   } else {
5379     return (this._getOffset(this._dur));
5380   }
5381 };
5382                     //raises( DOMException );
5383 NAIBU.Time = {
5384   currentFrame : 0,
5385   Max : 7000,
5386   start : function() {
5387   if (NAIBU.Clip.length > 0) {
5388     screen.updateInterval = 42; //24fpsとして描画処理
5389     window.onscroll = function () {
5390       screen.updateInterval = 0;
5391       screen.updateInterval = 42;
5392     }
5393     NAIBU.stop = setInterval( (function() {
5394 /*      try{*/
5395         var ntc = NAIBU.Time.currentFrame,
5396             nc = NAIBU.Clip,
5397             s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
5398         if (ntc > NAIBU.Time.Max) {
5399           clearInterval(NAIBU.stop);
5400         }
5401         nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
5402         for (var i=0,ncli=nc.length;i<ncli;++i) {
5403           var nci = nc[i]
5404               s2 = s + 100,
5405               s1 = s - 100;
5406           if ((nci._start || (nci._start === 0)) && (s1 <= nci._start && nci._start < s)) {
5407             if (nci.getCurrentTime() > 0) {
5408               /*アニメーションの最中で、beginEventが起きるときは、endEventが前もって起こされる。SVG1.1の仕様を参照
5409                * 
5410                * 19.4.2 Interface TimeEvent
5411                * Note that if an element is restarted while it is currently playing, the element will raise an end event and another begin event, as the element restarts. 
5412                * 
5413                * http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
5414                * 
5415                */
5416               nci.endElement();
5417               nci._currentFrame = 0;
5418             }
5419             nci.beginElement();
5420           }
5421           if (nci._isRepeat && (nci.getCurrentTime() !== 0) && ((nci.getSimpleDuration() % s) === 0)) {
5422             var ttd = nci.ownerDocument,
5423                 evt = ttd.createEvent("TimeEvents");
5424             ++nci._numRepeat;
5425             evt.initTimeEvent("repeatEvent", ttd.defaultView, nci._numRepeat);
5426             nci.dispatchEvent(evt);
5427             ttd = evt = void 0;
5428           }
5429           if ((nci._finish || (nci._finish === 0)) && (s < nci._finish && nci._finish <= s2) && (nci.getCurrentTime() !== 0)) {
5430             nci.endElement();
5431             nci._currentFrame = 0;
5432           }
5433           if (nci._frame) {
5434             nci._currentFrame++;
5435             nci._frame();
5436           }
5437         }
5438         ++NAIBU.Time.currentFrame;
5439         nci = s1 = s2 = void 0;
5440 /*      } catch (e) {
5441         stlog.add(e, 4157);
5442       }*/
5443         }),
5444          1
5445       );
5446     } else {
5447       window.onscroll = function () {
5448         screen.updateInterval = 0;
5449                window.onscroll = NAIBU.emptyFunction;
5450       }
5451     }
5452  }
5453 };
5454 NAIBU.Clip = [];
5455   
5456 function SVGAnimateElement(){
5457   SVGAnimationElement.apply(this);
5458   /*NAIBU.Clipについては、NAIBU.Timeで使う
5459    *くわしくはNAIBU.Time.start関数のコードを参照
5460    */
5461   NAIBU.Clip[NAIBU.Clip.length] = this;
5462   /*_valueListプロパティは、
5463    *機械が理解できる形で保管されているvalueの値の配列リスト
5464    */
5465   this._valueList = [];
5466   this._isDiscrete = false;
5467   this.addEventListener("DOMAttrModified", function(evt){
5468     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5469       return; //強制終了させる
5470     }
5471     if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
5472       evt.target._isDiscrete = true;
5473     }
5474   }, false);
5475   this.addEventListener("DOMNodeInserted", function(evt){
5476     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5477       return; //強制終了させる
5478     }
5479     var tar = evt.target;
5480     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5481       var tar = evt.target,
5482           attrName = tar.getAttributeNS(null, "attributeName"),
5483           ttr = tar.targetElement,
5484           tta = ttr[attrName];
5485       /*tar.valuesのリスト:  ["12px", "13px"]
5486        *tar._valueList:   [(new SVGPoint()), (new SVGPoint())]
5487        *  tar.valuesを機械が理解できるように変換したものがtar._valueList
5488        *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
5489        */
5490       var vi = ttr.cloneNode(false);
5491       if (!tar._values[0]) {   //to属性か、by属性が設定されている場合
5492         var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
5493         tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
5494         if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
5495           var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
5496           tar._values[1] = v2 + tanni[0];
5497           tar._values.pop();
5498           v2 = tanni = void 0;
5499         }
5500       }
5501       if ("animatedPoints" in ttr) {
5502         ttr.animatedPoints = vi.points;
5503         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5504           var vir = ttr.cloneNode(false);
5505           delete vir._tar;
5506           vir.setAttributeNS(null, "points", tav[i]);
5507           tar._valueList[tar._valueList.length] = vir.points;
5508         }
5509       } else if (!!tta) {
5510         tta.animVal = vi[attrName].baseVal;
5511         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5512           var vir = ttr.cloneNode(false); //仮の要素
5513           delete vir._tar;
5514           vir.setAttributeNS(null, attrName, tav[i]);
5515           tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
5516         }
5517       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5518         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5519           if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
5520             tar._valueList[i] = new SVGPaint();
5521             tar._valueList[i].setPaint(1, null, tav[i], null)
5522           } else {
5523             tar._valueList[i] = parseFloat(tav[i]);
5524           }
5525         }
5526       } else if ("normalizedPathSegList" in ttr) {
5527         ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
5528         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5529           var vir = ttr.cloneNode(false);
5530           delete vir._tar;
5531           vir.setAttributeNS(null, "d", tav[i]);
5532           tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
5533         }
5534       } else {
5535         vi = void 0;
5536         return;
5537       }
5538       evt = tta = vir = vi = void 0;
5539     }, false);
5540   }, false);
5541   this.addEventListener("beginEvent", function(evt) {
5542     var _tar = evt.target,
5543         attrName = _tar.getAttributeNS(null, "attributeName"),
5544         newAttr = _tar.targetElement.attributes.getNamedItemNS(null, attrName),
5545         ttr = _tar.targetElement,
5546         tta = ttr[attrName];
5547     _tar._frame = function() {
5548       var tar = _tar,
5549           d = tar._isRepeat ? tar.getSimpleDuration() : (tar._finish - tar._start),
5550           n = tar._valueList.length-1,
5551           tg = tar.getCurrentTime();
5552       tar._finish || (d = 0);
5553       d *= 0.8;
5554       if ((n !== -1) && (d !== 0) && (tg <= d)) {
5555         if (tar._isDiscrete) {
5556           ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
5557         }
5558         var ii = Math.floor((tg*n) / d);
5559         if (ii === n) { //iiが境い目のときは、n-2を適用
5560           ii -= 1;
5561         }
5562       } else {
5563         return;
5564       }
5565       /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
5566       *
5567       * 参照:アニメーションサンドイッチモデル
5568       * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
5569       *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
5570       */
5571       var evt = tar.ownerDocument.createEvent("MutationEvents");
5572       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5573       if (tar._keyTimes) {
5574         var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
5575         var ti = tar._keyTimes[ii];
5576       } else {
5577         var di = d / n; //keyTimesがなければ均等に時間を配分しておく
5578         var ti = ii / n;
5579       }
5580       if ("animatedPoints" in ttr) {
5581         var base = ttr.points;
5582         ttr.points = ttr.animatedPoints;
5583         ttr.dispatchEvent(evt);
5584         ttr.animatedPoints = ttr.points;
5585         ttr.points = base;
5586       } else if (!!tta) {
5587         var base = tta.baseVal, tanim = tta.animVal;
5588         var v1 = tar._valueList[ii].value;
5589         /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
5590          * 3.4.2 Specifying the simple animation function f(t)
5591          *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
5592          */
5593         if (!tar._isDiscrete) {
5594           var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
5595         } else {
5596           var v = v1;
5597         }
5598         tanim.newValueSpecifiedUnits(base.unitType, v);
5599         tta.baseVal = tanim;
5600         tanim = void 0;
5601         ttr.dispatchEvent(evt);
5602         /*変化値はanimValプロパティに収納しておき、
5603          *変化する前の、元の値はbaseValプロパティに再び収納しておく
5604          */
5605         tta.animVal = tta.baseVal;
5606         tta.baseVal = base;
5607         di = void 0;
5608       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5609         var base = null;
5610         var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
5611         if (!tar._isDiscrete) {
5612           var v = v1 + (v2-v1) * (tg-ti*d) / di;
5613         } else {
5614           var v = v1;
5615         }
5616       } else if ("normalizedPathSegList" in ttr) {
5617         var base = ttr.normalizedPathSegList;
5618         ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
5619         ttr.dispatchEvent(evt);
5620         ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
5621         ttr.normalizedPathSegList = base;
5622       }
5623      evt = tar = v1 = v2 = v = d = n = ii = tg = void 0;
5624     };
5625     evt = vir = void 0;
5626   }, false);
5627   this.addEventListener("endEvent", function(evt) {
5628     var tar = evt.target,
5629         fill = tar.getAttributeNS(null, "fill");
5630     if (!fill || (fill === "remove")) {
5631       var evt = tar.ownerDocument.createEvent("MutationEvents");
5632       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5633       tar.targetElement.dispatchEvent(evt);
5634       evt = void 0;
5635       tar._frame && tar._frame();
5636     }
5637     delete tar._frame;
5638   }, false);
5639   this.addEventListener("repeatEvent", function(evt) {
5640     var tar = evt.target;
5641   }, false);
5642   return this;
5643 };
5644 SVGAnimateElement.constructor = SVGAnimationElement;
5645 SVGAnimateElement.prototype = new SVGAnimationElement(1);
5646
5647 function SVGSetElement(){
5648   SVGAnimationElement.apply(this);
5649   NAIBU.Clip[NAIBU.Clip.length] = this;
5650   this._to = "";
5651   this.addEventListener("DOMAttrModified", function(evt) {
5652     var tar = evt.target, name = evt.attrName;
5653     if (name === "to") {
5654       tar._to = evt.newValue;
5655     }
5656     tar = name = void 0;
5657   }, false);
5658   this.addEventListener("beginEvent", function(evt) {
5659     var tar = evt.target;
5660     if (tar.targetElement) {
5661       var attrName = tar.getAttributeNS(null, "attributeName"),
5662           newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
5663           tta = tar.targetElement[attrName];
5664       if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5665         var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
5666         style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
5667         style = void 0;
5668       } else if (!!tta) {
5669         var base = tta.baseVal;
5670         if (base instanceof SVGLength) {
5671           tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
5672         } else if (base instanceof SVGRect) {
5673           tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
5674         }
5675         /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
5676          *
5677          * 参照:アニメーションサンドイッチモデル
5678          * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
5679          *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
5680          */
5681         var evt = tar.ownerDocument.createEvent("MutationEvents");
5682         evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
5683         tar.targetElement.dispatchEvent(evt);
5684         evt = void 0;
5685         /*変化値はanimValプロパティに収納しておき、
5686          *変化する前の、元の値はbaseValプロパティに再び収納しておく
5687          */
5688         tta.animVal = tta.baseVal;
5689         tta.baseVal = base;
5690       }
5691     }
5692     evt = tar = attrName = void 0;
5693   }, false);
5694   this.addEventListener("endEvent", function(evt) {
5695     var tar = evt.target,
5696         fill = tar.getAttributeNS(null, "fill");
5697     if (!fill || (fill === "remove")) {
5698       var attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5699       tar.targetElement.style.setProperty(attrName, style.getPropertyValue(attrName), null);
5700       var evtt = tar.ownerDocument.createEvent("MutationEvents");
5701       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5702       tar.targetElement.dispatchEvent(evtt);
5703       attrName = style = evtt = void 0;
5704     }
5705     tar = fill = void 0;
5706   }, false);
5707   this.addEventListener("repeatEvent", function(evt) {
5708     var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5709   }, false);
5710   return this;
5711 };
5712 SVGSetElement.constructor = SVGAnimationElement;
5713 SVGSetElement.prototype = new SVGAnimationElement(1);
5714
5715 function SVGAnimateMotionElement(){
5716   SVGAnimationElement.apply(this);
5717   NAIBU.Clip[NAIBU.Clip.length] = this;
5718   this.addEventListener("DOMAttrModified", function(evt){
5719     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5720       return;
5721     }
5722     var tar = evt.target,
5723         name = evt.attrName;
5724     if (name === "path") {
5725       var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
5726       d.setAttributeNS(null, "d", evt.newValue);
5727       tar._path = d;
5728       d = void 0;
5729     }
5730   }, false);
5731   this.addEventListener("DOMNodeInserted", function(evt){
5732     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5733       return; //強制終了させる
5734     }
5735     var tar = evt.target;
5736     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5737       var vlist = [],
5738           ti;
5739       if (tar._values) {
5740         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5741           ti = tav[i];
5742           ti = ti.split(",");
5743           vlist[i] = [+ti[0], +ti[1]];
5744         }
5745         tar._valueList = vlist;
5746       }
5747     }, false);
5748   }, false);
5749   this.addEventListener("beginEvent", function(evt) {
5750     var tar = evt.target,
5751         trans = tar.targetElement.transform;
5752     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
5753      *baseValと同じような値に設定。
5754      */
5755     trans.animVal = new SVGTransformList();
5756     if (trans.baseVal.numberOfItems !== 0) {
5757       trans.baseVal.consolidate();
5758       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
5759       } else {
5760       trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
5761     }
5762     tar._frame = function() {
5763       var _tar = tar,
5764           tpn = _tar._path,
5765           tgsd = _tar._isRepeat ? _tar.getSimpleDuration() : (_tar._finish - _tar._start),
5766           d = tgsd * 0.8,
5767           tg = _tar.getCurrentTime(),
5768           ii;
5769       _tar._finish || (d = 0);
5770       if (tgsd === 0) {
5771          tgsd = void 0;
5772          return;
5773       }
5774       if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
5775         var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
5776             p = tpn.getPointAtLength(st),
5777             trans = _tar.targetElement.transform;
5778         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
5779         var base = trans.baseVal;
5780         trans.baseVal = trans.animVal;
5781         _tar.targetElement._cacheMatrix = null;
5782         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
5783         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5784         _tar.targetElement.dispatchEvent(evtt);
5785         trans.baseVal = base;
5786         evtt = base = trans = st = p = void 0;
5787       } else if (tar._valueList) {
5788         var total = 0, //totalは総距離
5789             st = 0,    //stは現在にいたるまでの距離
5790             tav = tar._valueList,
5791             n = tav.length - 1;
5792         if ((n !== -1) && (d !== 0) && (tg <= d)) {
5793           ii = Math.floor((tg*n) / d);
5794           if (ii === n) { //iiが境い目のときは、n-2を適用
5795             ii -= 1;
5796           }
5797         } else {
5798           return;
5799         }
5800         for (var i=1, tvli=tav.length;i<tvli;i+=2) {
5801           total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
5802         }
5803         for (var i=1;i<ii;i+=2) {
5804           st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
5805         }
5806         var p = tar.ownerDocument.documentElement.createSVGPoint(),
5807             trans = _tar.targetElement.transform;
5808         st = (st / total) * d;
5809         p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
5810         p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
5811         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
5812         var base = trans.baseVal;
5813         trans.baseVal = trans.animVal;
5814         _tar.targetElement._cacheMatrix = void 0;
5815         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
5816         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5817         _tar.targetElement.dispatchEvent(evtt);
5818         trans.baseVal = base;
5819         evtt = base = trans = st = p = void 0;
5820       }
5821     }
5822     evt = trans = tpn = tgsd = void 0;
5823   }, false);
5824   this.addEventListener("endEvent", function(evt) {
5825     var tar = evt.target,
5826         trans = tar.targetElement.transform,
5827         fill = tar.getAttributeNS(null, "fill");
5828     if (!fill || (fill === "remove")) {
5829       trans.animVal = trans.baseVal;
5830       var evtt = tar.ownerDocument.createEvent("MutationEvents");
5831       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5832       tar.targetElement.dispatchEvent(evtt);
5833       tar._frame && tar._frame();
5834     }
5835     delete tar._frame;
5836     evt = evtt = trans = fill = tar = void 0;
5837   }, false);
5838   this.addEventListener("repeatEvent", function(evt) {
5839     var tar = evt.target;
5840   }, false);
5841   return this;
5842 };
5843 SVGAnimateMotionElement.constructor = SVGAnimationElement;
5844 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
5845
5846 function SVGMPathElement() /* : 
5847                 SVGElement,
5848                 SVGURIReference,
5849                 SVGExternalResourcesRequired*/ {
5850   SVGElement.apply(this);
5851   SVGURIReference.apply(this);
5852   return this;
5853 };
5854 SVGMPathElement.constructor = SVGElement;
5855 SVGMPathElement.prototype = new SVGElement();
5856
5857 function SVGAnimateColorElement() {
5858   SVGAnimationElement.apply(this);
5859   NAIBU.Clip[NAIBU.Clip.length] = this;
5860   this._valueList = [];
5861   this.addEventListener("DOMNodeInserted", function(evt){
5862     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5863       return; //強制終了させる
5864     }
5865     var tar = evt.target;
5866     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5867       var tar = evt.target,
5868           attrName = tar.getAttributeNS(null, "attributeName"),
5869           ttr = tar.targetElement,
5870           fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
5871           css, n;
5872       if (!tar._values[0]) {
5873         tar._values[0] = fstyle.getPropertyValue(attrName);
5874       }
5875       for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5876         var to = new SVGColor();
5877         if (tar._values[i] === "currentColor") {
5878           to.setRGBColor(fstyle.getPropertyValue("color") || "black");
5879         } else if (tar._values[i] === "inherit") {
5880           /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
5881           css = fstyle.getPropertyCSSValue(attrName);
5882           n = css.cssValueType;
5883           css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
5884           to = fstyle.getPropertyCSSValue(attrName);
5885           css.cssValueType = n;
5886         } else {
5887           to.setRGBColor(tar._values[i]);
5888         }
5889         tar._valueList[tar._valueList.length] = to;
5890         to = void 0;
5891       }
5892       tar = ttr = fstyle = css = n = attrName = void 0;
5893     }, false);
5894   }, false);
5895   this.addEventListener("beginEvent", function(evt) {
5896     var tar = evt.target,
5897         attrName = tar.getAttributeNS(null, "attributeName"),
5898         style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
5899         fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5900     tar._frame = function() {
5901       var _tar = tar;
5902       /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
5903        * 3.4.2 Specifying the simple animation function f(t)
5904        *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
5905        */
5906       var d = _tar._isRepeat ? _tar.getSimpleDuration() : (_tar._finish - _tar._start),
5907           n = _tar._valueList.length - 1,
5908           tg = _tar.getCurrentTime(),
5909           ii, di, ti;
5910       _tar._finish || (d = 0);
5911       d *= 0.8;
5912       if ((n !== -1) && (d !== 0) && (tg <= d)) {
5913         ii = Math.floor((tg*n) / d);
5914         if (ii === n) { //iiが境い目のときは、n-2を適用
5915           ii -= 1;
5916         }
5917       } else {
5918         return;
5919       }
5920       if (tar._keyTimes) {
5921         di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
5922         ti = tar._keyTimes[ii];
5923       } else {
5924         di = d / n; //keyTimesがなければ均等に時間を配分しておく
5925         ti = ii / n;
5926       }
5927       var fc = _tar._valueList[ii].rgbColor,
5928           tc = _tar._valueList[ii+1].rgbColor,
5929           durd = (tg-ti*d) / di,
5930           num = CSSPrimitiveValue.CSS_NUMBER,
5931           fr = fc.red.getFloatValue(num),
5932           fg = fc.green.getFloatValue(num),
5933           fb = fc.blue.getFloatValue(num),
5934           r = fr + (tc.red.getFloatValue(num) - fr) * durd,
5935           g = fg + (tc.green.getFloatValue(num) - fg) * durd,
5936           b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
5937       style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
5938       _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = void 0;
5939     };
5940     tar._frame();
5941   }, false);
5942   this.addEventListener("endEvent", function(evt) {
5943     var tar = evt.target,
5944         fill = tar.getAttributeNS(null, "fill");
5945     if (!fill || (fill === "remove")) {
5946       var evtt = tar.ownerDocument.createEvent("MutationEvents");
5947       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5948       tar.targetElement.dispatchEvent(evtt);
5949       tar._frame && tar._frame();
5950     }
5951     delete tar._frame;
5952     evt = evtt = tar = fill = void 0;
5953   }, false);
5954   this.addEventListener("repeatEvent", function(evt) {
5955     var tar = evt.target;
5956   }, false);
5957   return this;
5958 };
5959 SVGAnimateColorElement.constructor = SVGAnimationElement;
5960 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
5961
5962 function SVGAnimateTransformElement() {
5963   SVGAnimationElement.apply(this);
5964   NAIBU.Clip[NAIBU.Clip.length] = this;
5965   this.addEventListener("beginEvent", function(evt) {
5966     var tar = evt.target, trans = tar.targetElement.transform;
5967     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
5968      *baseValと同じような値に設定。
5969      */
5970     trans.animVal = new SVGTransformList();
5971     if (trans.baseVal.numberOfItems !== 0) {
5972       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
5973     }
5974     trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
5975   }, false);
5976   this.addEventListener("endEvent", function(evt) {
5977     var tar = evt.target,
5978         fill = tar.getAttributeNS(null, "fill");
5979     if (!fill || (fill === "remove")) {
5980       var evtt = tar.ownerDocument.createEvent("MutationEvents");
5981       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5982       tar.targetElement.dispatchEvent(evtt);
5983       tar._frame && tar._frame();
5984     }
5985     delete tar._frame;
5986     evt = evtt = tar = fill = void 0;
5987   }, false);
5988   this.addEventListener("repeatEvent", function(evt) {
5989     var tar = evt.target;
5990   }, false);
5991   return this;
5992 };
5993 SVGAnimateTransformElement.constructor = SVGAnimationElement;
5994 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
5995
5996 function SVGFontElement() /*: 
5997                 SVGElement,
5998                 SVGExternalResourcesRequired,
5999                 SVGStylable*/ {
6000   SVGElement.apply(this);
6001   /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
6002   /*boolean or number*/ this._isExternal = 0;
6003   this.addEventListener("DOMNodeInserted", function(evt){
6004     var tar = evt.target;
6005     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6006       return;
6007     }
6008     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
6009       var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
6010       var nefunc = function(evt){
6011         var svg = evt.target;
6012         /*以下のtarはfont要素*/
6013         var familyName = fontFace.getAttributeNS(null, "font-family");
6014         var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
6015         for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
6016           var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
6017           if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
6018             NAIBU._noie_createFont(ti, _tar, true);
6019           }
6020         }
6021         evt = tar = svg = curt = textElments = svgns = _tar = void 0;
6022       };
6023       if (!fontFace.__isLinked || tar._isExternal) {
6024         tar.ownerDocument.documentElement._svgload_limited = 0;
6025         tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
6026       }
6027     }, false);
6028   }, false);
6029   return this;
6030 };
6031 SVGFontElement.constructor = SVGElement;
6032 SVGFontElement.prototype = new SVGElement();
6033
6034 function SVGGlyphElement() /*: 
6035                 SVGElement,
6036                 SVGStylable*/ {
6037   SVGElement.apply(this);
6038   return this;
6039 };
6040 SVGGlyphElement.constructor = SVGElement;
6041 SVGGlyphElement.prototype = new SVGElement();
6042
6043 function SVGMissingGlyphElement() /*: 
6044                 SVGElement,
6045                 SVGStylable*/ {
6046   SVGElement.apply(this);
6047   return this;
6048 };
6049 SVGMissingGlyphElement.constructor = SVGElement;
6050 SVGMissingGlyphElement.prototype = new SVGElement();
6051
6052 function SVGHKernElement() {
6053   SVGElement.apply(this);
6054   return this;
6055 };
6056 SVGHKernElement.constructor = SVGElement;
6057 SVGHKernElement.prototype = new SVGElement();
6058
6059 function SVGVKernElement() {
6060   SVGElement.apply(this);
6061   return this;
6062 };
6063 SVGVKernElement.constructor = SVGElement;
6064 SVGVKernElement.prototype = new SVGElement();
6065
6066 function SVGFontFaceElement() {
6067   SVGElement.apply(this);
6068   /*boolean(or number)*/ this._isLinked = 0;
6069   this.addEventListener("DOMNodeInserted", function(evt){
6070     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6071       if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
6072         evt.currentTarget._isLinked = 1;
6073       }
6074       return; //強制終了させる
6075     }
6076   }, false);
6077   return this;
6078 };
6079 SVGFontFaceElement.constructor = SVGElement;
6080 SVGFontFaceElement.prototype = new SVGElement();
6081
6082 function SVGFontFaceSrcElement() {
6083   SVGElement.apply(this);
6084   return this;
6085 };
6086 SVGFontFaceSrcElement.constructor = SVGElement;
6087 SVGFontFaceSrcElement.prototype = new SVGElement();
6088
6089 function SVGFontFaceUriElement() {
6090   SVGElement.apply(this);
6091   this.addEventListener("DOMNodeInserted", function(evt){
6092     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6093       return; //強制終了させる
6094     }
6095     evt.target.ownerDocument.documentElement._svgload_limited--
6096     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
6097   }, false);
6098   this.addEventListener("S_Load", function(evt){
6099     var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
6100     if (tpp.localName === "defs") {
6101       tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
6102     }
6103     tar._instance._isExternal = 1;
6104     tpp.parentNode.appendChild(tar._instance);
6105     evt = tar = tpp = void 0;
6106   }, false);
6107   SVGURIReference.apply(this);
6108   return this;
6109 };
6110 SVGFontFaceUriElement.constructor = SVGElement;
6111 SVGFontFaceUriElement.prototype = new SVGElement();
6112
6113 function SVGFontFaceFormatElement() {
6114   SVGElement.apply(this);
6115   return this;
6116 };
6117 SVGFontFaceFormatElement.constructor = SVGElement;
6118 SVGFontFaceFormatElement.prototype = new SVGElement();
6119
6120 function SVGFontFaceNameElement() {
6121   SVGElement.apply(this);
6122   return this;
6123 };
6124 SVGFontFaceNameElement.constructor = SVGElement;
6125 SVGFontFaceNameElement.prototype = new SVGElement();
6126
6127 function SVGDefinitionSrcElement() {
6128   SVGElement.apply(this);
6129   return this;
6130 };
6131 SVGDefinitionSrcElement.constructor = SVGElement;
6132 SVGDefinitionSrcElement.prototype = new SVGElement();
6133
6134 function SVGMetadataElement() {
6135   SVGElement.apply(this);
6136   return this;
6137 };
6138 SVGMetadataElement.constructor = SVGElement;
6139 SVGMetadataElement.prototype = new SVGElement();
6140
6141 function SVGForeignObjectElement() /*: 
6142                 SVGElement,
6143                 SVGTests,
6144                 SVGLangSpace,
6145                 SVGExternalResourcesRequired,
6146                 SVGStylable,
6147                 SVGTransformable,
6148                 events::EventTarget*/ { 
6149   SVGElement.apply(this);
6150   var sl = SVGAnimatedLength;
6151   /*readonly SVGAnimatedLength*/ this.x = new sl();
6152   /*readonly SVGAnimatedLength*/ this.y = new sl();
6153   /*readonly SVGAnimatedLength*/ this.width = new sl();
6154   /*readonly SVGAnimatedLength*/ this.height = new sl();
6155   sl = void 0;
6156   return this;
6157 };
6158 SVGForeignObjectElement.constructor = SVGElement;
6159 SVGForeignObjectElement.prototype = new SVGElement();
6160
6161 //#endif  _SVG_IDL_
6162 /*SVGの要素マッピング(DOMでは定められていないが、必須)
6163  *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
6164  *SIEでは軽量化のために、マッピングを用いた
6165  */
6166 DOMImplementation["http://www.w3.org/2000/svg"] = {
6167   Document:        SVGDocument,
6168   svg:             SVGSVGElement,
6169   g:               SVGGElement,
6170   path:            NAIBU.SVGPathElement,
6171   title:           SVGTitleElement,
6172   desc:            SVGDescElement,
6173   defs:            SVGDefsElement,
6174   linearGradient:  SVGLinearGradientElement,
6175   radialGradient:  SVGRadialGradientElement,
6176   stop:            SVGStopElement,
6177   rect:            SVGRectElement,
6178   circle:          SVGCircleElement,
6179   ellipse:         SVGEllipseElement,
6180   polyline:        SVGPolylineElement,
6181   polygon:         SVGPolygonElement,
6182   text:            SVGTextElement,
6183   tspan:           SVGTSpanElement,
6184   image:           SVGImageElement,
6185   line:            SVGLineElement,
6186   a:               SVGAElement,
6187   altGlyphDef:     SVGAltGlyphDefElement,
6188   altGlyph:        SVGAltGlyphElement,
6189   altGlyphItem:    SVGAltGlyphItemElement,
6190   animateColor:    SVGAnimateColorElement,
6191   animate:         SVGAnimateElement,
6192   animateMotion:   SVGAnimateMotionElement,
6193   animateTransform:SVGAnimateTransformElement,
6194   clipPath:        SVGClipPathElement,
6195   colorProfile:    SVGColorProfileElement,
6196   cursor:          SVGCursorElement,
6197   definitionSrc:   SVGDefinitionSrcElement,
6198   feBlend:         SVGFEBlendElement,
6199   feGaussianBlur:  SVGFEGaussianBlurElement,
6200   filter:          SVGFilterElement,
6201   font:            SVGFontElement,
6202   "font-face":     SVGFontFaceElement,
6203   "font-face-format":SVGFontFaceFormatElement,
6204   "font-face-name":SVGFontFaceNameElement,
6205   "font-face-src": SVGFontFaceSrcElement,
6206   "font-face-uri": SVGFontFaceUriElement,
6207   foreignObject:   SVGForeignObjectElement,
6208   glyph:           SVGGlyphElement,
6209   glyphRef:        SVGGlyphRefElement,
6210   hkern:           SVGHKernElement,
6211   marker:          SVGMarkerElement,
6212   mask:            SVGMaskElement,
6213   metadata:        SVGMetadataElement,
6214   missingGlyph:    SVGMissingGlyphElement,
6215   mpath:           SVGMPathElement,
6216   script:          SVGScriptElement,
6217   set:             SVGSetElement,
6218   style:           SVGStyleElement,
6219   "switch":        SVGSwitchElement,
6220   textPath:        SVGTextPathElement,
6221   tref:            SVGTRefElement,
6222   use:             SVGUseElement,
6223   view:            SVGViewElement,
6224   vkern:           SVGVKernElement,
6225   pattern:         SVGPatternElement
6226 };
6227
6228 NAIBU._fontSearchURI = function(evt){
6229   var doc = evt.target.ownerDocument;
6230   var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
6231   for (var i=0;i<tsrc.length;++i) {
6232     var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
6233         ids = src.split(":")[1],
6234         xmlhttp = NAIBU.xmlhttp;
6235     xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
6236     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
6237     xmlhttp.onreadystatechange = function() {
6238       if ((xmlhttp.readyState === 4)  &&  (xmlhttp.status === 200)) {
6239         var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
6240         NAIBU._font({document:doce, docu:doc, id:ids});
6241         xmlhttp = doc = doce = void 0;
6242       }
6243     };
6244     xmlhttp.send(null);
6245   }
6246 };
6247 /*_font関数は、SVGFontで使う*/
6248 NAIBU._font = function (data) {
6249   var doc = data.document, svgns = "http://www.w3.org/2000/svg";
6250   //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
6251   var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
6252   var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
6253   if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
6254     var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
6255     for (var i=0,tli=textElements.length;i<tli;++i) {
6256       var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
6257       if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
6258         NAIBU._noie_createFont(ti, font, false);
6259       }
6260     }
6261   }
6262   doc = data = void 0;
6263 };
6264 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
6265   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
6266       svgns = "http://www.w3.org/2000/svg",
6267       //isTategakiは縦書きならば真
6268       isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
6269       horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
6270       node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
6271       em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
6272       advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
6273       dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
6274       dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
6275       fontSize = parseFloat(style.getPropertyValue("font-size")),
6276       fe = fontSize / em,
6277       ds = false, npdlist = ["fill",
6278   "fill-opacity",
6279   "stroke",
6280   "stroke-width",
6281   "stroke-linecap",
6282   "stroke-linejoin",
6283   "stroke-miterlimit",
6284   "stroke-dasharray",
6285   "stroke-opacity",
6286   "opacity",
6287   "cursor"];
6288   if (/a/[-1] === 'a') { //Firefoxならば
6289     ds = true;
6290   } else if (isMSIE || isTategaki) {
6291     ds = true;
6292   }
6293   if (ds){
6294      while(node) {
6295       if (!glyphs) {
6296         break;
6297       }
6298       data = node.data;
6299       if (data !== void 0) { //dataがある場合
6300         var advanceX = [], glyphData = [];
6301         for (var i=0,gli=glyphs.length;i<gli;++i) {
6302           var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
6303           var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
6304           if (orientation) {
6305             if (orientation === "h") {
6306               isVert = false;
6307             }
6308           } else {
6309             isOrientationAttribute = false;
6310           }
6311           if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
6312             //indexは該当する文字が何番目にあるかの数字
6313             var index = data.indexOf(unicode);
6314             while (index > -1) {
6315               advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
6316               glyphData[index] = glyph.getAttributeNS(null, "d");
6317               index = data.indexOf(unicode, index+1);
6318             }
6319           }
6320         }
6321         for (var i=0,adv=0;i<data.length;++i) {
6322           if (advanceX[i] !== void 0) { //配列に含まれていれば
6323             var path = ti.ownerDocument.createElementNS(svgns, "path");
6324             //advance、すなわち字幅の長さ分、ずらしていく
6325             var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
6326             matrix.a = fe;
6327             matrix.d = -fe;
6328             for (var j=0;j<npdlist.length;++j){
6329               var nj = npdlist[j],
6330                   tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
6331               if (nj === "stroke-width") {
6332                 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
6333                 tg += "";
6334               }
6335               if (tg) {
6336                 path.setAttributeNS(null, nj, tg);
6337               }
6338             }
6339             if (isTategaki) {
6340               var y= dy + adv*fe, x = dx;
6341               if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
6342                 var fms = fontSize / Math.SQRT2;
6343                 x += fms;
6344                 y -= fms;
6345                 fms = void 0;
6346               }
6347               matrix.e = x;
6348               matrix.f = y;
6349             } else {
6350               matrix.e = dx + adv*fe;
6351               matrix.f = dy;
6352             }
6353             path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
6354             path.setAttributeNS(null, "d", glyphData[i]);
6355             ti.parentNode.insertBefore(path, ti);
6356             adv += advanceX[i];
6357             matrix = void 0;
6358           }
6359         }
6360         adv = advanceX = glyphData = void 0;
6361       } else if ("tspan|a".indexOf(node.localName) > -1){
6362         NAIBU._noie_createFont(node, font, isMSIE);
6363       }
6364       node = node.nextSibling;
6365     }
6366     if (isMSIE) {
6367       var style = ti.ownerDocument.getOverrideStyle(ti, null);
6368       style.setProperty("visibility", "hidden");
6369       style = void 0;
6370     } else {
6371       ti.setAttributeNS(null, "opacity", "0");
6372     }
6373   }
6374   data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
6375 };
6376
6377 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
6378  *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
6379  */
6380 (function(){
6381   var s = new CSSStyleDeclaration(),
6382        slis = s._list,
6383       n = 0,
6384       regAZ = /([A-Z])/,
6385       regm = /\-/,
6386       u, t;
6387   for (var i in CSS2Properties) {
6388     if(CSS2Properties.hasOwnProperty(i)) {
6389       t = i.replace(regAZ, "-");
6390       if (!!RegExp.$1) {
6391         u = "-" +RegExp.$1.toLowerCase();
6392       } else {
6393         u = "-";
6394       }
6395       t = t.replace(regm, u);
6396       s.setProperty(t, CSS2Properties[i]);
6397       slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
6398       slis[n]._isDefault = 1;
6399       ++n;
6400       i = t = u =  void 0;
6401     }
6402   }
6403   slis._opacity = 1;
6404   slis._fontSize = 12;
6405   CSS2Properties._list = slis;
6406   Document.prototype.defaultView._defaultCSS = slis;
6407   s = n = regAZ = regm = slis =null;
6408 })();
6409
6410 NAIBU.addEvent = function(evt,lis){
6411   if (window.addEventListener) {
6412     window.addEventListener(evt, lis, false);
6413   } else if (window.attachEvent) {
6414     window.attachEvent('on'+evt, lis);
6415   } else {
6416     window['on'+evt] = lis;
6417   }
6418   //Sieb用
6419   if (sieb_s) {
6420     lis();
6421   }
6422 };
6423
6424 function unsvgtovml() {
6425   try {
6426     if ("stop" in NAIBU) {
6427       clearInterval(NAIBU.stop);
6428     }
6429     window.onscroll = NAIBU.emptyFunction;
6430     window.detachEvent("onload", NAIBU._main);
6431     NAIBU.freeArg();
6432     Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
6433     Array = ActiveXObject = void 0;
6434   } catch(e) {}
6435 }
6436 /*_main関数
6437  *一番最初に起動するべき関数 
6438  */
6439 NAIBU._main = (function() {
6440   stlog = new STLog(true);
6441   var xmlhttp,         //XMLHttpオブジェクトを生成
6442       _doc = document; //documentのエイリアスを作成
6443   try {
6444     if (XMLHttpRequest) {
6445       xmlhttp = false;
6446     } else {
6447       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
6448     }
6449   } catch (e) {
6450     try {
6451       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
6452     } catch (E) {
6453       xmlhttp = false;
6454     }
6455   }
6456   if (!xmlhttp) {
6457     try {
6458       xmlhttp = new XMLHttpRequest();
6459     } catch (e) {
6460       xmlhttp = false;
6461     }
6462   }
6463   NAIBU.xmlhttp = xmlhttp;
6464   var nd;
6465   if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
6466     try {
6467       NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
6468     } catch (e) {
6469       
6470     }
6471     nd = NAIBU.doc;
6472     _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
6473     _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
6474     var st = _doc.createStyleSheet();
6475     var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
6476     st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
6477       + "dn\\:defs{display:none}"
6478       + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
6479       + "v\\:shape{width:100%;height:100%;" +vmlUrl;
6480   }
6481   var ary = _doc.getElementsByTagName("script");
6482   //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
6483   for (var i=0; ary[i]; ++i) {
6484     var ai = ary[i],
6485         hoge = ai.type;
6486     if (ai.type === "image/svg+xml") {
6487       var ait = ai.text;
6488       if (sieb_s && ait.match(/&lt;svg/)) {
6489         //ソース内のタグを除去
6490         ait = ait.replace(/<.+?>/g, "");
6491         //エンティティを文字に戻す
6492         ait = ait.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
6493       }
6494       if (NAIBU.isMSIE) {
6495         var gsd = new GetSVGDocument(ai);
6496         gsd.xmlhttp = {
6497           readyState : 4,
6498           status : 200,
6499           responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
6500         }
6501         gsd._ca();
6502       } else {
6503         var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
6504         ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
6505         var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
6506         ai.parentNode.insertBefore(s,ai);
6507       }
6508       ai = ait = void 0;
6509     }
6510     hoge = void 0;
6511   }
6512   NAIBU.doc = nd;
6513   nd = ary = void 0;
6514   if (xmlhttp && NAIBU.isMSIE) {
6515     if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
6516     } else { //IE6-8ならば
6517       var ob = _doc.getElementsByTagName("object"),
6518           em = _doc.getElementsByTagName("embed"),
6519           s=[],
6520           _search = function(_ob) {
6521             var ifr, obi, n;
6522             s || (s = []);             //NAIBU._searchで呼ばれたときに必要
6523             _doc || (_doc = document);
6524             for (var i=0;_ob[i];++i) {
6525               obi = _ob[i];
6526               s[s.length] = new GetSVGDocument(obi);
6527               ifr = _doc.createElement("iframe");
6528               ifr.style.background = "black";
6529               n = obi.getAttribute("width");
6530               n && ifr.setAttribute("width", n);
6531               n = obi.getAttribute("height");
6532               n && ifr.setAttribute("height", n);
6533               ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
6534               ifr.scrolling = "no";
6535               ifr.frameBorder = "0";
6536              /*iframe要素を使って、描画のプロセスを分離する
6537               *したがって、_docはdocumentとは別のオブジェクトとなる
6538               */
6539               obi.parentNode.insertBefore(ifr, obi);
6540             }
6541             i = obi = ifr = _ob = void 0;
6542             return s[s.length-1];
6543           };
6544       _search(ob);
6545       _search(em);
6546       NAIBU._search = _search; //a要素がクリックされたときに使う関数
6547       ob = em = _search = void 0;
6548       for (var i=0;i<s.length;++i) {
6549         if (i < s.length-1) {
6550           s[i]._next = s[i+1]
6551         }
6552       }
6553       if (i > 0) {
6554         s[0]._init(); //初期化作業を開始
6555       }
6556       s = void 0;
6557     }
6558   } else {
6559     var ob = _doc.getElementsByTagName("object");
6560     for (var i=0;i<ob.length;++i) {
6561       if (ob[i].contentDocument) {
6562         NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
6563       } else if (ob[i].getSVGDocument) {
6564         ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
6565       } else {
6566       }
6567     }
6568   }
6569   xmlhttp = _doc = void 0;
6570 });
6571 NAIBU.addEvent("load", NAIBU._main);
6572 NAIBU.utf16 = function ( /*string*/ s)  {
6573   return unescape(s);
6574 }
6575 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
6576   return s.replace(/%u\w\w\w\w/g,  NAIBU.utf16);
6577 }
6578 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
6579 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
6580   /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
6581    *dataスキーム方式を採用する
6582    */
6583   if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
6584     var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
6585     var ob = document.createElement("object");
6586     ob.setAttribute("data",data);
6587     ob.setAttribute("width",w);
6588     ob.setAttribute("height",h);
6589     ob.setAttribute("type","image/svg+xml");
6590     return ob;
6591   } else {
6592     var doc = (new DOMParser()).parseFromString(source, "text/xml");
6593     return (document.importNode(doc.documentElement, true));
6594   }
6595 };
6596 NAIBU.addEvent("unload", unsvgtovml);
6597 //IEならばtrue
6598 NAIBU.isMSIE = /*@cc_on!@*/false;