OSDN Git Service

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