OSDN Git Service

Merge branch 'develop'
[sie/sie.git] / sie.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 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/dom.idl
59 /*W3CのDOMのIDLを参照にコードを起こしている
60  *変数やプロパティ、メソッドの名前の頭に、「_」がついているときはSIE独自のもの
61  */
62 /*
63 #ifndef _DOM_IDL_
64 #define _DOM_IDL_
65
66 #pragma prefix "w3c.org"
67 module dom
68 {
69
70   valuetype DOMString sequence<unsigned short>;
71
72   typedef   unsigned long long DOMTimeStamp;
73
74   interface DocumentType;
75   interface Document;
76   interface NodeList;
77   interface NamedNodeMap;
78   interface Element;
79 */
80 function DOMException(n){
81  Error.apply(this, arguments);
82  this.code = n;
83  var s = [
84    "", //数合わせのため
85    "Index Size Error",
86    "DOMString Size Error",
87    "Hierarchy Request Error",
88    "Wrong Document Error",
89    "Invalid Character Error",
90    "No Data Allowed Error",
91    "No Modification Allowed Error",
92    "Not Found Error",
93    "Not Supported Error",
94    "Inuse Attribute Error",
95    "Invalid State Error",
96    "Syntax Error",
97    "Invalid Modification Error",
98    "Namespace Error",
99    "Invalid Access Error"
100  ];
101  this.message = s[n];
102  return this;
103 /*DOMSTRING_SIZE_ERR
104 テキストの指定された範囲がDOMStringに合致しない。 2
105 HIERARCHY_REQUEST_ERR
106 コードが属さない場所に挿入されている。 3
107 INDEX_SIZE_ERR
108 インデクス若しくは大きさが負数,又は許された値よりも大きい。 1
109 INUSE_ATTRIBUTE_ERR
110 他で既に使用されている属性を追加しようとしている。 10
111 INVALID_ACCESS_ERR,DOM水準2で導入 
112 パラメタ又は操作が基礎になるオブジェクトによってサポートされていない。 15
113 INVALID_CHARACTER_ERR
114 名前の中などで,妥当でない又は不正な文字が指定されている。文法に合った文字の定義についてはXML規定の 生成規則2 を,文法に合った名前文字については 生成規則5 を参照すること。5 
115 INVALID_MODIFICATION_ERR,DOM水準2で導入 
116 基礎となるオブジェクトの型を修正しようとしている。 13
117 INVALID_STATE_ERR,DOM水準2で導入 
118 利用不可能又はもはや利用可能ではないオブジェクトを使用しようとしている。 11
119 NAMESPACE_ERR,DOM水準2で導入 
120 名前空間に関して正しくない方法でオブジェクトを生成又は変更しようとしている。 14
121 NOT_FOUND_ERR
122 ノードが存在しない文脈でそのノードを参照しようとしている。 8
123 NOT_SUPPORTED_ERR
124 実装は,オブジェクト又は操作の要求された型をサポートしていない。9 
125 NO_DATA_ALLOWED_ERR
126 データをサポートしないノードに対してデータを指定している。 6
127 NO_MODIFICATION_ALLOWED_ERR
128 修正が許されない場所でオブジェクトを修正しようとしている。 7
129 SYNTAX_ERR,DOM水準2で導入 
130 妥当ではない又は不正な文字列が指定されている。 12
131 WRONG_DOCUMENT_ERR
132 ノードを生成した文書以外の(そのノードをサポートしない)異なる文書で,ノードが使用されている。4
133 */
134 };
135 (function(t) {
136 t.INDEX_SIZE_ERR                 = 1;
137 t.DOMSTRING_SIZE_ERR             = 2;
138 t.HIERARCHY_REQUEST_ERR          = 3;
139 t.WRONG_DOCUMENT_ERR             = 4;
140 t.INVALID_CHARACTER_ERR          = 5;
141 t.NO_DATA_ALLOWED_ERR            = 6;
142 t.NO_MODIFICATION_ALLOWED_ERR    = 7;
143 t.NOT_FOUND_ERR                  = 8;
144 t.NOT_SUPPORTED_ERR              = 9;
145 t.INUSE_ATTRIBUTE_ERR            = 10;
146 t.INVALID_STATE_ERR              = 11;
147 t.SYNTAX_ERR                     = 12;
148 t.INVALID_MODIFICATION_ERR       = 13;
149 t.NAMESPACE_ERR                  = 14;
150 t.INVALID_ACCESS_ERR             = 15;
151 t.prototype = new Error();
152 })(DOMException);
153
154 /*DOMImplementation
155  *DOMの基本的な機能をつかさどる
156  */
157 DOMImplementation = {
158     /* hasFeature
159      *文字列によって、機能をサポートしているかどうかをチェックする。削除不可。
160      */
161     /*boolean*/ hasFeature : function(/*string*/ feature, version) {
162       switch (feature) {
163         case "CORE" :
164         case "XML" :
165         case "Events" :              //DOM level2 Eventを参照
166         case "StyleSheets" :         //DOM level2 StyleSheetを参照
167         case "org.w3c.svg.static" :  //SVG1.1の仕様を参照
168         case "org.w3c.dom.svg.static" :
169           return true;
170         default :
171           if (version === "2.0") {   //DOM level2 Coreにおいて策定されたバージョン情報
172             return true;
173           } else {
174             return false;
175           }
176       }
177     },
178
179     /* createDocumentType
180      *ドキュメントタイプを作るためのもの。削除可。
181      */
182     /*DocumentType*/ createDocumentType : function(/*string*/ qualifiedName, publicId, systemId) {
183       var s = new Node();
184       s.publicId = publicId;
185       s.systemId = systemId;
186       return s;
187     },
188     /* createDocument
189      * ドキュメントオブジェクトを作るためのもの。削除不可。
190      */
191     /*Document*/ createDocument : function( /*string*/ ns, qname, /*DocumentType*/ doctype) {
192       try {
193         var s;
194         if (ns) {
195           s = new (DOMImplementation[ns].Document);
196           this._doc_ && (s._document_ = this._doc_);          //_document_プロパティはcreateElementNSメソッドやradialGradient要素やNAIBU._setPaintなどで使う
197         } else {
198           s = new Document();
199         }
200         s.implementation = this;
201         s.doctype = doctype;
202         s.documentElement = s.createElementNS(ns,qname); //ルート要素を作る
203         return s;
204       } catch(e){alert(e.message);}
205     },
206     "http://www.w3.org/2000/xmlns": {}
207 };
208
209 /* Node
210  *ノード(節)はすべての雛形となる重要なものである。削除不可。
211  */
212
213 function Node(){
214   this.childNodes = [];
215   this._capter = []; //eventで利用
216   return this;
217 }
218 (function(t) {
219 // NodeType
220 /*const unsigned short*/  t.ELEMENT_NODE                   = 1;
221 /*const unsigned short*/  t.ATTRIBUTE_NODE                 = 2;
222 /*const unsigned short*/  t.TEXT_NODE                      = 3;
223 /*const unsigned short*/  t.CDATA_SECTION_NODE             = 4;
224 /*const unsigned short*/  t.ENTITY_REFERENCE_NODE          = 5;
225 /*const unsigned short*/  t.ENTITY_NODE                    = 6;
226 /*const unsigned short*/  t.PROCESSING_INSTRUCTION_NODE    = 7;
227 /*const unsigned short*/  t.COMMENT_NODE                   = 8;
228 /*const unsigned short*/  t.DOCUMENT_NODE                  = 9;
229 /*const unsigned short*/  t.DOCUMENT_TYPE_NODE             = 10;
230 /*const unsigned short*/  t.DOCUMENT_FRAGMENT_NODE         = 11;
231 /*const unsigned short*/  t.NOTATION_NODE                  = 12;
232 })(Node);
233 Node.prototype = {
234   //以下は初期値として設定
235   tar : null,
236   firstChild : null,
237   previousSibling : null,
238   nextSibling : null,
239   attributes : null,
240   namespaceURI : null,
241   localName : null,
242   lastChild : null,
243   prefix : null,
244   ownerDocument : null,
245   parentNode : null,
246 /*replaceChildメソッド
247  *指定したoldChildノードの代わりに、新たなnewChildノードを入れる。切り替え機能。
248  */
249 /*Node*/ replaceChild : function( /*Node*/ newChild, oldChild) {
250   this.insertBefore(newChild, oldChild);
251   var s = this.removeChild(oldChild);
252   return s;
253 },
254 /*appendChildメソッド
255  *eleノードをリストの最後尾に追加する
256  */
257 /*Node*/ appendChild : function( /*Node*/ ele) {
258   this.insertBefore(ele,null);
259   return ele;
260 },
261 /*hasChildNodesメソッド
262  *子ノードがあるかどうか
263  */
264 /*boolean*/ hasChildNodes : function() {
265   if (this.childNodes.length > 0) {
266     return true;
267   } else {
268     return false;
269   }
270 },
271 /*cloneNodeメソッド
272  *ノードのコピーを作る。引数は、子ノードのコピーも作るかどうか。コピー機能。
273  */
274 /*Node*/ cloneNode : function( /*boolean*/ deep) {
275   var s;
276   if (this.hasOwnProperty("ownerDocument")) {
277     s = this.ownerDocument.importNode(this, deep);
278   } else {
279     s = new Node();
280   }
281   return s;
282 },
283 /*normalizeメソッド
284  *二つ以上の重複したテキストノードを一つにまとめる
285  */
286 /*void*/ normalize : function() {
287   var tcn = this.childNodes;
288   try {
289   for (var i=tcn.length-1;i<0;--i) {
290     var tcni = tcn[i], tcnip = tcni.nextSibling;
291     if (tcnip) {
292       if (tcni.nodeType === Node.TEXT_NODE && tcnip.nodeType === Node.TEXT_NODE) {
293         tcni.appendData(tcnip.data);    //次ノードの文字列データを、現ノード文字列の後に付け加える
294         tcni.legnth = tcni.data.length;
295         this.removeChild(tcnip);        //次ノードを排除
296       } else {
297         tcni.normalize();
298       }
299     } else {
300       tcni.normalize();
301     }
302   }
303   } catch(e){};
304 },
305 /*isSupportedメソッド
306  *どんな機能をサポートしているかどうかをチェック
307  */
308 /*boolean*/ isSupported : function( /*string*/ feature, version) {
309   return (this.ownerDocument.implementation.hasFeature(feature+"", version+""));
310 },
311 /*hasAttributesメソッド
312  *ノードが属性を持っているかどうか
313  */
314 /*boolean*/ hasAttributes : function() {
315   if (this.attributes.length > 0) {
316     return true;
317   } else {
318     return false;
319   }
320 }
321 };
322
323
324 Array.prototype.item = function( /*long*/ index) {
325   return (this[index]);
326 };
327 /*ノードリストはArrayで代用。
328   interface NodeList {
329     Node               item(in unsigned long index);
330     readonly attribute unsigned long    length;
331   };
332 */
333
334 /*NamedNodeMap
335  *ノードの集合。ノードリストと違って、順序が決まっていない。削除不可
336  */
337 function NamedNodeMap() {
338   return this;
339 }
340 /*_copyNode
341  *cloneNodeを行う際に、用いる。削除不可
342  */
343 Array.prototype._copyNode = function __nnmp_c( /*NamedNodeMap*/ children, /*boolean*/ deep) {
344   for (var i=0,cli=children.length;i<cli;i++) {
345     this[i] = children[i].cloneNode(deep);
346   }
347 };
348
349 NamedNodeMap.prototype = {
350  /*number*/ length : 0,
351 /*
352  *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること
353  */
354 /*Node*/ getNamedItem : function(/*string*/ name){
355   },
356 /*Node*/ setNamedItem : function(/*Node*/ arg){
357   },
358 /*Node*/ removeNamedItem : function(/*string*/ name){
359   },
360 /*Node*/ item : function( /*long*/ index) {
361     return this[index];
362   },
363 /*getNamedItemNSメソッド
364  *名前空間と名前を使って、ノードの集合から特定のノードを取り出す
365  */
366 /*Node*/ getNamedItemNS : function(/*string*/ namespaceURI, /*string*/ localName) {
367     var ta;
368     for (var i=0,tali=this.length;i<tali;i++) {
369       ta = this[i];
370       if (ta.namespaceURI === namespaceURI && ta.localName === localName) { //名前空間と名前がそれぞれ一致すれば
371         this._num = i;                                                      //場所をいったん記録しておく。(setNamedItemNSで使う)
372         return ta;
373       }
374     }
375     i = ta = void 0;
376     return null;
377   },
378 /*setNamedItemNSメソッド
379  *ノードの集合に特定のノードを設定
380  */
381 /*Node*/ setNamedItemNS : function(/*Node*/ arg) {
382     var tgans = this.getNamedItemNS(arg.namespaceURI, arg.localName),
383         s;
384     if (tgans) {                          //ノードがすでにあるならば、
385       s = this[this._num];
386       this[this._num] = arg;
387       arg = tgans = void 0;
388       return s;
389     } else {
390       if (arg.ownerElement !== void 0) { //ノードがもはや別の要素で使われている
391         throw (new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
392       }
393       this[this.length] = arg;            //新たに、argを項目として追加する
394       this.length +=  1;
395       arg = void 0;
396       return null;
397     }
398   },
399 /*removeNamedItemNSメソッド
400  *名前空間と名前を使って、ノードの集合から特定のノードを排除
401  */
402 /*Node*/ removeNamedItemNS : function(/*string*/ namespaceURI, /*string*/ localName) {
403     var tgans = this.getNamedItemNS(namespaceURI, localName);
404     if (!tgans) {                          //ノードが見当たらない場合、
405       throw (new DOMException(DOMException.NOT_FOUND_ERR));
406     } else {
407       var s = this[this._num];
408       delete (this[this._num]);
409       this.length -= 1;
410       tgas = void 0;
411       return s;
412     }
413   },
414   _copyNode : Array.prototype._copyNode //上記のArrayの_copyNodeを参照
415 };
416
417 /*CharacterData
418  *文字データ。Textノードなどの元となる。削除不可。
419  */
420 function CharacterData(){
421  Node.apply(this);
422  return this;
423 };
424 CharacterData.prototype = new Node();                    //ノードのプロトタイプチェーンを作って、継承
425 CharacterData.constructor = Node;
426 CharacterData.prototype.length = 0;
427 /*substringDataメソッド
428  *offsetから数えてcount分の文字列を取り出す
429  */
430 /*string*/ CharacterData.prototype.substringData = function(/*long*/ offset, /*long*/ count) {
431   if (offset < 0 || count < 0 || offset > this.length) { //値が負か、データの長さよりoffsetが長いとき、サイズエラーを起こす
432     throw (new DOMException(INDEX_SIZE_ERR));
433   }
434   if (offset + count > this.length) {                    //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを取り出す
435     count = this.length - offset;
436   }
437   var s = this.data.substr(offset, count);
438   return s;
439 };
440 /*void*/ CharacterData.prototype.replaceData = function( /*long*/ offset, /*long*/ count, /*string*/ arg) {
441   if (offset < 0 || count < 0 || offset > this.length) { //値が負か、データの長さよりoffsetが長いとき、サイズエラーを起こす
442     throw (new DOMException(INDEX_SIZE_ERR));
443   }
444   this.deleteData(offset, count);
445   this.insertData(offset, arg);
446 };
447
448 /*Attr
449  *属性ノード。削除不可。
450  */
451 function Attr() {
452   return this;
453 };
454 Attr.prototype = new Node();                    //ノードのプロトタイプチェーンを作って、継承
455 Attr.constructor = Node;
456 Attr.prototype.nodeType = Node.ATTRIBUTE_NODE;
457 Attr.prototype.nodeValue = null;
458
459 /*Element
460  *要素ノード。削除不可。
461  */
462 function Element() {
463   Node.apply(this);
464   this.attributes = new NamedNodeMap();          //属性を収納
465   return this;
466 };
467 Element.prototype = new Node();                  //ノードのプロトタイプチェーンを作って、継承
468 Element.constructor = Node;
469 Element.prototype.nodeType = Node.ELEMENT_NODE;
470 Element.prototype.nodeValue = null;
471 /*
472  *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること
473  *(getAttributeとsetAttributeは普及しているので機能させる
474  */
475 /*string*/ Element.prototype.getAttribute = function( /*string*/ name) {
476   return (this.getAttributeNS(null, name));
477 };
478 /*void*/ Element.prototype.setAttribute = function( /*string*/ name, /*string*/ value) {
479   this.setAttributeNS(null, name, value);
480 };
481 /*void*/ Element.prototype.removeAttribute = function( /*string*/ name) {
482   this.removeAttributeNS(null, name);
483 };
484 /*Attr*/ Element.prototype.getAttributeNode = function( /*string*/ name) {
485 };
486 /*Attr*/ Element.prototype.setAttributeNode = function( /*Attr*/ newAttr) {
487 };
488 /*Attr*/ Element.prototype.removeAttributeNode = function( /*Attr*/ oldAttr) {
489   var s = this.attributes.removeNamedItemNS(oldAttr.namespaceURI, oldAttr.localName);  //attributesから該当するノードを排除
490   return s;
491 };
492 /*NodeList(Array)*/ Element.prototype.getElementsByTagName = function( /*string*/ name) {
493 };
494 /*string*/ Element.prototype.getAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
495   var n = this.getAttributeNodeNS(namespaceURI, localName);                      //属性ノードを取得する
496   if (!n) {
497     return null;
498   } else {
499     return (n.nodeValue);
500   }
501 };
502 /*void*/ Element.prototype.setAttributeNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName, /*string*/ value) {
503   var atn = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
504   /*元来、string型以外の型を許容すべきではないが、他のブラウザ(FirefoxやOpera)でエラーが出ないため許容する*/
505   atn.nodeValue = value+"";
506   atn.value = value+"";
507   this.setAttributeNodeNS(atn);
508 };
509 /*void*/ Element.prototype.removeAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
510 };
511 /*Attr*/ Element.prototype.getAttributeNodeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
512   var s = this.attributes.getNamedItemNS(namespaceURI,localName);
513   return s;
514 };
515 /*NodeList(Array)*/ Element.prototype.getElementsByTagNameNS = function( /*string*/ namespaceURI, /*string*/ localName) {
516   var s = [], n = 0;
517   var tno = this.childNodes;
518   for (var i=0,tcli = tno.length;i<tcli;i++) {
519     var tnoi = tno[i];
520     if (tnoi.nodeType === Node.ELEMENT_NODE) {
521       var ns = (namespaceURI === "*") ? tnoi.namespaceURI : namespaceURI;
522       var ln = (localName === "*") ? tnoi.localName : localName;
523       if((tnoi.namespaceURI === ns) && (tnoi.localName === ln)) {
524         s[n++] = tnoi;
525       }
526       var d = tnoi.getElementsByTagNameNS(namespaceURI, localName);
527       if (d) {
528         for (var j=0,dli=d.length;j<dli;++j) {
529           s[n++] = d[j];
530         }
531       }
532       ns = ln = d = void 0;
533     }
534   }
535   tno = i = j = tcli = dli = void 0;
536   if (n === 0) {
537     n = void 0;
538     return null; //該当する要素なし
539   }
540   n = void 0;
541   return s;
542 };
543 /*boolean*/ Element.prototype.hasAttribute = function( /*string*/ name) {
544   return (this.hasAttributeNS(null, name));
545 };
546 /*boolean*/ Element.prototype.hasAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
547   if (this.getAttributeNodeNS(namespaceURI, localName)) { //ノードの取得に成功した場合
548    return true;
549   } else {
550    return false;
551   }
552 };
553
554 /*Text
555  *テキストノード。削除不可。
556  */
557 function Text() {
558   return this;
559 };
560 Text.prototype = new CharacterData();                       //文字データのプロトタイプチェーンを作って、継承
561 Text.constructor = CharacterData;
562 Text.prototype.nodeType = Node.TEXT_NODE;
563 Text.prototype.nodeName = "#text";
564 /*Text*/ Text.prototype.splitText = function(/*long*/ offset) {
565   var pre = this.substringData(0, offset - 1);              //このノードからoffsetまでの文字列を取り出して、
566   this.replaceData(0, this.length - 1, pre);                //このノードの文字列と置き換える
567   var next = "";
568   if (this.length !== offset) {                             //このノードの文字列の長さがoffsetに等しくない場合
569     next = this.substringData(offset, this.length - 1);     //文字列を取り出す。(等しい場合は文字列を取り出さない)
570   }
571   var nnode = this.ownerDocument.createTextNode(next);
572   if (this.parentNode) {
573     this.parentNode.insertBefore(nnode, this.nextSibling);
574   }
575   return nnode;
576 };
577
578 /*Comment
579  *コメントノード。<!-- --!>で表現される。削除不可。
580  */
581 function Comment() {
582   return this;
583 };
584 Comment.prototype = new CharacterData();                    //文字データのプロトタイプチェーンを作って、継承
585 Comment.constructor = CharacterData;
586 Comment.prototype.nodeType = Node.COMMENT_NODE;
587 Comment.prototype.nodeName = "#comment";
588 /*CDATASection
589  *CDATA領域を示すノード。<![CDATA[ ]]!>で表現される。削除不可。
590  */
591 function CDATASection() {
592   this.nodeType = Node.CDATA_SECTION_NODE;
593   this.nodeName = "#cdata-section";
594   return this;
595 };
596 CDATASection.prototype = new Text();                        //テキストノードのプロトタイプチェーンを作って、継承
597 CDATASection.constructor = Text;
598
599 /*DocumentType
600  *DTD(文書型定義)の情報を取り扱うノード。DTDは<!DOCTYPE[ ]>で表現されうる。削除可
601  */
602 function DocumentType() {
603   //以下のメンバは削除可
604   this.name = "";
605   this.entities = new NamedNodeMap();   //パラメタ実体を除く実体の集まり
606   this.notations = new NamedNodeMap();  //DTDで示した記法の集まり
607   this.publicId = "";                   //外部サブセットの公開識別子
608   this.systemId = "";                   //上同のシステム識別子
609   this.internalSubset = "";             //内部サブセットの内容(文字列)
610   this.nodeValue = null;
611   this.nodeType = Node.DOCUMENT_TYPE_NODE;
612   return this;
613 };
614 DocumentType.prototype = new Node();   //ノードのプロトタイプチェーンを作って、継承
615 DocumentType.constructor = Node;
616
617 /*Notation
618  *DTDの記法の情報を取り扱うノード。<!NOTATION >か、処理命令で記法は表現されうる。削除可
619  */
620 function Notation() {
621   this.publicId = null;
622   this.systemId = null;
623   this.nodeValue = null;
624   this.nodeType = Node.NOTATION_NODE;
625   return this;
626 };
627 Notation.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
628 Notation.constructor = Node;
629
630 /*注意
631  *以下のノードは、もし、DOMを展開する前に、XMLプロセッサが実体参照の読み込みを行うのであれば、文書中に挿入される必要はない。
632  */
633 /*Entity
634  *解析対象(外)実体ノード。削除可
635  */
636 function Entity() {
637   this.publicId = null;
638   this.systemId = null;
639   this.notationName = null;      //解析対象外実体のための記法名。解析対象実体ではnull
640   this.nodeValue = null;
641   this.nodeType = Node.ENTITY_NODE;
642   return this;
643 };
644 Entity.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
645 Entity.constructor = Node;
646
647 /*EntityReference
648  *実態参照の代わりに挿入されるノード。削除可
649  */
650 function EntityReference() {
651   this.nodeValue = null;
652   this.nodeType = Node.ENTITY_REFERENCE_NODE ;
653   return this;
654 };
655 EntityReference.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
656 EntityReference.constructor = Node;
657
658 /*ProcessingInstruction
659  *処理命令ノード。スタイルシート処理命令で使うので、削除不可
660  */
661 function ProcessingInstruction() {
662   this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
663   return this;
664 };
665 ProcessingInstruction.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
666 ProcessingInstruction.constructor = Node;
667
668 /*DocumentFragment
669  *複数のノードを移したりするのに便宜上、用いられる文書ノード。削除可
670  */
671 function DocumentFragment() {
672   this.nodeName = "#document-fragment";
673   this.nodeValue = null;
674   this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
675   return this;
676 };
677 DocumentFragment.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
678 DocumentFragment.constructor = Node;
679
680 /*Document
681  *文書ノード。
682  */
683 function Document() {
684   this.nodeName = "#document";
685   this.nodeValue = null;
686   this.nodeType = Node.DOCUMENT_NODE;
687   this._id = {};  //getElementByIdで使う
688   return this;
689 };
690 Document.prototype = new Node();  //ノードのプロトタイプチェーンを作って、継承
691 Document.constructor = Node;
692
693 /*
694  *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること。
695  *また、createメソッドは工場メソッドである。クラス名をユーザから隠蔽するのに役に立つ。
696  *突然、クラス名が変更されても、ライブラリを利用したユーザは、コードを書き換える必要がないなどのメリットがある。
697  */
698 /*Element*/ Document.prototype.createElement = function( /*string*/ tagName) {
699 };
700 /*createDocumentFragmentメソッド
701  *切り貼り用のドキュメントを作る。削除可
702  */
703 /*DocumentFragment*/   Document.prototype.createDocumentFragment = function() {
704   var s = new DocumentFragment();
705   s.ownerDocument = this;
706   return s;
707 };
708 /*createTextNodeメソッド
709  *テキストのノードを作る
710  */
711 /*Text*/               Document.prototype.createTextNode = function( /*string*/ data) {
712   var s = new Text();
713   s.data = s.nodeValue = data+"";
714   s.length = data.length;
715   s.ownerDocument = this;
716   return s;
717 };
718 /*createCommentメソッド
719  *コメントノードを作る
720  */
721 /*Comment*/            Document.prototype.createComment = function( /*string*/ data) {
722   var s = new Comment();
723   s.data = s.nodeValue = data;
724   s.length = data.length;
725   s.ownerDocument = this;
726   return s;
727 };
728 /*createCDATASectionメソッド
729  *CDATA領域ノードを作る
730  */
731 /*CDATASection*/       Document.prototype.createCDATASection = function( /*string*/ data) {
732   var s = new CDATASection();
733   s.data = s.nodeValue = data;
734   s.length = data.length;
735   s.ownerDocument = this;
736   return s;
737 };
738 /*createProcessingInstructionメソッド
739  *処理命令ノードを作る
740  */
741 /*ProcessingInstruction*/ Document.prototype.createProcessingInstruction = function( /*string*/ target, /*string*/ data) {
742   var s = new ProcessingInstruction();
743   s.target = s.nodeName = target;
744   s.data = s.nodeValue = data;
745   s.ownerDocument = this;
746   return s;
747 };
748 /*createAttribute
749  *createAttributeNSを推奨
750  */
751 /*Attr*/               Document.prototype.createAttribute = function( /*string*/ name) {
752 };
753 /*createEntityReferenceメソッド
754  *実体参照ノードを作る
755  */
756 /*EntityReference*/    Document.prototype.createEntityReference = function( /*string*/ name) {
757   var s = new EntityReference();
758   s.nodeName = name;
759   s.ownerDocument = this;
760   return s;
761 };
762 /*getElementsByTagNameメソッド
763  *getElementsByTagNameNSを推奨
764  */
765 /*NodeList*/           Document.prototype.getElementsByTagName = function( /*string*/ tagname) {
766 };
767 /*importNodeメソッド
768  *自身のドキュメントノードに、他のドキュメントノードから作られたノードを取り込みたいときに用いる
769  */
770 /*Node*/               Document.prototype.importNode = function( /*Node*/ importedNode, /*boolean*/ deep) {
771   var s,
772       imn = importedNode.nodeType,
773       attr, att, fi, n, uri, ch;
774   /*以下の処理は引き渡されたimportedNodeがMSXMLによって解析された
775    *データであることを前提にしている
776    */
777   if (imn === /*Node.ELEMENT_NODE*/ 1) {
778     s = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName);
779     attr = importedNode.attributes;
780     for (var i=0;attr[i];++i) { //NamedNodeMapを検索する
781       ch = attr[i];
782       uri = ch.namespaceURI;
783       uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
784       att = this.createAttributeNS(uri, ch.nodeName);
785       att.nodeValue = ch.nodeValue;
786       s.setAttributeNodeNS(att);
787     }
788     if (deep) {
789       fi = importedNode.firstChild;
790       while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
791         n = this.importNode(fi, true);
792         s.appendChild(n);
793         fi = fi.nextSibling;
794       }
795     }
796     i = void 0;
797   } else if(imn === /*Node.TEXT_NODE*/ 3) {
798     s = this.createTextNode(importedNode.data);
799   } else if(imn === /*Node.ATTRIBUTE_NODE*/ 2) {
800     uri = importedNode.namespaceURI;
801     uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
802     s = this.createAttributeNS(uri, importedNode.nodeName);
803     s.nodeValue = importedNode.nodeValue;
804   } else if(imn === /*Node.COMMENT_NODE*/ 8) {
805     s = this.createComment(importedNode.data);
806   } else if(imn === Node.DOCUMENT_FRAGMENT_NODE) {
807     s = this.createDocumentFragment();
808     if (deep) {
809       ch = importedNode.childNodes;
810       for (var i=0,chli=ch.length;i<chli;i++) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
811         n = this.importNode(ch[i], true);
812         s.appendChild(n);
813       }
814     }
815     i = chli = void 0;
816   } else if(imn === Node.CDATA_SECTION_NODE) {
817     s = this.createCDATASection(importedNode.data);
818   } else if(imn === Node.ENTITY_REFERENCE_NODE) {
819     s = this.createEntityReference(importedNode.nodeName);
820     if (deep) {
821       fi = importedNode.firstChild;
822       while (fi) {
823         n = this.importNode(fi, true);
824         s.appendChild(n);
825         fi = fi.nextSibling;
826       }
827     }    
828   } else if(imn === Node.ENTITY_NODE) {
829     s = new Entity();
830     s.publicId = importedNode.publicId;
831     s.systemId = importedNode.systemId;
832     s.notationName = importedNode.notationName;
833   } else if(imn === Node.PROCESSING_INSTRUCTION_NODE ) {
834     s = this.createProcessingInstruction(importedNode.nodeName, importedNode.nodeValue)
835   } else if(imn === Node.NOTATION_NODE) {
836     s = new Notation();
837     s.publicId = importedNode.publicId;
838     s.systemId = importedNode.systemId;
839   } else {
840     throw (new DOMException(DOMException.NOT_SUPPORTED_ERR));
841   }
842   importedNode = deep = imn = attr = att = fi = n = uri = ch = void 0;
843   return s;
844 };
845 /*createElementNSメソッド
846  *要素ノードを作る。削除不可
847  *例:var s = DOC.createElementNS("http://www.w3.org/2000/svg", "svg:svg");
848  */
849 /*Element*/            Document.prototype.createElementNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
850   var ele,
851       prefix = null,
852       localName = null;
853   if (!qualifiedName) {
854     throw (new DOMException(DOMException.INVALID_CHARACTER_ERR));
855   }
856   if (qualifiedName.indexOf(":") !== -1){
857     var p = qualifiedName.split(":");
858     prefix = p[0];
859     localName = p[1];
860   } else {
861     localName = qualifiedName;
862   }
863   var isSpecified = false;
864   if (namespaceURI) {
865     var ti = this.implementation;
866     if (!!ti[namespaceURI]) {
867       if (!!ti[namespaceURI][localName]) { //もし、名前空間とローカル名によって、オブジェクトがあった場合
868         isSpecified = true;
869       }
870     }
871   }
872   if (isSpecified) {
873     ele = new (ti[namespaceURI][localName])(this._document_);
874   } else {
875     ele = new Element();
876   }
877   ele.namespaceURI = namespaceURI;
878   ele.nodeName = ele.tagName = qualifiedName;
879   ele.localName = localName;
880   ele.prefix = prefix;
881   ele.ownerDocument = this;
882   ti = namespaceURI = qualifiedName = prefix = localName = isSpecified = void 0;
883   return ele;
884 };
885 Document.prototype._document_ = document
886 /*createAttributeNSメソッド
887  *属性ノードを作る。setAttributeNSで使うため、削除不可
888  */
889 /*Attr*/               Document.prototype.createAttributeNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
890   var attr = new Attr(),
891       p;
892   attr.namespaceURI = namespaceURI;
893   attr.nodeName = attr.name = qualifiedName;
894   if (qualifiedName.indexOf(":") !== -1){
895    p = qualifiedName.split(":");
896     attr.prefix = p[0];
897     attr.localName = p[1];
898   } else {
899     attr.prefix = null;
900     attr.localName = qualifiedName;
901   }
902   attr.ownerDocument = this;
903   p = qualifiedName = void 0;
904   return attr;
905 };
906 /*getElementsByTagNameNSメソッド
907  *タグ名と名前空間URIを元に、要素ノード達を取得
908  */
909 /*NodeList*/           Document.prototype.getElementsByTagNameNS = function(/*string*/ namespaceURI, /*string*/ localName) {
910   var NodeList = this.documentElement.getElementsByTagNameNS(namespaceURI, localName);
911   return NodeList;
912 };
913 /*getElementByIdメソッド
914  *id属性の値で要素ノードを指定
915  */
916 /*Element*/            Document.prototype.getElementById = function( /*string*/ elementId) {
917   var s = !!this._id[elementId] ? this._id[elementId] : null;
918   return s;
919 };
920
921 /*
922 #endif // _DOM_IDL_*/
923 
924 //以下は例外処理のログをとるためのもの。開発者以外は削除すること
925 function STLog(jou) {
926 this.jo = jou;
927 if (this.jo) {
928   this.p = document.createElement("div");
929   this.p.innerHTML = "<h1>例外処理のログ</h1>";
930   document.body.insertBefore(this.p,document.body.firstChild);
931 }
932   return this;
933 }
934 STLog.prototype.add = function(e,code) {
935 if (this.jo) {
936   this.p.innerHTML += "<p>"+code+":"+e.message+"</p>";
937 }
938 }
939 /*
940
941 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.idl
942
943 #ifndef _EVENTS_IDL_
944 #define _EVENTS_IDL_
945
946 #include "dom.idl"
947 #include "views.idl"
948
949 #pragma prefix "dom.w3c.org"
950 module events
951 {
952
953   typedef dom::DOMString DOMString;
954   typedef dom::DOMTimeStamp DOMTimeStamp;
955   typedef dom::Node Node;
956
957   interface EventListener;
958   interface Event;
959 */
960 /*EventExceptionクラス
961  *イベント専用の例外クラス。
962  */
963 function EventException() {
964   DOMException.call(this,arguments);
965   if (this.code === 0) {
966     this.message = "Uuspecified Event Type Error";
967   }
968   return this;
969 };
970 /*unsigned short*/  EventException.UNSPECIFIED_EVENT_TYPE_ERR = 0;
971
972 EventException.prototype = new DOMException();
973
974
975 /*  // Introduced in DOM Level 2:
976   interface EventTarget {*/
977 /*void*/  Node.prototype.addEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
978   this.removeEventListener(type, listener, useCapture);  //いったん、(あれば)リスナーを離す。
979   var s = new EventListener(useCapture, type, listener), //リスナーを作成
980       t = type.charAt(0),
981       that;
982   this._capter.push(s);                 //このノードにリスナーを登録しておく
983   if ((t !== "D") && (t !== "S") && (type !== "beginEvent") && (type !== "endEvent") && (type !== "repeatEvent")) { //MouseEventsならば
984     that = this;
985     that._tar && that._tar.attachEvent("on" +type, (function(node, type) { 
986       return  function(){
987         var evt = node.ownerDocument.createEvent("MouseEvents");
988         evt.initMouseEvent(type, true, true, node.ownerDocument.defaultView, 0);
989         node.dispatchEvent(evt);
990         /*cancelBubbleプロパティについては、IEのMSDNなどを参照*/
991         node.ownerDocument._window.event.cancelBubble = true;
992         evt = void 0;
993       };
994     })(that, type)
995     );
996   }
997   type = listener = useCapture = s = t = that = void 0;
998 };
999 /*void*/  Node.prototype.removeEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
1000   var tce = this._capter;
1001   for (var i=0,tcli=tce.length;i<tcli;i++){
1002     if (tce[i]._listener === listener) {  //登録したリスナーと一致すれば
1003       tce[i] = void 0;
1004     }
1005   }
1006   i = tcli = tce = void 0;
1007 };
1008 /*boolean*/  Node.prototype.dispatchEvent = function( /*Event*/ evt) {
1009   if (!evt.type) { //Eventの型が設定されていないとき
1010     throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
1011   }
1012   var te = this,
1013       td = te.ownerDocument,
1014       etime = evt.timeStamp,
1015       etype = evt.type,
1016       ebub = evt.bubbles,
1017       tob,
1018       toli,
1019       type = /*Event.CAPTURING_PHASE*/ 1,
1020       ecptype = /*Event.CAPTURING_PHASE*/ "1",
1021       ebptype = /*Event.BUBBLING_PHASE*/ "3",
1022       tce;
1023   if (!td._isLoaded) {
1024     /*以下では、画像の処理に時間がかかりそうな場合、処理落ちとして、遅延処理
1025      *を行い、バッファリングにイベント送付処理をためていく作業となる
1026      */
1027     if (!td._limit_time_) {
1028       td._limit_time_ = etime;
1029     } else if ((etime - td._limit_time_) > 1000) {
1030       /*1秒を超えたらバッファにため込んで後で使う*/
1031       tob = td.implementation._buffer_ || [];
1032       toli = tob.length
1033       tob[toli] = this;
1034       tob[toli+1] = evt;
1035       td.implementation._buffer_ = tob;
1036       te = td = etime = etype = ebub = tob = toli = type = void 0;
1037       return true;
1038     }
1039   }
1040   evt.target = te;
1041   evt.eventPhase = 1;//Event.CAPTURING_PHASE
1042   //このノードからドキュメントノードにいたるまでの、DOMツリーのリストを作成しておく
1043   td[ebptype] = null;
1044   /*以下の処理では、documentElementのparentNodeが
1045    *Documentノードではなく、nullになっていることを前提としている。
1046    *したがって、documentElementのparentNodeがもし、Documentノードのオブジェクトならば、以下を書き換えるべきである
1047    */
1048   while (te.parentNode) {
1049     te.parentNode[ecptype] = te;
1050     te[ebptype] = te.parentNode;
1051     te = te.parentNode;
1052   }
1053   td[ecptype] = te;
1054   te[ebptype] = td;
1055   /*最初に捕獲フェーズでDOMツリーを下っていき、イベントのターゲットについたら、
1056    *そこで、浮上フェーズとして折り返すように、反復処理をおこなう。
1057    */
1058   te = this;
1059   while (td) {
1060     evt.currentTarget = td;
1061     if (td === te) { //イベントのターゲットに到着(折り返し地点)
1062       type = 2;//Event.AT_TARGET;
1063     }
1064     evt.eventPhase = type;
1065     tce = td._capter; //tceは登録しておいたリスナーのリスト
1066     for (var j=0,tcli=tce.length;j<tcli;++j){
1067       if (tce[j] && (etype === tce[j]._type)) {
1068         tce[j].handleEvent(evt);
1069       }
1070     }
1071     if (evt._stop) {
1072       break; //stopPropagationメソッドが呼ばれたら、停止する
1073     }
1074     if (td === te) {
1075       if (!ebub) {
1076         break; //浮上フェーズに移行せず、停止する
1077       }
1078       type = 3;//Event.BUBBLING_PHASE;
1079     }
1080     td = td[type];
1081   }
1082   var ed = evt._default;
1083   evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub = ecptype = ebptype = void 0;
1084   return ed;
1085 };
1086
1087 function EventListener(cap,type,listener) {
1088   this._cap = cap;
1089   this._type = type;
1090   this._listener = listener;
1091   return this;
1092 };
1093
1094 EventListener.prototype = {
1095 /*void*/ handleEvent : function( /*Event*/ evt) {
1096     try {
1097       var ph = evt.eventPhase,
1098           cap = this._cap;
1099       if (ph === /*Event.CAPTURING_PHASE*/ 1) { //イベントフェーズが捕獲段階であることを示し
1100         cap = cap ? false : true;         //このオブジェクト(EventListenr)が捕獲フェーズを指定するならば、リスナーを作動させる。指定しなければ、作動しない。
1101       }
1102       if (!cap && (evt.type === this._type)) {
1103         this._listener(evt);
1104       }
1105       evt = ph = cap = void 0;
1106     } catch (e) {
1107       
1108     }
1109   }
1110 };
1111
1112 /*Eventクラス
1113  *イベントの雛形となる。プロパティもすべて含めて、必須
1114  */
1115 function Event() {
1116   return this;
1117 };
1118 // PhaseType
1119 /*unsigned short*/ Event.CAPTURING_PHASE   = 1;
1120 /*unsigned short*/ Event.AT_TARGET         = 2;
1121 /*unsigned short*/ Event.BUBBLING_PHASE    = 3;
1122 Event.prototype = {
1123   /*DOMTimeStamp*/     timeStamp : 0,
1124   /*DOMString*/        type : null,
1125   /*EventTarget*/      target : null,
1126   /*EventTarget*/      currentTarget : null,
1127   /*unsigned short*/   eventPhase : Event.CAPTURING_PHASE,
1128   /*boolean*/          bubbles : false,
1129   /*boolean*/          cancelable : false,
1130   _stop : false, //stopPropagationメソッドで使う
1131   _default : true, //preventDefaultメソッドで使う
1132   /*void*/ stopPropagation : function(){
1133     this._stop = true;
1134   },
1135   /*void*/ preventDefault : function(){
1136     if (this.cancelable) {
1137       this._default = false;
1138       /*IEのみで使えるreturnValueプロパティ*/
1139       this.target.ownerDocument._window.event.returnValue = false;
1140     }
1141   },
1142   /*void*/ initEvent : function( /*string*/ eventTypeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg) {
1143     this.type = eventTypeArg;
1144     this.bubbles = canBubbleArg;
1145     this.cancelable = cancelableArg;
1146     eventTypeArg = canBubbleArg = cancelableArg = void 0;
1147   }
1148 };
1149 /*Documentノードに直接結びつける
1150 function DocumentEvent() {
1151   return this;
1152 }*/
1153 /*Event*/ Document.prototype.createEvent = function( /*string*/ eventType) {
1154   var evt,
1155       tc = this._cevent[eventType];
1156   if (tc) {
1157     evt = new tc();
1158   } else if (eventType === "SVGEvents") {
1159     evt = new SVGEvent();
1160   } else if (eventType === "TimeEvents") {
1161     evt = new TimeEvent();
1162   } else {
1163     evt =  new Event();
1164   }
1165   evt.type = eventType;
1166   evt.timeStamp = +(new Date());
1167   eventType = void 0;
1168   return evt;
1169 };
1170
1171 function UIEvent() {
1172 /*views::AbstractView*/  this.view;
1173 /*long*/                 this.detail = 0;
1174   return this;
1175 };
1176
1177 UIEvent.prototype = new Event();
1178 /*void*/ UIEvent.prototype.initUIEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg) {
1179   this.initEvent(typeArg, canBubbleArg, cancelableArg);
1180   this.detail = detailArg;
1181   this.view = viewArg;
1182 };
1183 function MouseEvent(evt) {
1184   UIEvent.call(this, arguments);
1185 /*long*/             this.screenX;
1186 /*long*/             this.screenY;
1187 /*long*/             this.clientX = this.clientY = 0;
1188 /*boolean*/          this.ctrlKey = this.shiftKey = this.altKey = this.metaKey = false;
1189 /*unsigned short*/   this.button;
1190 /*EventTarget*/      this.relatedTarget;
1191   return this;
1192 };
1193 MouseEvent.prototype = new UIEvent();
1194 /*void*/ MouseEvent.prototype.initMouseEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg, /*long*/ screenXArg, /*long*/ screenYArg, /*long*/ clientXArg, /*long*/ clientYArg, /*boolean*/ ctrlKeyArg, /*boolean*/ altKeyArg, /*boolean*/ shiftKeyArg, /*boolean*/ metaKeyArg, /*unsigned short*/ buttonArg, /*EventTarget*/ relatedTargetArg) {
1195   this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
1196   this.screenX = screenXArg;
1197   this.screenY = screenYArg;
1198   this.clientX  = clientXArg;
1199   this.clientY  = clientYArg;
1200   this.ctrlKey  = ctrlKeyArg;
1201   this.shiftKey = shiftKeyArg;
1202   this.altKey   = altKeyArg;
1203   this.metaKey  = metaKeyArg;
1204   this.button = buttonArg;
1205   this.relatedTarget = relatedTargetArg;
1206 };
1207
1208 function MutationEvent(){
1209   return this;
1210 };
1211 MutationEvent.prototype = new Event();
1212 (function() {
1213 /*void*/  this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
1214     /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
1215     /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
1216     this.initEvent(typeArg, canBubbleArg, cancelableArg);
1217     this.relatedNode = relatedNodeArg;
1218     this.prevValue = prevValueArg;
1219     this.newValue = newValueArg;
1220     this.attrName = attrNameArg;
1221     this.attrChange = attrChangeArg;
1222     typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = void 0;
1223   };
1224   /*Node*/  this.relatedNode = null;
1225   /*string*/  this.prevValue = this.newValue = this.attrName = null;
1226   /*unsigned short*/  this.attrChange = 2;
1227 }).apply(MutationEvent.prototype);
1228     // attrChangeType
1229 /*unsigned short*/  MutationEvent.MODIFICATION  = 1;
1230 /*unsigned short*/  MutationEvent.ADDITION      = 2;
1231 /*unsigned short*/  MutationEvent.REMOVAL       = 3;
1232
1233 /*MutationEventsの発動のために、setAttributeNodeNSを上書きする。ファイル統合やmakeの際は、
1234  *重複するのでコアモジュールのメソッドは削除する。モジュールテストを行うために、
1235  *このような形式をとることにする。なお、追加部分には区別を付けるために、前後にコメントを挿入する。
1236  */
1237 /*Attr*/ Element.prototype.setAttributeNodeNS = function( /*Attr*/ newAttr){
1238   if (newAttr.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1239     throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1240   }
1241   var s = this.attributes.setNamedItemNS(newAttr);
1242   newAttr.ownerElement = this;
1243   if ((newAttr.localName === "id") && !this.ownerDocument._id[newAttr.nodeValue]) {  //id属性であったならば
1244     this.ownerDocument._id[newAttr.nodeValue] = this; //ドキュメントに登録しておく
1245   }
1246   /*ここから*/
1247   var evt = this.ownerDocument.createEvent("MutationEvents");
1248   if (!s) { //ノードがなければ
1249     /*initMutationEventメソッドは軽量化のため省略する*/
1250     evt.initEvent("DOMAttrModified", true, false);
1251     evt.relatedNode = newAttr;
1252     evt.newValue = newAttr.nodeValue;
1253     evt.attrName = newAttr.nodeName;
1254   } else {
1255     evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
1256   }
1257   this.dispatchEvent(evt); //このとき、MutationEventsが発動
1258   evt = void 0;
1259   /*ここまで追加*/
1260   return s;
1261 };
1262
1263 /*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
1264   var tp = this.parentNode,
1265       np = n.parentNode,
1266       rp, evt,
1267       te = this,
1268       s, descend, di;
1269   if (tp) {
1270     while (!tp) {                              //先祖をたどっていく
1271       if (tp === n) {                          //先祖要素が追加ノードならばエラー
1272         throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1273       }
1274       tp = tp.parentNode;
1275     }
1276   }
1277   if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1278     throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1279   }
1280   if (np === this) {                  //入力した要素が子要素ならば
1281     this.removeChild(n);
1282   }
1283   if (np) {
1284     (n === np.firstChild) && (np.firstChild = n.nextSibling);
1285     (n === np.lastChild ) && (np.lastChild = n.previousSibling);
1286   }
1287   if (!ref) {                                   //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1288     n._num = this.childNodes.length;
1289     this.childNodes[n._num] = n;
1290     if (this.lastChild) {
1291       n.previousSibling = this.lastChild;
1292       this.lastChild.nextSibling = n;
1293     }
1294   } else {
1295     if (ref.parentNode !== this) {              //参照ノードが子要素でない場合
1296       throw (new DOMException(DOMException.NOT_FOUND_ERR));
1297     }
1298     this.childNodes.splice(ref._num,1,n,ref);   //Arrayのspliceを利用して、リストにnノードを追加
1299     rp = ref.previousSibling;
1300     if (rp) {
1301       rp.nextSibling = n;
1302     }
1303     ref.previousSibling = n;
1304   }
1305   n.nextSibling = ref;
1306   this.firstChild = this.childNodes[0];
1307   this.lastChild = this.childNodes[this.childNodes.length-1];
1308   n.parentNode = this;
1309   if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1310     /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1311      *それらを直接文書に埋め込む作業を以下で行う
1312      */
1313     var ch = n.childNodes.concat([]); //Arrayのコピー
1314     for (var i=0,chli=ch.length;i<chli;i++) {
1315       this.insertBefore(ch[i], n);
1316     }
1317     ch = void 0;
1318   }
1319   /*ここから*/
1320   evt = this.ownerDocument.createEvent("MutationEvents");
1321   evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1322   n.dispatchEvent(evt);
1323   /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1324    *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1325    *このイベントは浮上しないことに注意を要する
1326    */
1327   do {
1328     s = te;
1329     te = te.parentNode;
1330   } while (te);
1331   if (s !== this.ownerDocument.documentElement) {
1332     evt = s = void 0;
1333     return n;
1334   }
1335   evt = this.ownerDocument.createEvent("MutationEvents");
1336   evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1337   n.dispatchEvent(evt);
1338   if (!n.hasChildNodes()) {                       //子ノードがないので終了
1339     return n;
1340   }
1341   if (n.getElementsByTagNameNS) {
1342     descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1343   } else {
1344     descend = n.childNodes;
1345   }
1346   if (descend) {
1347     for (var i=0,dli=descend.length;i<dli;++i) {
1348       di = descend[i];
1349       di.dispatchEvent(evt);
1350       di = null;
1351     }
1352   }
1353   evt = descend = void 0;
1354   tp = np = rp = te = s = di = void 0;
1355   return n;
1356 };
1357
1358 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1359   if (!(ele instanceof Node)) {                   //Nodeでなければ
1360     throw (new Error());
1361   }
1362   /*ここから*/
1363   var evt = this.ownerDocument.createEvent("MutationEvents"),
1364       descend;
1365   /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1366    *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1367    *このイベントは浮上しないことに注意を要する
1368    */
1369   evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1370   ele.dispatchEvent(evt);
1371   if (ele.getElementsByTagNameNS) {
1372     descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1373   } else {
1374     descend = ele.childNodes;
1375   }
1376   if (descend) {
1377     evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1378     for (var i=0,dli=descend.length;i<dli;++i) {
1379       var di = descend[i];
1380       evt.target = di;
1381       di.dispatchEvent(evt);
1382       di = void 0;
1383     }
1384   }
1385   evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1386   ele.dispatchEvent(evt);
1387   evt = descend = void 0;
1388   /*ここまで追加*/
1389   if (ele.parentNode === this) {
1390     this.childNodes.splice(ele._num,1);           //Arrayのspliceを利用して、リストからeleノードを排除
1391     if (this.firstChild === ele) {
1392       this.firstChild = null;
1393     }
1394     if (this.lastChild === ele) {
1395       this.lastChild = null;
1396     }
1397     ele.previousSibling && (ele.previousSibling.nextSibling = ele.nextSibling);
1398     ele.nextSibling && (ele.nextSibling.previousSibling = ele.previousSibling);
1399   } else {                                        //親が違う場合
1400     throw (new DOMException(DOMException.NOT_FOUND_ERR));
1401   }
1402   if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1403     throw (new Error());
1404   }
1405   return ele;
1406 };
1407
1408 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
1409   var pd = this.data,
1410       evt;
1411   this.data += arg;
1412   this.length = this.data.length;
1413   /*ここから*/
1414   evt = this.ownerDocument.createEvent("MutationEvents");
1415   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1416   this.parentNode.dispatchEvent(evt);
1417   evt = arg = pd = void 0;
1418   /*ここまで追加*/
1419 };
1420 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1421   var pd = this.data,
1422       pre = this.substring(0, offset - 1),                 //文字列を二つに分けた、前半部分
1423       next = this.substring(offset, this.length - offset), //後半部分
1424       evt;
1425   this.data = pre + this.data + next;
1426   this.length = this.data.length;
1427   /*ここから*/
1428   evt = this.ownerDocument.createEvent("MutationEvents");
1429   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1430   this.parentNode.dispatchEvent(evt);
1431   evt = arg = pd = pre = next = void 0;
1432   /*ここまで追加*/
1433 };
1434 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1435   var pd = this.data;
1436       pre = this.substring(0, offset - 1),                    //残すべき前半部分
1437       next = this.substring(offset + count, this.length - 1), //後半部分
1438       evt;
1439   if (offset + count > this.length) {                         //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1440     next = "";
1441   }
1442   this.data = pre + next;
1443   this.length = this.data.length;
1444   /*ここから*/
1445   evt = this.ownerDocument.createEvent("MutationEvents");
1446   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1447   this.parentNode.dispatchEvent(evt);
1448   evt = pd = void 0;
1449   /*ここまで追加*/
1450 };
1451
1452 /*_ceventプロパティはcreateEventメソッドで軽量化のために使う。*/
1453 Document.prototype._cevent = {
1454     "MutationEvents" : MutationEvent,
1455     "MouseEvents" : MouseEvent,
1456     "UIEvents" : UIEvent
1457 };
1458
1459
1460 // _EVENTS_IDL_
1461 
1462 /*
1463 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1464
1465 #ifndef _STYLESHEETS_IDL_
1466 #define _STYLESHEETS_IDL_
1467
1468 #include "dom.idl"
1469
1470 #pragma prefix "dom.w3c.org"
1471 module stylesheets
1472 {
1473
1474   typedef dom::DOMString DOMString;
1475   typedef dom::Node Node;
1476 */
1477
1478 /*StyleSheet
1479  *スタイルシート文書を示す。削除不可。
1480  */
1481 function StyleSheet() {
1482  this.type = "text/css";
1483  this.disabled = false;
1484  /*Node*/ this.ownerNode = null;
1485  /*StyleSheet*/ this.parentStyleSheet = null;
1486  this.href = null;
1487  this.title = "";
1488  /*MediaList*/ this.media = new MediaList();
1489  return this;
1490 };
1491
1492 /*StyleSheetList
1493  *このインターフェースはArrayで代用する
1494 function StyleSheetList() {
1495     readonly attribute unsigned long    length;
1496     StyleSheet         item(in unsigned long index);
1497   };
1498 */
1499
1500 function MediaList() {
1501  this.mediaText = "";
1502  this.length = 0;
1503  return this;
1504 };
1505 MediaList.prototype = {
1506 /*string*/ item : function(/*long*/ index) {
1507     return (this[index]);
1508   },
1509 /*void*/   deleteMedium : function(/*string*/ oldMedium) {
1510     for (var i=0,tli=this.length;i<tli;++i) {
1511       if (this[i] === oldMedium) {
1512         delete this[i];
1513         --this.length;
1514         return;
1515       }
1516     }
1517     throw (new DOMException(DOMException.NOT_FOUND_ERR));
1518   },
1519 /*void*/   appendMedium : function(/*string*/ newMedium) {
1520     this[this.length] = newMedium;
1521     ++this.length;
1522   }
1523 };
1524
1525 function LinkStyle() {
1526  /*StyleSheet*/ this.sheet = new StyleSheet();
1527  return this;
1528 };
1529
1530 function DocumentStyle() {
1531  /*StyleSheetList*/ this.styleSheets = [];
1532  return this;
1533 };
1534 /*
1535 #endif // _STYLESHEETS_IDL_
1536 */
1537 /*
1538 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1539
1540 #ifndef _CSS_IDL_
1541 #define _CSS_IDL_
1542
1543 #include "dom.idl"
1544 #include "stylesheets.idl"
1545 #include "views.idl"
1546
1547 #pragma prefix "dom.w3c.org"
1548 module css
1549 {
1550
1551   typedef dom::DOMString DOMString;
1552   typedef dom::Element Element;
1553   typedef dom::DOMImplementation DOMImplementation;
1554
1555   interface CSSRule;
1556   interface CSSStyleSheet;
1557   interface CSSStyleDeclaration;
1558   interface CSSValue;
1559   interface Counter;
1560   interface Rect;
1561   interface RGBColor;
1562 */
1563 /*CSSRuleList
1564  *Arrayで代用
1565 function CSSRuleList {
1566     readonly attribute unsigned long    length;
1567     CSSRule            item(in unsigned long index);
1568   };
1569 */
1570 /*CSSRule
1571  *CSSのルールを表現する。基底クラスなので削除不可。
1572  */
1573 function CSSRule() {
1574   this.cssText = "";
1575 /*CSSStyleSheet*/ this.parentStyleSheet;
1576 /*CSSRule*/       this.parentRule = null;
1577   return this;
1578 };
1579 // RuleType
1580 CSSRule.UNKNOWN_RULE                   = 0;
1581 CSSRule.STYLE_RULE                     = 1;
1582 CSSRule.CHARSET_RULE                   = 2;
1583 CSSRule.IMPORT_RULE                    = 3;
1584 CSSRule.MEDIA_RULE                     = 4;
1585 CSSRule.FONT_FACE_RULE                 = 5;
1586 CSSRule.PAGE_RULE                      = 6;
1587
1588 function CSSStyleRule() {
1589   CSSRule.call(this, arguments);
1590   this.type = CSSRule.STYLE_RULE;
1591   this.selectorText = "";
1592 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1593   this.style.parentRule = null;
1594   return this;
1595 };
1596 CSSStyleRule.prototype = new CSSRule();
1597
1598 function CSSMediaRule() {
1599   CSSRule.call(this, arguments);
1600   this.type = CSSRule.MEDIA_RULE;
1601 /*stylesheets::MediaList*/ this.media = new MediaList();
1602 /*CSSRuleList*/ this.cssRules = [];
1603   return this;
1604 };
1605 CSSMediaRule.prototype = new CSSRule();
1606 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1607   this.cssRules.splice(index,rule,1);
1608   this.media.appendMedium(rule);
1609   return this;
1610 };
1611 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1612 };
1613
1614 function CSSFontFaceRule() {
1615   CSSRule.call(this, arguments);
1616   this.type = CSSRule.FONT_FACE_RULE;
1617 /*CSSStyleDeclaration*/ this.style;
1618   return this;
1619 };
1620 CSSFontFaceRule.prototype = new CSSRule();
1621
1622 function CSSPageRule() {
1623   CSSRule.call(this, arguments);
1624   this.type = CSSRule.PAGE_RULE;
1625   this.selectorText = "";
1626 /*CSSStyleDeclaration*/ this.style;
1627   return this;
1628 };
1629 CSSPageRule.prototype = new CSSRule();
1630
1631 function CSSImportRule() {
1632   CSSRule.call(this, arguments);
1633   this.type = CSSRule.IMPORT_RULE;
1634   this.href = "";
1635 /*stylesheets::MediaList*/ this.media = new MediaList();
1636 /*CSSStyleSheet*/ this.styleSheet = null;
1637   return this;
1638 };
1639 CSSImportRule.prototype = new CSSRule();
1640
1641 function CSSCharsetRule() {
1642   CSSRule.call(this, arguments);
1643   this.type = CSSRule.CHARSET_RULE;
1644   this.encoding = "";
1645   return this;
1646 };
1647 CSSCharsetRule.prototype = new CSSRule();
1648
1649 function CSSUnknownRule() {
1650   CSSRule.call(this, arguments);
1651   this.type = CSSRule.UNKNOWN_RULE;
1652   return this;
1653 };
1654 CSSUnknownRule.prototype = new CSSRule();
1655
1656 /*CSSStyleDeclaration
1657  *CSSの宣言ブロックを表現。削除不可。
1658  */
1659 function CSSStyleDeclaration() {
1660   this._list = []; //内部のリスト
1661   this._list._fontSize = this._list._opacity = null;
1662   return this;
1663 };
1664 CSSStyleDeclaration.prototype = {
1665   cssText : "",
1666   /*long*/ length : 0,
1667   /*CSSRule*/ parentRule : null,
1668   _urlreg : /url\(#([^)]+)/,
1669   /*getPropertyValueメソッド
1670    *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1671    */
1672 /*string*/   getPropertyValue : function( /*string*/ propertyName) {
1673     var tg = this.getPropertyCSSValue(propertyName);
1674     if (tg) {                             //見つかった場合
1675       var tc = tg.cssText;
1676       return (tc.slice(tc.indexOf(":")+1));
1677     } else {
1678       return "";
1679     }
1680   },
1681   /*getPropertyCSSValueメソッド
1682    *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1683    */
1684 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1685     var prop = propertyName,
1686         ti, tc;
1687     propertyName += ":";
1688     if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1689       return null;
1690     }
1691     for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1692       ti = tl[i];
1693       tc = ti.cssText;
1694       if (tc.indexOf(propertyName) > -1) {  //プロパティ名に合致するCSSValueオブジェクトが見つかった場合 
1695         ti._empercents = tl._fontSize;
1696         i = tl = tli = tc = prop = propertyName = void 0;
1697         return ti;
1698       }
1699     }
1700     i = tl = tli = prop = propertyName = void 0;
1701     return null;
1702   },
1703   /*removePropertyメソッド
1704    *プロパティを宣言内から除去
1705    */
1706 /*string*/   removeProperty : function( /*string*/ propertyName) {
1707     var tg = this.getPropertyCSSValue(propertyName);
1708     if (tg) {                        //見つかった場合
1709       this._list.splice(tg._num,1);  //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1710       --this.length;
1711     }
1712   },
1713   /*getPropertyPriorityメソッド
1714    *importantなどのpriorityを取得する
1715    */
1716 /*string*/   getPropertyPriority : function( /*string*/ propertyName) {
1717     var tg = this.getPropertyCSSValue(propertyName);
1718     if (tg) {                        //見つかった場合
1719       return (tg._priority);
1720     } else {
1721       return "";
1722     }
1723   },
1724   _isFillStroke : {
1725     "fill" : 1,
1726     "stroke" : 1
1727   },
1728   _isColor : {
1729     "color" : 1
1730   },
1731   _isStop : {
1732     "stop-color" : 1
1733   },
1734   _isRS : {
1735     "r" : 1,
1736     "#" : 1
1737   },
1738   /*setPropertyメソッド
1739    *プロパティを宣言内で、明示的に設定。継承は無視する
1740    */
1741 /*void*/     setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1742     var cssText = propertyName,
1743         tg = null,
1744         ti, paintType, v1,
1745         uri = null,
1746         color = null,
1747         fill, stroke, stop;
1748     if (!!this[propertyName]) {
1749       tg = this.getPropertyCSSValue(propertyName);
1750     }
1751     cssText += ":";
1752     cssText += value;
1753     if (this._isFillStroke[propertyName]) {
1754       /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1755        *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1756        */
1757       if (tg) {  //見つかった場合
1758         ti = tg;
1759       } else {
1760         ti = new SVGPaint();
1761       }
1762       paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1763       v1 = value.charAt(0);
1764       if (this._isRS[v1] || ti._keywords[value]) {
1765         paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1766         color = value;
1767       } else if (value === "none") {
1768         paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1769       } else if (this._urlreg.test(value)) {                   //fill属性の値がurl(#id)ならば
1770         paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1771         uri = RegExp.$1;
1772       } else if (value === "currentColor") {
1773         paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1774       }
1775       ti.setPaint(paintType, uri, color, null);
1776       paintType = v1 = uri = color = void 0;
1777     } else if (this._isStop[propertyName]) {
1778       if (tg) {  //見つかった場合
1779         ti = tg;
1780       } else {
1781         ti = new SVGColor();
1782       }
1783       if (value === "currentColor") {
1784         ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1785       } else {
1786         ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1787       }
1788       ti.setRGBColor(value);
1789     } else {
1790       if (tg) {  //見つかった場合
1791         ti = tg;
1792       } else {
1793         ti = new CSSPrimitiveValue();
1794       }
1795     }
1796     ti._priority = priority;
1797     ti.cssText = cssText;
1798     if (!tg) {
1799       //_numプロパティはremovePropertyメソッドで利用する
1800       ti._num = this._list.length;
1801       this._list[ti._num] = ti;
1802       this[propertyName] = 1;
1803       ++this.length;
1804     }
1805     if (value === "inherit") {
1806       ti.cssValueType = CSSValue.CSS_INHERIT;
1807     } else if (propertyName === "opacity") {
1808       this._list._opacity = +value;
1809     } else if (propertyName === "font-size") {
1810       if (/(%|em|ex)/.test(value)) {
1811         tg = "_" +RegExP.$1
1812         ti[tg] = parseFloat(value);
1813       } else {
1814         this._em = this._ex = this["_%"] = null;
1815         this._list._fontSize = parseFloat(value);
1816       }
1817     }
1818     cssText = void 0;
1819   },
1820   /*itemメソッド
1821    *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1822    */
1823 /*string*/   item : function( /*long*/ index) {
1824     if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1825       var s = "";
1826     } else {
1827       var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1828     }
1829     return s;
1830   }
1831 };
1832
1833 function CSSValue() {
1834   return this;
1835 };
1836     // UnitTypes
1837 CSSValue.CSS_INHERIT                    = 0;
1838 CSSValue.CSS_PRIMITIVE_VALUE            = 1;
1839 CSSValue.CSS_VALUE_LIST                 = 2;
1840 CSSValue.CSS_CUSTOM                     = 3;
1841 CSSValue.prototype = {
1842   cssText : "",
1843   cssValueType : CSSValue.CSS_CUSTOM,
1844   _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1845 };
1846
1847 function CSSPrimitiveValue() {
1848   return this;
1849 };
1850
1851 (function(t) {
1852 t.CSS_UNKNOWN                    = 0;
1853 t.CSS_NUMBER                     = 1;
1854 t.CSS_PERCENTAGE                 = 2;
1855 t.CSS_EMS                        = 3;
1856 t.CSS_EXS                        = 4;
1857 t.CSS_PX                         = 5;
1858 t.CSS_CM                         = 6;
1859 t.CSS_MM                         = 7;
1860 t.CSS_IN                         = 8;
1861 t.CSS_PT                         = 9;
1862 t.CSS_PC                         = 10;
1863 t.CSS_DEG                        = 11;
1864 t.CSS_RAD                        = 12;
1865 t.CSS_GRAD                       = 13;
1866 t.CSS_MS                         = 14;
1867 t.CSS_S                          = 15;
1868 t.CSS_HZ                         = 16;
1869 t.CSS_KHZ                        = 17;
1870 t.CSS_DIMENSION                  = 18;
1871 t.CSS_STRING                     = 19;
1872 t.CSS_URI                        = 20;
1873 t.CSS_IDENT                      = 21;
1874 t.CSS_ATTR                       = 22;
1875 t.CSS_COUNTER                    = 23;
1876 t.CSS_RECT                       = 24;
1877 t.CSS_RGBCOLOR                   = 25;
1878 t.prototype = new CSSValue();
1879 })(CSSPrimitiveValue);
1880
1881 (function(){
1882   this._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15, 1, 180 / Math.PI, 90/100, 1, 1000, 1, 1000, 1]; //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)
1883   this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1884   this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1885   this._value = null;
1886   this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1887   this._empercent = 0;
1888   this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1889   /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1890     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1891       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1892     }
1893     this.primitiveType = unitType;
1894     this._value = floatValue * this._n[unitType-1];  //値はあらかじめ、利用しやすいように変換しておく
1895   };
1896   /*getFloatValueメソッド
1897    *別の単位に変換可能。
1898    */
1899   this._regd = /[\d\.]+/;
1900   /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1901     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1902       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1903     }
1904     if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1905       return (this._value / this._n[unitType-1]);
1906     } else {
1907       var tc = this.cssText,
1908           n = tc.slice(-1),
1909           type = 0,
1910           s = +(tc.match(this._regd));
1911       s = isNaN(s) ? 0 : s;
1912       if (n >= "0" && n <= "9") {
1913         type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1914         if (unitType === 1) {
1915           unitType = tc = n = type = void 0;
1916           return s;
1917         }
1918       } else if (n === "%") {
1919         s *= this._percent;
1920         type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1921       } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1922         s *= this._empercent;
1923         type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1924       } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1925         type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1926       } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1927         type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1928       } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1929         type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1930       } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1931         type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1932       } else if (n === "n") {
1933         type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1934       } else if (n === "t") {
1935         type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1936       } else if (n === "c") {
1937         type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1938       }
1939       s = s * this._n[type-1] / this._n[unitType-1];
1940       tc = n = type = unitType = void 0;
1941       return s;
1942     }
1943   };
1944   /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1945     if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1946       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1947     }
1948     this._value = stringValue;
1949   };
1950   /*string*/ this.getStringValue = function(/*short*/ stringType) {
1951     if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1952       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1953     }
1954     return (this._value);
1955   };
1956   /*Counter*/ this.getCounterValue = function() {
1957     if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1958       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1959     }
1960     return (new Counter());
1961   };
1962   /*Rect*/ this.getRectValue = function() {
1963     if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1964       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1965     }
1966     return (new Rect());
1967   };
1968   /*RGBColor*/ this.getRGBColorValue = function() {
1969     if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1970       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1971     }
1972     var s = new RGBColor();
1973     var rgbColor = this.cssText;
1974     var tkr = SVGColor.prototype._keywords[rgbColor];
1975     if (tkr !== void 0) {
1976       rgbColor = tkr;
1977     }
1978     if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
1979       rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1980         return Math.round((2.55 * parseFloat(t)));
1981       });
1982     } else if (rgbColor.indexOf("#") > -1) {  //#を含む場合
1983       rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1984         return parseInt(s, 16);
1985       });
1986     }
1987     var n = rgbColor.match(/\d+/g);
1988     s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1989     s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1990     s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1991     n = rgbColor = void 0;
1992     return (s);
1993   };
1994 }).apply(CSSPrimitiveValue.prototype);
1995 /*CSSValueList
1996  *Arrayで代用する
1997  */
1998 function CSSValueList() {
1999   this.cssValueType = CSSValue.CSS_VALUE_LIST;
2000   this.length = 0;
2001   return this;
2002 };
2003 CSSValueList.prototype = new CSSValue();
2004 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
2005   return (this[index]);
2006 };
2007
2008 function RGBColor() {
2009   var cs = CSSPrimitiveValue;
2010   this.red = new cs();
2011   this.green = new cs();
2012   this.blue = new cs();
2013   cs = void 0;
2014   this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2015   return this;
2016 };
2017
2018 function Rect() {
2019   var cs = CSSPrimitiveValue;
2020   this.top = new cs();
2021   this.right = new cs();
2022   this.bottom = new cs();
2023   this.left = new cs();
2024   cs = void 0; 
2025   return this;
2026 };
2027
2028 function Counter() {
2029   this.identifier = this.listStyle = this.separator = "";
2030   return this;
2031 };
2032
2033 function ElementCSSInlineStyle() {
2034   var cs = CSSStyleDeclaration;
2035   this.style = new cs();
2036   this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2037   cs = void 0;
2038   return this;
2039 };
2040
2041 /*CSS2Properties
2042  *削除不可
2043  *さらにSVG CSSを付け加えている
2044  */
2045 var n = "none",
2046     m = "normal",
2047     a = "auto",
2048     CSS2Properties = {
2049   fill : "black",
2050   stroke : n,
2051   cursor : a,
2052   visibility : "visible",
2053   display : "inline-block",
2054   opacity : "1",
2055   fillOpacity : "1",
2056   strokeWidth : "1",
2057   strokeDasharray : n,
2058   strokeDashoffset : "0",
2059   strokeLinecap : "butt",
2060   strokeLinejoin : "miter",
2061   strokeMiterlimit : "4",
2062   strokeOpacity : "1",
2063   writingMode : "lr-tb",
2064   fontFamily : "serif",
2065   fontSize : "12",
2066   color : "black",
2067   fontSizeAdjust : n,
2068   fontStretch : m,
2069   fontStyle : m,
2070   fontVariant : m,
2071   fontWeight : m,
2072   font : "inline",
2073
2074 //# Gradient properties:
2075
2076   stopColor : "black",
2077   stopOpacity : "1",
2078   textAnchor : "start",
2079   azimuth : "center",
2080                                         // raises(dom::DOMException) on setting
2081   //簡略プロパティに関しては、初期値を再考せよ
2082   clip : a,
2083   direction : "ltr",
2084   letterSpacing : m,
2085   lineHeight : m,
2086   overflow : "visible",
2087   textAlign : "left",
2088   textDecoration : n,
2089   textIndent : "0",
2090   textShadow : n,
2091   textTransform : n,
2092   unicodeBidi : m,
2093   verticalAlign : "baseline",
2094   whiteSpace : m,
2095   wordSpacing : m,
2096   zIndex : a,
2097 //  #
2098
2099   mask : n,
2100   markerEnd : n,
2101   markerMid : n,
2102   markerStart : n,
2103   fillRule : "nonzero",
2104
2105 //# Filter Effects properties:
2106
2107   enableBackground : "accumulate",
2108   filter : n,
2109   floodColor : "black",
2110   floodOpacity : "1",
2111   lightingColor : "white",
2112
2113 //# Interactivity properties:
2114
2115   pointerEvents : "visiblePainted",
2116
2117 //# Color and Painting properties:
2118
2119   colorInterpolation : "sRGB",
2120   colorInterpolationFilters : "linearRGB",
2121   colorProfile : a,
2122   colorRendering : a,
2123   imageRendering : a,
2124   marker : "",
2125   shapeRendering : a,
2126   textRendering : a,
2127
2128 //# Text properties:
2129
2130   alignmentBaseline : "",
2131   baselineShift : "baseline",
2132   dominantBaseline : a,
2133   glyphOrientationHorizontal : "0deg",
2134   glyphOrientationVertical : a,
2135   kerning : a
2136 };
2137 n = m = a = void 0;
2138 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2139
2140 function CSSStyleSheet() {
2141 /*CSSRule*/      this.ownerRule = null;
2142 /*CSSRuleList*/  this.cssRules = [];
2143   return this;
2144 };
2145 CSSStyleSheet.prototype = new StyleSheet();
2146 /*long*/  CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2147   var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2148   s.parentStyleSheet = this;
2149   style.cssText = rule;
2150   //style値の解析;
2151   sc = sc.replace(/^[^a-z\-]+/, "")
2152          .replace(/\:\s+/g, ":")
2153          .replace(/\s*;[^a-z\-]*/g, ";");
2154   a = sc.split(";");
2155   for (var i=0, ali=a.length;i<ali;++i) {
2156       ai = a[i],
2157       m = ai.split(":");
2158       if (ai !== "") {
2159         style.setProperty(m[0], m[1]);
2160       }
2161       ai = m = void 0;
2162     }
2163   a = sc = style = void 0;
2164   this.cssRules.splice(index,s,1);
2165 };
2166 /*void*/  CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2167   this.cssRules.splice(index, 1);
2168 };
2169
2170
2171 /*getComputedStyle関数
2172  *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2173  */
2174 /*interface ViewCSS : views::AbstractView {*/
2175 Document.prototype.defaultView = new ViewCSS();
2176 function ViewCSS(){
2177   return this;
2178 };
2179 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2180   var s = new CSSStyleDeclaration(),
2181       el, es,
2182       eso = 1;
2183   //クロージャを利用して、カスケーディングを実現する
2184   s.getPropertyCSSValue = (function(elt, td, s){
2185     return function( /*string*/ propertyName) {
2186       var el = elt,
2187           css = null,
2188           n;
2189       while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2190         if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2191           css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2192         } else if (el.style && el.style[propertyName]) {
2193           css = el.style.getPropertyCSSValue(propertyName);
2194         } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2195           //プレゼンテーション属性を探す
2196           css = el._attributeStyle.getPropertyCSSValue(propertyName);
2197         } else if (el._rules) {
2198           //スタイルシートのルールを探す
2199           for (var i=0,eli=el._rules.length;i<eli;++i) {
2200             el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2201           }
2202         }
2203         el = el.parentNode;
2204       }
2205       if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2206         //デフォルト値を探す
2207         td && (css = td[propertyName]);
2208       }
2209       if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2210         css.setRGBColor(s.getPropertyValue("color"));
2211       } else if (css && (css._em || css._ex || css["_%"])) {
2212         el = elt;
2213         n = 1;
2214         while (el) {
2215           if (el.style._list._fontSize) {
2216             n = el.style._list._fontSize;
2217             break;
2218           }
2219           el = el.parentNode;
2220         }
2221         if (css._em) {
2222           n *= css._em;
2223         } else if (css._ex) {
2224           n *= css._ex * 0.5;
2225         } else if (css["_%"]) {
2226           n *= css["_%"] / 100; 
2227         }
2228         css.cssText = "font-size:" +n+ "px";
2229       }
2230       el = void 0;
2231       return css;
2232     };
2233    })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2234   el = elt;
2235   while (el) {
2236     if (el.style) {
2237       es = el.style._list._opacity || el._attributeStyle._list._opacity;
2238       eso *= es || 1;
2239     }
2240     el = el.parentNode;
2241   }
2242   s._list._opacity = eso;
2243   el = pelt = eso = es = void 0;
2244   s._document = elt.ownerDocument;
2245   return s;
2246 };
2247
2248 /*getOverrideStyleメソッド
2249  *指定した要素の上書きスタイルシートを取得。
2250  */
2251 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2252 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2253   var tar = elt;
2254   if (!!tar._runtimeStyle) {
2255     return (tar._runtimeStyle);
2256   } else {
2257     var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2258     tar._runtimeStyle = s;
2259   }
2260   s.setProperty = (function(setProp, s){
2261     return function(propertyName, value, priority) {
2262       setProp.call(s, propertyName, value, priority);
2263       var tar = elt, el = tar._tar, isFill = isStroke = false;
2264       if ((tar.localName === "g") || (tar.localName === "a")) {
2265         var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2266         if (sl) {
2267           for (var i=0,sli=sl.length;i<sli;++i) {
2268             var di = sl[i];
2269             NAIBU._setPaint(di, di.getScreenCTM());
2270             di = void 0;
2271           }
2272           sl = void 0;
2273         }
2274         el = null;
2275       }
2276       if (!el) {
2277         return;
2278       }
2279       NAIBU._setPaint(tar, tar.getScreenCTM());
2280       el = tar = value = void 0;
2281     };
2282   })(setProp, s);
2283   return s;
2284 };
2285 /*createCSSStyleSheetメソッド
2286  *文書のスタイルシートを作成
2287  */
2288 /*interface DOMImplementationCSS : DOMImplementation {*/
2289 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2290   var s = new CSSStyleSheet();
2291   s.title = title;
2292   var nm = new MediaList();
2293   nm.mediaText = media;
2294   if (media && (media !== "")) {
2295     var mes = media.split(",");  //文字列をコンマで区切って配列に
2296     for (var i=0,mli=mes.length;i<mli;++i) {
2297       nm.appendMedium(mes[i]);   //メディアリストに値を加えていく
2298     }
2299   }
2300   s.media = nm;
2301   return s;
2302 };
2303 /*
2304 #endif // _CSS_IDL_
2305 */
2306 // File: smil.idl
2307 /*
2308 #ifndef _SMIL_IDL_
2309 #define _SMIL_IDL_
2310
2311 #include "dom.idl"
2312
2313 #pragma prefix "dom.w3c.org"
2314 module smil
2315 {
2316   typedef dom::DOMString DOMString;
2317 */
2318 /*ElementTimeControlはSVGAnimationElementに統合させる。
2319  *というのは、多重継承が難しいため
2320  */
2321 function ElementTimeControl(ele) {
2322   this._tar = ele;
2323   /*_startと_endプロパティはミリ秒数を収納する。
2324    *_startはアニメ開始時の秒数のリスト。_finishはアニメ終了時の秒数のリスト。
2325    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2326    */
2327   this._start = [];
2328   this._finish = null;
2329   return this;
2330 };
2331 ElementTimeControl.prototype = {
2332   /*void*/  beginElement : function() {
2333     var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2334     evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2335     this.dispatchEvent(evt);
2336   },
2337   /*void*/  endElement : function() {
2338     var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2339     evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2340     this.dispatchEvent(evt);
2341   },
2342   /*void*/  beginElementAt : function(/*float*/ offset) {
2343     var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2344         start = this._start || [];
2345     for (var i=0,sli=start.length;i<sli;++i) {
2346       if (start[i] === (offset+ntc)) {
2347         ntc = start = offset = void 0;
2348         return;
2349       }
2350     }
2351     start.push(offset + ntc);
2352     this._start = start;
2353   },
2354   /*void*/  endElementAt : function(/*float*/ offset) {
2355     var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2356         fin = this._finish || [];
2357     for (var i=0,fli=fin.length;i<fli;++i) {
2358       if (fin[i] === (offset+ntc)) {
2359         ntc = fin = offset = void 0;
2360         return;
2361       }
2362     }
2363     fin.push(offset + ntc);
2364     this._finish = fin;
2365   }
2366 };
2367
2368 function TimeEvent() {
2369   Event.apply(this);
2370   /*readonly attribute views::AbstractView*/  this.view;
2371   /*readonly attribute long*/             this.detail;
2372   return this;
2373 };
2374 TimeEvent.counstructor = Event;
2375 TimeEvent.prototype = new Event();
2376 /*void*/  TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg, 
2377                                      /*views::AbstractView*/ viewArg, 
2378                                      /*long*/ detailArg) {
2379   this.type = typeArg;
2380   this.view = viewArg;
2381   this.detail = detailArg;
2382 };
2383 //#endif // _SMIL_IDL_
2384
2385
2386 //これを頭に付けたら、内部処理用
2387 var  NAIBU = {};
2388
2389 /*
2390 // File: svg.idl
2391 #ifndef _SVG_IDL_
2392 #define _SVG_IDL_
2393 // For access to DOM2 core
2394 #include "dom.idl"
2395 // For access to DOM2 events
2396 #include "events.idl"
2397 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2398 #include "css.idl"
2399 // For access to those parts from DOM2 Views OM used by SVG DOM.
2400 #include "views.idl"
2401 // For access to the SMIL OM used by SVG DOM.
2402 #include "smil.idl"
2403 #pragma prefix "dom.w3c.org"
2404 #pragma javaPackage "org.w3c.dom"
2405 module svg
2406 {
2407   typedef dom::DOMString DOMString;
2408   typedef dom::DOMException DOMException;
2409   typedef dom::Element Element;
2410   typedef dom::Document Document;
2411   typedef dom::NodeList NodeList;
2412   // Predeclarations
2413   interface SVGElement;
2414   interface SVGLangSpace;
2415   interface SVGExternalResourcesRequired;
2416   interface SVGTests;
2417   interface SVGFitToViewBox;
2418   interface SVGZoomAndPan;
2419   interface SVGViewSpec;
2420   interface SVGURIReference;
2421   interface SVGPoint;
2422   interface SVGMatrix;
2423   interface SVGPreserveAspectRatio;
2424   interface SVGAnimatedPreserveAspectRatio;
2425   interface SVGTransformList;
2426   interface SVGAnimatedTransformList;
2427   interface SVGTransform;
2428   interface SVGICCColor;
2429   interface SVGColor;
2430   interface SVGPaint;
2431   interface SVGTransformable;
2432   interface SVGDocument;
2433   interface SVGSVGElement;
2434   interface SVGElementInstance;
2435   interface SVGElementInstanceList;
2436 */
2437 function SVGException(code) {
2438   /*unsigned short*/  this.code = code;
2439   if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2440     this.message = "SVG Wrong Type Error";
2441   } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2442     this.message = "SVG Invalid Value Error";
2443   } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2444     this.message = "SVG Matrix Not Invertable";
2445   }
2446   return this;
2447 };
2448 SVGException.prototype = new Error();
2449 // SVGExceptionCode
2450 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR           = 0;
2451 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR        = 1;
2452 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE    = 2;
2453
2454 /*SVGElement
2455  *すべてのSVG関連要素の雛形となるオブジェクト
2456  */
2457 function SVGElement() {
2458   Element.call(this);
2459   SVGStylable.call(this);             //ElementCSSInlineStyleのインタフェースを継承
2460   /*interface SVGTransformable : SVGLocatable
2461    *TransformListはtransform属性を行列で表現したあとのリスト構造
2462    */
2463   /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2464   //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2465   this.addEventListener("DOMAttrModified", function(evt){
2466     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2467       return;
2468     }
2469     var name = evt.attrName,
2470         tar = evt.target;
2471     if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2472       tar._attributeStyle.setProperty(name, evt.newValue, "");
2473     }
2474     if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2475       tar.id = evt.newValue;
2476     } else if ((name === "transform") && !!tar.transform) {
2477       var tft = evt.newValue,
2478           degR = tar._degReg,
2479           coma = tft.match(tar._comaReg),   //コマンド文字にマッチ translate
2480           list = tft.match(tar._strReg),    //カッコ内のリストにマッチ (10 20 30...)
2481           a,b,c,d,e,f,
2482           lis,
2483           com,
2484           deg,
2485           rad,
2486           degli,
2487           s,
2488           cm,
2489           degz,
2490           etod = evt.target.ownerDocument.documentElement,
2491           ttb = tar.transform.baseVal;
2492       //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2493       for (var j=0,cli=coma.length;j<cli;j++) {
2494         s = etod.createSVGTransform();
2495         lis = list[j],
2496         com = coma[j];
2497         deg = lis.match(degR);
2498         degli = deg.length;
2499         if (degli === 6) {
2500           cm = s.matrix;
2501           cm.a = +(deg[0]);
2502           cm.b = +(deg[1]);
2503           cm.c = +(deg[2]);
2504           cm.d = +(deg[3]);
2505           cm.e = +(deg[4]);
2506           cm.f = +(deg[5]);
2507         } else {
2508           if (degli === 3) {
2509             degz = +(deg[0]);
2510             s.setRotate(degz, +(deg[1]), +(deg[2]))
2511           } else if (degli <= 2) {
2512             degz = +(deg[0]);
2513             if (com === "translate") {
2514               s.setTranslate(degz, +(deg[1] || 0));
2515             } else if (com === "scale") {
2516               s.setScale(degz, +(deg[1] || deg[0]));
2517             } else if (com === "rotate") {
2518               s.setRotate(degz, 0, 0);
2519             } else if (com === "skewX") {
2520               s.setSkewX(degz);
2521             } else if (com === "skewY") {
2522               s.setSkewY(degz);
2523             }
2524           }
2525         }
2526         ttb.appendItem(s);
2527       }
2528       tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2529     } else if (name === "style") {
2530       var sc = evt.newValue,
2531           style = tar.style,
2532           a,
2533           ai,
2534           m;
2535       style.cssText = sc;
2536       if (sc !== "") {
2537         //style属性値の解析
2538         sc = sc.replace(tar._shouReg, "")
2539                .replace(tar._conReg, ":")
2540                .replace(tar._bouReg, ";");
2541         a = sc.split(";");
2542         for (var i=0, ali=a.length;i<ali;++i) {
2543           ai = a[i],
2544           m = ai.split(":");
2545           if (ai !== "") {
2546             style.setProperty(m[0], m[1]);
2547           }
2548           ai = m = void 0;
2549         }
2550       }
2551       a = sc = style = void 0;
2552     } else if (name === "class") {
2553       tar.className = evt.newValue;
2554     } else if (name.indexOf("on") === 0) {           //event属性ならば
2555       /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2556        *ところが、IEでは、undefinedの値を返してしまう。
2557        *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2558        */
2559       eval("document._s = (function(evt){" +evt.newValue+ "})");
2560       var v = name.slice(2);
2561       if (v === "load") {
2562         v = "SVGLoad";
2563       } else if (v === "unload") {
2564         v = "SVGUnload";
2565       } else if (v === "abort") {
2566         v = "SVGAbort";
2567       } else if (v === "error") {
2568         v = "SVGError";
2569       } else if (v === "resize") {
2570         v = "SVGResize";
2571       } else if (v === "scroll") {
2572         v = "SVGScroll";
2573       } else if (v === "zoom") {
2574         v = "SVGZoom";
2575       } else if (v === "begin") {
2576         v = "beginEvent";
2577       } else if (v === "end") {
2578         v = "endEvent";
2579       } else if (v === "repeat") {
2580         v = "repeatEvent";
2581       }
2582       tar.addEventListener(v, document._s, false);
2583     } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2584       tar.xmlbase = evt.newValue;
2585     } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2586       var tea = tar[name],
2587           tod = tar.nearestViewportElement || tar.ownerDocument.documentElement,
2588           tvw = tod.viewport.width,
2589           tvh = tod.viewport.height,
2590           s,
2591           n = evt.newValue.slice(-2),
2592           m = n.charAt(1),
2593           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2594           _parseFloat = parseFloat;
2595       if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
2596       } else if (m === "%") {
2597         if (tar._x1width[name]) {
2598           tea.baseVal._percent = tvw * 0.01;
2599         } else if (tar._y1height[name]) {
2600           tea.baseVal._percent = tvh * 0.01;
2601         } else {
2602           tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2603         }
2604         type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2605       } else if (n === "em") {
2606         type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2607       } else if (n === "ex") {
2608         type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2609       } else if (n === "px") {
2610         type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2611       } else if (n === "cm") {
2612         type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2613       } else if (n === "mm") {
2614         type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2615       } else if (n === "in") {
2616         type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2617       } else if (n === "pt") {
2618         type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2619       } else if (n === "pc") {
2620         type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2621       }
2622       s = _parseFloat(evt.newValue);
2623       s = isNaN(s) ? 0 : s;
2624       tea.baseVal.newValueSpecifiedUnits(type, s);
2625       tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2626     }
2627     evt = _parseFloat = name = tar = null;
2628   }, false);
2629   return this;
2630 };
2631 SVGElement.prototype = new Element();
2632
2633 (function(){
2634   /*以下の正規表現は属性のパーサの際に用いる*/
2635   this._degReg = /[\-\d\.e]+/g;
2636   this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2637   this._strReg =  /\([^\)]+\)/g;
2638   this._syouReg = /^[^a-z\-]+/;
2639   this._conReg = /\:\s+/g;
2640   this._bouReg = /\s*;[^a-z\-]*/g;
2641   /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2642    *getCTMメソッドで使う
2643    */
2644   this._cacheMatrix = null;
2645   /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2646   this._x1width = {
2647       "x" : 1,
2648       "x1" : 1,
2649       "x2" : 1,
2650       "width" : 1,
2651       "cx" : 1
2652   };
2653   this._y1height = {
2654       "y" : 1,
2655       "y1" : 1,
2656       "y2" : 1,
2657       "height" : 1,
2658       "cy" : 1      
2659   };
2660   /*String*/              this.id      = null;        //id属性の値
2661   /*String*/              this.xmlbase = null;   //xml:base属性の値
2662   /*SVGSVGElement*/       this.ownerSVGElement;  //ルート要素であるsvg要素
2663   /*readonly SVGElement*/ this.viewportElement;  //ビューポートを形成する要素(多くはsvg要素)
2664   /*readonly attribute SVGElement*/ this.nearestViewportElement  = null;
2665   /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2666   
2667   /*interface SVGLocatable*/
2668   /*SVGRect*/     this.getBBox = function(){
2669     var s = new SVGRect(),
2670         data = this._tar.path.value,
2671         vi = this.ownerDocument.documentElement.viewport,
2672         el = vi.width,
2673         et = vi.height,
2674         er = 0,
2675         eb = 0,
2676         degis = data.match(/[0-9\-]+/g),
2677         nx,
2678         ny;
2679     /*要素の境界領域を求める(四隅の座標を求める)
2680      *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2681      *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2682      */
2683     for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2684       nx = +(degis[i]),
2685       ny = +(degis[i+1]);
2686       el = el > nx ? nx : el;
2687       et = et > ny ? ny : et;
2688       er = er > nx ? er : nx;
2689       eb = eb > ny ? eb : ny;
2690     }
2691     s.x      = el;
2692     s.y      = et;
2693     s.width  = er - el;
2694     s.height = eb - et;
2695     nx = ny = data = degis =el = et = er = eb = vi = void 0;
2696     return s;
2697   };
2698
2699   /*getCTMメソッド
2700    *CTMとは現在の利用座標系に対する変換行列
2701    *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2702    *1.2ではgetCTMが言及されていない
2703    *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2704    */
2705   /*SVGMatrix*/   this.getCTM = function() {
2706     var s, m;
2707     if (!!this._cacheMatrix) { //キャッシュがあれば
2708       s = this._cacheMatrix;
2709     } else {
2710       m = this.transform.baseVal.consolidate();
2711       if (m) {
2712         m = m.matrix;
2713       } else {
2714         m = this.ownerDocument.documentElement.createSVGMatrix();
2715       }
2716       if (this.parentNode && !!this.parentNode.getCTM) {
2717         s = this.parentNode.getCTM().multiply(m);
2718       } else {
2719         s = m;
2720       }
2721       m = void 0;
2722       this._cacheMatrix = s; //キャッシュをためて次回で使う
2723     }
2724     return s;
2725   };
2726
2727   /*SVGMatrix*/   this.getScreenCTM = function(){
2728     if (!this.parentNode) {
2729       return null;
2730     }
2731     var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2732     var s = view.getScreenCTM().multiply(this.getCTM());
2733     view = null;
2734     return s;
2735   };
2736
2737   /*getTransformToElementメソッド
2738    *これは、あるelementへの変換行列を計算して返す
2739    *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2740    */
2741   /*SVGMatrix*/   this.getTransformToElement = function(/*SVGElement*/ element ){
2742     var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2743     return s;
2744   };
2745 }).apply(SVGElement.prototype);
2746
2747 function SVGAnimatedBoolean() {
2748   /*boolean*/  this.animVal = this.baseVal = true;
2749   return this;
2750 };
2751
2752 function SVGAnimatedString() {
2753   /*String*/ this.animVal = this.baseVal = "";
2754   return this;
2755 };
2756
2757 function SVGStringList() {
2758   return this;
2759 };
2760 SVGStringList.prototype = new Array();
2761 (function(){
2762   /*readonly unsigned long*/ this.numberOfItems = 0;
2763   /*void*/   this.clear = function(){
2764     for (var i=0, tli=this.length;i<tli;++i) {
2765       delete this[i];
2766     }
2767     this.numberOfItems = 0;
2768   };
2769   /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2770     this.clear();
2771     this[0] = newItem;
2772     this.numberOfItems = 1;
2773     return newItem;
2774   };
2775   /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2776     if (index >= this.numberOfItems || index < 0) {
2777       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2778     } else {
2779       return (this[index]);
2780     }
2781   };
2782   /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2783     if (index >= this.numberOfItems) {
2784       this.appendItem(newItem);
2785     } else {
2786       this.splice(index, 1, newItem, this.getItem[index]);
2787       ++this.numberOfItems;
2788     }
2789     return newItem;
2790   };
2791   /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2792     if (index >= this.numberOfItems || index < 0) {
2793       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2794     } else {
2795       this.splice(index, 1, newItem);
2796     }
2797     return newItem;
2798   };
2799                   //raises( DOMException, SVGException );
2800   /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2801     if (index >= this.numberOfItems || index < 0) {
2802       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2803     } else {
2804       this.splice(index, 1);
2805       --this.numberOfItems;
2806     }
2807     return newItem;
2808   };
2809   /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2810     this[this.numberOfItems] = newItem;
2811     ++this.numberOfItems;
2812   };
2813 }).apply(SVGStringList.prototype);
2814
2815 function SVGAnimatedEnumeration() {
2816   /*unsigned short*/ this.baseVal = 0;
2817                          // raises DOMException on setting
2818   /*readonly unsigned short*/ this.animVal = 0;
2819   return this;
2820 };
2821 function SVGAnimatedInteger() {
2822   /*long*/ this.baseVal = 0;
2823                          // raises DOMException on setting
2824   /*readonly long*/ this.animVal = 0;
2825   return this;
2826 };
2827 function SVGNumber() {
2828   /*float*/ this.value = 0;
2829                          // raises DOMException on setting
2830   return this;
2831 };
2832 function SVGAnimatedNumber() {
2833   /*float*/ this.baseVal = this.animVal = 0;
2834   return this;
2835 };
2836
2837 function SVGNumberList() {
2838   return this;
2839 };
2840 /*SVGUnmberListのメソッドはSVGPathSegListを参照*/
2841
2842 function SVGAnimatedNumberList() {
2843   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2844   return this;
2845 };
2846 /*SVGLengthクラス
2847  *長さを設定する(単位pxに統一する方便として使う)
2848  *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2849  */
2850 function SVGLength() {
2851   return this;
2852 };
2853 (function(t) {
2854     // Length Unit Types
2855   /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN    = 0;
2856   /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER     = 1;
2857   /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2858   /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS        = 3;
2859   /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS        = 4;
2860   /*const unsigned short*/ t.SVG_LENGTHTYPE_PX         = 5;
2861   /*const unsigned short*/ t.SVG_LENGTHTYPE_CM         = 6;
2862   /*const unsigned short*/ t.SVG_LENGTHTYPE_MM         = 7;
2863   /*const unsigned short*/ t.SVG_LENGTHTYPE_IN         = 8;
2864   /*const unsigned short*/ t.SVG_LENGTHTYPE_PT         = 9;
2865   /*const unsigned short*/ t.SVG_LENGTHTYPE_PC         = 10;
2866 })(SVGLength);
2867
2868 SVGLength.prototype = {
2869   /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2870   /*attribute float*/          value : 0,                  //利用単位における値
2871   /*attribute float*/          valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN,  //unitTypeにおける値
2872   /*attribute DOMString*/      valueAsString : "0",
2873   _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2874   _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2875 /*newValueSpedifiedUnitsメソッド
2876  *新しくunitTypeにおける値を設定する
2877  *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2878  */
2879   newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2880     var n = 1,
2881        _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2882     if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2883     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2884       _s = "px";
2885     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2886       n = this._percent;
2887       _s = "%"
2888     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2889       n = this._fontSize;
2890       _s = "em";
2891     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2892       n = this._fontSize * 0.5;
2893       _s = "ex";
2894     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2895       n = 35.43307;
2896       _s = "cm";
2897     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2898       n = 3.543307;
2899       _s = "mm";
2900     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2901       n = 90;
2902       _s = "in";
2903     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2904       n = 1.25;
2905       _s = "pt";
2906     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2907       n = 15;
2908       _s = "pc";
2909     } else {
2910       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2911     }
2912     this.unitType = unitType;
2913     this.value = valueInSpecifiedUnits * n;
2914     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2915     this.valueAsString = valueInSpecifiedUnits + _s;
2916     valueInSpecifiedUnits = unitType = n = _s = void 0;
2917   },
2918 /*convertToSpecifiedUnitsメソッド
2919  *valueプロパティを書き換えずに、単位だけを変換する
2920  *例:2cmをmmに変換したい場合
2921  * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2922  * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2923  * alert(x.valueAsString); //20mm
2924  */
2925   convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2926     if (this.value === 0) {
2927       this.newValueSpecifiedUnits(unitType, 0);
2928       return;
2929     }
2930     var v = this.value;
2931     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2932     v = v / this.value * this.valueInSpecifiedUnits;
2933     this.newValueSpecifiedUnits(unitType, v); 
2934   },
2935   /*_emToUnitメソッド
2936    *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2937    *単位が%の場合は、新しいvalueへと変換させておく
2938    */
2939   _emToUnit : function (/*float*/ fontSize) {
2940     if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2941       this._fontSize = fontSize;
2942       this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2943     }
2944   }
2945 };
2946 function SVGAnimatedLength() {
2947   /*readonly SVGLength*/ this.animVal;
2948   this.baseVal = new SVGLength();
2949   this.baseVal.unitType = 1;
2950   return this;
2951 };
2952 function SVGLengthList() {
2953   return this;
2954 };
2955 /*SVGLengthListのメソッドはSVGPathSegListを参照*/
2956
2957 function SVGAnimatedLengthList() {
2958   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2959   return this;
2960 };
2961 function SVGAngle() { 
2962   return this;
2963 };
2964 SVGAngle.prototype = {
2965   /*readonly attribute unsigned short*/ unitType : 0,
2966   /*attribute float*/     value : 0,
2967                          // raises DOMException on setting
2968   /*attribute float*/     valueInSpecifiedUnits : 0,
2969                          // raises DOMException on setting
2970   /*attribute DOMString*/ valueAsString : "0",
2971                          // raises DOMException on setting
2972   /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2973     var n = 1,
2974         _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2975     if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2976     } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2977       _s = "deg"
2978     } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2979       n =  Math.PI / 180;
2980       _s = "rad";
2981     } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2982       n = 9 / 10;
2983       _s = "grad";
2984     } else {
2985       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2986     }
2987     this.unitType = unitType;
2988     this.value = valueInSpecifiedUnits * n;
2989     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2990     this.valueAsString = valueInSpecifiedUnits + _s;
2991     n = _s = void 0;
2992     //raises( DOMException );
2993   },
2994   /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2995     if (this.value === 0) {
2996       this.newValueSpecifiedUnits(unitType, 0);
2997       return;
2998     }
2999     var v = this.value;
3000     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
3001     v = v / this.value * this.valueInSpecifiedUnits;
3002     this.newValueSpecifiedUnits(unitType, v); 
3003     //raises( DOMException );
3004   }
3005 };
3006 // Angle Unit Types
3007 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN     = 0;
3008 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
3009 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG         = 2;
3010 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD         = 3;
3011 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD        = 4;
3012 function SVGAnimatedAngle() { 
3013   /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
3014   /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
3015   return this;
3016 };
3017 function SVGColor() {
3018   CSSValue.apply(this);
3019   /*readonly css::RGBColor*/  this.rgbColor  = new RGBColor();
3020   return this;
3021 };
3022
3023   // Color Types
3024 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN           = 0;
3025 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR          = 1;
3026 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3027 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR      = 3;
3028 SVGColor.prototype = new CSSValue();  //ノードのプロトタイプチェーンを作って、継承
3029
3030 (function(){
3031   /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3032   /*readonly SVGICCColor*/    this.iccColor = null;
3033   this._regD = /\d+/g;
3034   this._regDP = /[\d.]+%/g;
3035   this._exceptionsvg = SVGException.SVG_INVALID_VALUE_ERR;
3036   /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3037   var s,
3038       _parseInt,
3039       r, g, b;
3040   if (!rgbColor || (typeof rgbColor !== "string")) {
3041     throw new SVGException(this._exceptionsvg);
3042   }
3043   rgbColor = this._keywords[rgbColor] || rgbColor;
3044   if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
3045     rgbColor = rgbColor.replace(this._regDP, function(s) {
3046       return Math.round((2.55 * parseFloat(s)));
3047     });
3048     s = rgbColor.match(this._regD);
3049   } else if (rgbColor.indexOf("#") === 0) {  //#を含む場合
3050     s = [];
3051     _parseInt = parseInt;
3052     if (rgbColor.length < 5) {
3053       r = rgbColor.charAt(1);
3054       g = rgbColor.charAt(2);
3055       b = rgbColor.charAt(3)
3056       rgbColor = "#" + r + r + g + g + b + b;
3057     }
3058     s[0] = _parseInt(rgbColor.slice(1, 3), 16)+ "";
3059     s[1] = _parseInt(rgbColor.slice(3, 5), 16)+ "";
3060     s[2] = _parseInt(rgbColor.slice(5, 7), 16)+ "";
3061     r = g = b = void 0;
3062   } else {
3063     s = rgbColor.match(this._regD);
3064     if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3065       rgbColor = void 0;
3066       throw new SVGException(this._exceptionsvg);
3067     }
3068   }
3069   this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3070   this.rgbColor.green.setFloatValue(1, s[1]);
3071   this.rgbColor.blue.setFloatValue(1, s[2]);
3072   rgbColor = s = _parseInt = void 0;
3073 };
3074
3075 //                    raises( SVGException );
3076 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3077   this.colorType = colorType;
3078   if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3079     throw new SVGException(this._exceptionsvg);
3080   } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3081     this.setRGBColor(rgbColor);
3082   } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3083     this.setRGBColor(rgbColor);
3084   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3085     throw new SVGException(this._exceptionsvg);
3086   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3087     throw new SVGException(this._exceptionsvg);
3088   }
3089   colorType = rgbColor = void 0;
3090 }
3091 //                    raises( SVGException );
3092 //色キーワード
3093 this._keywords = {
3094     aliceblue:    "rgb(240,248,255)",
3095     antiquewhite: "rgb(250,235,215)",
3096     aqua:         "rgb(0,255,255)",
3097     aquamarine:   "rgb(127,255,212)",
3098     azure:        "rgb(240,255,255)",
3099     beige:        "rgb(245,245,220)",
3100     bisque:       "rgb(255,228,196)",
3101     black:        "rgb(0,0,0)",
3102     blanchedalmond:"rgb(255,235,205)",
3103     blue:         "rgb(0,0,255)",
3104     blueviolet:   "rgb(138,43,226)",
3105     brown:        "rgb(165,42,42)",
3106     burlywood:    "rgb(222,184,135)",
3107     cadetblue:    "rgb(95,158,160)",
3108     chartreuse:   "rgb(127,255,0)",
3109     chocolate:    "rgb(210,105,30)",
3110     coral:        "rgb(255,127,80)",
3111     cornflowerblue:"rgb(100,149,237)",
3112     cornsilk:     "rgb(255,248,220)",
3113     crimson:      "rgb(220,20,60)",
3114     cyan:         "rgb(0,255,255)",
3115     darkblue:     "rgb(0,0,139)",
3116     darkcyan:     "rgb(0,139,139)",
3117     darkgoldenrod:"rgb(184,134,11)",
3118     darkgray:     "rgb(169,169,169)",
3119     darkgreen:    "rgb(0,100,0)",
3120     darkgrey:     "rgb(169,169,169)",
3121     darkkhaki:    "rgb(189,183,107)",
3122     darkmagenta:  "rgb(139,0,139)",
3123     darkolivegreen:"rgb(85,107,47)",
3124     darkorange:    "rgb(255,140,0)",
3125     darkorchid:   "rgb(153,50,204)",
3126     darkred:      "rgb(139,0,0)",
3127     darksalmon:   "rgb(233,150,122)",
3128     darkseagreen: "rgb(143,188,143)",
3129     darkslateblue:"rgb(72,61,139)",
3130     darkslategray:"rgb(47,79,79)",
3131     darkslategrey:"rgb(47,79,79)",
3132     darkturquoise:"rgb(0,206,209)",
3133     darkviolet:   "rgb(148,0,211)",
3134     deeppink:     "rgb(255,20,147)",
3135     deepskyblue:  "rgb(0,191,255)",
3136     dimgray:      "rgb(105,105,105)",
3137     dimgrey:      "rgb(105,105,105)",
3138     dodgerblue:   "rgb(30,144,255)",
3139     firebrick:    "rgb(178,34,34)",
3140     floralwhite:  "rgb(255,250,240)",
3141     forestgreen:  "rgb(34,139,34)",
3142     fuchsia:      "rgb(255,0,255)",
3143     gainsboro:    "rgb(220,220,220)",
3144     ghostwhite:   "rgb(248,248,255)",
3145     gold:         "rgb(255,215,0)",
3146     goldenrod:    "rgb(218,165,32)",
3147     gray:         "rgb(128,128,128)",
3148     grey:         "rgb(128,128,128)",
3149     green:        "rgb(0,128,0)",
3150     greenyellow:  "rgb(173,255,47)",
3151     honeydew:     "rgb(240,255,240)",
3152     hotpink:      "rgb(255,105,180)",
3153     indianred:    "rgb(205,92,92)",
3154     indigo:       "rgb(75,0,130)",
3155     ivory:        "rgb(255,255,240)",
3156     khaki:        "rgb(240,230,140)",
3157     lavender:     "rgb(230,230,250)",
3158     lavenderblush:"rgb(255,240,245)",
3159     lawngreen:    "rgb(124,252,0)",
3160     lemonchiffon: "rgb(255,250,205)",
3161     lightblue:    "rgb(173,216,230)",
3162     lightcoral:   "rgb(240,128,128)",
3163     lightcyan:    "rgb(224,255,255)",
3164     lightgoldenrodyellow:"rgb(250,250,210)",
3165     lightgray:    "rgb(211,211,211)",
3166     lightgreen:   "rgb(144,238,144)",
3167     lightgrey:    "rgb(211,211,211)",
3168     lightpink:    "rgb(255,182,193)",
3169     lightsalmon:  "rgb(255,160,122)",
3170     lightseagree: "rgb(32,178,170)",
3171     lightskyblue: "rgb(135,206,250)",
3172     lightslategray:"rgb(119,136,153)",
3173     lightslategrey:"rgb(119,136,153)",
3174     lightsteelblue:"rgb(176,196,222)",
3175     lightyellow:  "rgb(255,255,224)",
3176     lime:         "rgb(0,255,0)",
3177     limegreen:    "rgb(50,205,50)",
3178     linen:        "rgb(250,240,230)",
3179     magenta:      "rgb(255,0,255)",
3180     maroon:       "rgb(128,0,0)",
3181     mediumaquamarine:"rgb(102,205,170)",
3182     mediumblue:    "rgb(0,0,205)",
3183     mediumorchid:  "rgb(186,85,211)",
3184     mediumpurple:  "rgb(147,112,219)",
3185     mediumseagreen:"rgb(60,179,113)",
3186     mediumslateblue:"rgb(123,104,238)",
3187     mediumspringgreen:"rgb(0,250,154)",
3188     mediumturquoise:"rgb(72,209,204)",
3189     mediumvioletred:"rgb(199,21,133)",
3190     midnightblue:  "rgb(25,25,112)",
3191     mintcream:     "rgb(245,255,250)",
3192     mistyrose:     "rgb(255,228,225)",
3193     moccasin:      "rgb(255,228,181)",
3194     navajowhite:   "rgb(255,222,173)",
3195     navy:          "rgb(0,0,128)",
3196     oldlace:       "rgb(253,245,230)",
3197     olive:         "rgb(128,128,0)",
3198     olivedrab:     "rgb(107,142,35)",
3199     orange:        "rgb(255,165,0)",
3200     orangered:     "rgb(255,69,0)",
3201     orchid:        "rgb(218,112,214)",
3202     palegoldenrod: "rgb(238,232,170)",
3203     palegreen:     "rgb(152,251,152)",
3204     paleturquoise: "rgb(175,238,238)",
3205     palevioletred: "rgb(219,112,147)",
3206     papayawhip:    "rgb(255,239,213)",
3207     peachpuff:     "rgb(255,218,185)",
3208     peru:          "rgb(205,133,63)",
3209     pink:          "rgb(255,192,203)",
3210     plum:          "rgb(221,160,221)",
3211     powderblue:    "rgb(176,224,230)",
3212     purple:        "rgb(128,0,128)",
3213     red:           "rgb(255,0,0)",
3214     rosybrown:     "rgb(188,143,143)",
3215     royalblue:     "rgb(65,105,225)",
3216     saddlebrown:   "rgb(139,69,19)",
3217     salmon:        "rgb(250,128,114)",
3218     sandybrown:    "rgb(244,164,96)",
3219     seagreen:      "rgb(46,139,87)",
3220     seashell:      "rgb(255,245,238)",
3221     sienna:        "rgb(160,82,45)",
3222     silver:        "rgb(192,192,192)",
3223     skyblue:       "rgb(135,206,235)",
3224     slateblue:     "rgb(106,90,205)",
3225     slategray:     "rgb(112,128,144)",
3226     slategrey:     "rgb(112,128,144)",
3227     snow:          "rgb(255,250,250)",
3228     springgreen:   "rgb(0,255,127)",
3229     steelblue:     "rgb(70,130,180)",
3230     tan:           "rgb(210,180,140)",
3231     teal:          "rgb(0,128,128)",
3232     thistle:       "rgb(216,191,216)",
3233     tomato:        "rgb(255,99,71)",
3234     turquoise:     "rgb(64,224,208)",
3235     violet:        "rgb(238,130,238)",
3236     wheat:         "rgb(245,222,179)",
3237     white:         "rgb(255,255,255)",
3238     whitesmoke:    "rgb(245,245,245)",
3239     yellow:        "rgb(255,255,0)",
3240     yellowgreen:   "rgb(154,205,50)"
3241 };
3242 }).apply(SVGColor.prototype);
3243
3244 function SVGRect() { 
3245   /*float*/ this.x      = 0;
3246                          // raises DOMException on setting
3247   /*float*/ this.y      = 0;
3248                          // raises DOMException on setting
3249   /*float*/ this.width  = 0;
3250                          // raises DOMException on setting
3251   /*float*/ this.height = 0;
3252                          // raises DOMException on setting
3253   return this;
3254 };
3255
3256 function SVGAnimatedRect() { 
3257   /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3258   return this;
3259 };
3260
3261 SVGUnitTypes = { 
3262   // Unit Types
3263   /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN           : 0,
3264   /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE    : 1,
3265   /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3266 };
3267 function SVGStylable() {
3268   /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3269   /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3270   this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3271   //styleのcssTextプロパティを解析するリスナーを登録しておく
3272 };
3273 /*getPresentationAttributeメソッド
3274  *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3275  */
3276 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3277   var s = this._attributeStyle.getPropertyCSSValue(name);
3278   if (s) {
3279     return s;
3280   } else {
3281     return null;
3282   }
3283 };
3284
3285 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3286  *SIEでは、もっぱらXLink言語の処理を行う
3287  */
3288 function SVGURIReference() {
3289   /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3290   this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3291   this._text = "";
3292   this.addEventListener("DOMAttrModified", function(evt){
3293     if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3294       evt.target.href.baseVal = evt.newValue;
3295       /*_svgload_limitedを+1とすることで、
3296        *SVGLoadイベントは発火されなくなる。1を引く必要がある
3297        */
3298       evt.target.ownerDocument.documentElement._svgload_limited++;
3299     }
3300     evt = void 0;
3301   }, false);
3302   this.addEventListener("DOMNodeInserted", function(evt){
3303     var tar = evt.target;
3304     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3305       return; //強制終了させる
3306     }
3307     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3308       var tar = evt.target,
3309           base,
3310           href = tar.href.baseVal,
3311           show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3312       /*xlink:href属性とxml:base属性を手がかりに、
3313        *ハイパーリンクのURIを決定する処理を行う
3314        */
3315       if (href !== "") { //xlink:href属性が指定されたとき
3316         egbase = tar.xmlbase;
3317         if (!egbase) {
3318           ep = tar.parentNode;
3319           b = null;
3320           while (!b && ep) {
3321             b = ep.xmlbase;
3322             ep = ep.parentNode;
3323           }
3324           base = b;
3325           if (!b) {                        //xml:baseの指定がなければ
3326             if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3327               lh = location.href;
3328               base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3329             } else {
3330               base = location.href;
3331             }
3332           }
3333         } else {
3334           base = egbase;
3335         }
3336         if (href.indexOf(":") !== -1) { //絶対URIの場合
3337           base =  "";
3338         }
3339         uri = base + href;
3340         show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3341         if (href.indexOf(".") === 0) {  //相対URIの場合
3342           uri = href;
3343         }
3344         if (show === "replace") {
3345           tar._tar.setAttribute("href", uri);
3346         } else if (show === "new") {
3347           tar._tar.setAttribute("target", "_blank");
3348           tar._tar.setAttribute("href", uri);
3349         } else if (show === "embed") {
3350           xmlhttp = NAIBU.xmlhttp;
3351           ui = uri.indexOf("#");
3352           if (ui > -1) {
3353             id = uri.slice(ui+1);
3354             uri = uri.replace(/#.+$/, "");
3355           } else {
3356             id = null;
3357           }
3358           if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3359             doc = tar.ownerDocument;
3360             ele = doc.getElementById(id);
3361             tar._instance = ele;
3362             ev = doc.createEvent("SVGEvents");
3363             ev.initEvent("S_Load", false, false);
3364             tar.dispatchEvent(ev);
3365             tar = xmlhttp = void 0;
3366           } else if (uri.indexOf("data:") > -1) {
3367             tar._tar.src = uri;
3368             tar = xmlhttp = void 0;
3369           } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3370             if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3371               tar._tar.src = uri;
3372             } else {
3373               /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3374               tar.ownerDocument.documentElement._svgload_limited++;
3375               xmlhttp.open("GET", uri, false);
3376               xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3377               xmlhttp.onreadystatechange = function() {
3378                 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3379                   var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3380                       doc, str, ele, ev;
3381                   if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3382                     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3383                      *ここでは、responseTextを用いる
3384                      */
3385                     /*script要素とstyle要素は、
3386                      *_textプロパティに読み込んだテキストを格納しておく
3387                      *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3388                      */
3389                     if (tar.localName !== "script" && tar.localName !== "style") {
3390                       doc = new ActiveXObject("MSXML2.DomDocument");
3391                       str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3392                       NAIBU.doc.async = false;
3393                       NAIBU.doc.validateOnParse = false;
3394                       NAIBU.doc.resolveExternals = false;
3395                       NAIBU.doc.preserveWhiteSpace = false;
3396                       doc.loadXML(str);
3397                       ele = doc.documentElement;
3398                       tar._instance = tar.ownerDocument.importNode(ele, true);
3399                       if (id) {
3400                         tar._instance = tar._instance.ownerDocument.getElementById(id);
3401                       }
3402                     } else {
3403                       tar._text = xmlhttp.responseText;
3404                     }
3405                   } else if (!!tar._tar) {
3406                     tar._tar.src = uri;
3407                   }
3408                   /*S_LoadイベントとはSIE独自のイベント。
3409                    *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3410                    */
3411                   ev = tar.ownerDocument.createEvent("SVGEvents");
3412                   ev.initEvent("S_Load", false, false);
3413                   tar.dispatchEvent(ev);
3414                   tar.ownerDocument.documentElement._svgload_limited--;
3415                   /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3416                   if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3417                     ev = tar.ownerDocument.createEvent("SVGEvents");
3418                     ev.initEvent("SVGLoad", false, false);
3419                     tar.ownerDocument.documentElement.dispatchEvent(ev);
3420                   }
3421                   tar = type = doc = str = ev = void 0;
3422                   /*IEのメモリリーク対策として、空関数を入力*/
3423                   xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3424                   xmlhttp = void 0;
3425                 }
3426               };
3427               xmlhttp.send(null);
3428             }
3429           }
3430         }
3431         tar.ownerDocument.documentElement._svgload_limited--;
3432       }
3433       evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3434     }, false);
3435     tar = evt = void 0;
3436   }, false);
3437   return this;
3438 };
3439 function SVGCSSRule() { 
3440   CSSRule.apply(this, arguments);
3441   // Additional CSS RuleType to support ICC color specifications
3442   /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3443   return this;
3444 };
3445 SVGCSSRule.prototype = new CSSRule();  //ノードのプロトタイプチェーンを作って、継承
3446
3447 /*SVGDocument
3448  *SVGの文書オブジェクト
3449  */
3450 function SVGDocument(){
3451   Document.apply(this);
3452   DocumentStyle.apply(this);
3453   /*readonly DOMString*/     this.title    = "";
3454   /*readonly DOMString*/     this.referrer = document.referrer;
3455   /*readonly DOMString*/     this.domain   = document.domain;
3456   /*readonly DOMString*/     this.URL      = document.location;
3457   /*readonly SVGSVGElement*/ this.rootElement;
3458   return this;
3459 };
3460 SVGDocument.prototype = new Document();  //ノードのプロトタイプチェーンを作って、継承
3461
3462 /*軽量化のために、頻繁に使われる処理をSVGDocumentの独自メソッドとしてまとめておく*/
3463 SVGDocument.prototype._domnodeEvent = function() {
3464   var evtt = this.createEvent("MutationEvents");
3465   evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3466   return evtt;
3467 };
3468
3469 /*SVGSVGElement
3470  *svg要素をあらわすオブジェクト
3471  */
3472 function SVGSVGElement(_doc) {
3473   SVGElement.apply(this, arguments);
3474   _doc && (this._tar = _doc.createElement("v:group"));
3475   _doc = void 0;
3476   /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3477    * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3478   this._svgload_limited = 0;
3479 /*                SVGElement,
3480                 SVGTests,
3481                 SVGLangSpace,
3482                 SVGExternalResourcesRequired,
3483                 SVGStylable,
3484                 SVGLocatable,
3485                 SVGFitToViewBox,
3486                 SVGZoomAndPan,
3487                 events::EventTarget,
3488                 events::DocumentEvent,
3489                 css::ViewCSS,
3490                 css::DocumentCSS {*/
3491   /*以下のx,y,width,heightプロパティは
3492    *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3493    *1000というのは、W3Cで触れていないため、独自の初期値を採用
3494    */
3495   var slen = SVGAnimatedLength;
3496   /*readonly SVGAnimatedLength*/ this.x      = new slen();
3497   /*readonly SVGAnimatedLength*/ this.y      = new slen();
3498   /*readonly SVGAnimatedLength*/ this.width  = new slen();
3499   /*readonly SVGAnimatedLength*/ this.height = new slen();
3500   slen = void 0;
3501   /*DOMString*/                  this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3502   /*DOMString*/                  this.contentStyleType  = "text/css";
3503   /*readonly SVGRect*/           this.viewport          = this.createSVGRect();
3504   /*useCurrentViewプロパティ
3505    * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3506    */
3507   /*boolean*/                    this.useCurrentView    = false;
3508   /*currentViewプロパティ
3509    * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3510    */
3511   /*readonly SVGViewSpec*/       this.currentView       = new SVGViewSpec(this);
3512   /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3513    *以下のプロパティを使って次の行列で示すことができる
3514    *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y] 
3515    */
3516   /*float*/                      this.currentScale     = 1;
3517   /*readonly SVGPoint*/          this.currentTranslate = this.createSVGPoint();
3518   /*以下は、SVGFitToViewBoxのインターフェースを用いる
3519    *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3520    */
3521   /*readonly SVGAnimatedRect*/   this.viewBox = this.currentView.viewBox;
3522   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3523   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3524   this._tx = 0;
3525   this._ty = 0;
3526   /*int*/                       this._currentTime = 0;
3527   /*DOMAttrModifiedイベントを利用して、
3528    *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3529    */
3530   this.addEventListener("DOMAttrModified", function(evt){
3531     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3532       return; //強制終了させる
3533     }
3534     var tar = evt.target,
3535         name = evt.attrName,
3536         tv, ovb, par, tp, sa, mos;
3537     if (name === "viewBox") {
3538       tar._cacheScreenCTM = null;
3539       tv = tar.viewBox.baseVal;
3540       ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3541       tv.x = parseFloat(ovb[0]);
3542       tv.y = parseFloat(ovb[1]);
3543       tv.width = parseFloat(ovb[2]);
3544       tv.height = parseFloat(ovb[3]);
3545       tar.viewBox.baseVal._isUsed = 1;
3546     } else if (name === "preserveAspectRatio") {
3547       tar._cacheScreenCTM = null;
3548       par = evt.newValue;
3549       tp = tar.preserveAspectRatio.baseVal;
3550       sa = 1;
3551       mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3552       if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3553         switch (RegExp.$1) {
3554           case "Min":
3555             sa += 1;
3556           break;
3557           case "Mid":
3558             sa += 2;
3559           break;
3560           case "Max":
3561             sa += 3;
3562           break;
3563         }
3564         switch (RegExp.$2) {
3565           case "Min":
3566           break;
3567           case "Mid":
3568             sa += 3;
3569           break;
3570           case "Max":
3571             sa += 6;
3572           break;
3573         }
3574         if (RegExp.$3 === "slice") {
3575           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3576         } else {
3577           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3578         }
3579       }
3580       tp.align = sa;
3581       tp.meetOrSlice = mos;
3582     } else if (name === "width") {
3583       /*viewportを更新する*/
3584       tar.viewport.width = tar.width.baseVal.value;
3585     } else if (name === "height") {
3586       tar.viewport.height = tar.height.baseVal.value;
3587     }
3588     evt = name = tv = ovb = par = tp = sa = mos = void 0;
3589   }, false);
3590   this.addEventListener("SVGLoad", function(evt){
3591     /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3592      *処理を書いたもの。属性が書き換わるたびに、再描画される
3593      */
3594     evt.target.addEventListener("DOMAttrModified", function(evt){
3595       var tar,
3596           evtt, tce, slist;
3597       if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3598         tar = evt.target;
3599         if (tar.parentNode) {
3600           evtt = tar.ownerDocument._domnodeEvent();
3601           evtt.target = tar;
3602           evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3603           tce = tar._capter; //tceは登録しておいたリスナーのリスト
3604           for (var j=0,tcli=tce.length;j<tcli;++j){
3605             if (tce[j]) {
3606               tce[j].handleEvent(evtt);
3607             }
3608           }
3609           if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3610             tar._cacheMatrix = void 0; //キャッシュを消去
3611             if (tar.firstChild) {
3612               slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3613               for (var i=0,sli=slist.length;i<sli;++i) {
3614                 tar = slist[i];
3615                 tar._cacheMatrix = void 0;
3616                 evtt = tar.ownerDocument.createEvent("MutationEvents");
3617                 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3618                 evtt.target = tar;
3619                 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3620                 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3621                 for (var j=0,tcli=tce.length;j<tcli;++j){
3622                   if (tce[j]) {
3623                     tce[j].handleEvent(evtt);
3624                   }
3625                 }
3626               }
3627             }
3628           }
3629         }
3630       }
3631       evtt = tar = evt = tce = slist = void 0;
3632     }, false)
3633     evt.target.addEventListener("DOMNodeRemovedFromDocument", function(evt){
3634       var tar = evt.target;
3635       tar._tar && tar._tar.parentNode && tar._tar.parentNode.removeChild(tar._tar);
3636       evt = tar = void 0;
3637     }, true);
3638     evt = void 0;
3639   }, false);
3640   return this;
3641 };
3642 SVGSVGElement.prototype = new SVGElement();
3643 /*void*/          SVGSVGElement.prototype.forceRedraw = function() {
3644 };
3645 /*float*/         SVGSVGElement.prototype.getCurrentTime = function(){
3646   return (this._currentTime);
3647 };
3648 /*void*/          SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3649   this._currentTime = seconds;
3650 };
3651 /*SVGNumber*/     SVGSVGElement.prototype.createSVGNumber = function(){
3652   var s = new SVGNumber();
3653   s.value = 0;
3654   return s;
3655 };
3656 /*SVGAngle*/     SVGSVGElement.prototype.createSVGAngle = function(){
3657   var s = new SVGAngle();
3658   s.value = 0;
3659   s.unitType = 1;
3660   return s;
3661 };
3662 /*SVGLength*/     SVGSVGElement.prototype.createSVGLength = function(){
3663   var s = new SVGLength();
3664   s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3665   return s;
3666 };
3667 /*SVGPoint*/      SVGSVGElement.prototype.createSVGPoint = function(){
3668   return new SVGPoint();
3669 };
3670 /*SVGMatrix*/     SVGSVGElement.prototype.createSVGMatrix = function(){
3671   //単位行列を作成
3672   return new SVGMatrix();
3673 };
3674 /*SVGRect*/       SVGSVGElement.prototype.createSVGRect = function(){
3675   return new SVGRect();
3676 };
3677 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransform = function(){
3678   var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3679   return s;
3680 };
3681 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3682   var s = new SVGTransform();
3683   s.setMatrix(matrix);
3684   return s;
3685 };
3686 /*getScreenCTM
3687  *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3688  */
3689 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3690   if (!!this._cacheScreenCTM) { //キャッシュがあれば
3691     return (this._cacheScreenCTM);
3692   }
3693   var vw = this.viewport.width,
3694       vh = this.viewport.height,
3695       vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3696   if (!this.useCurrentView) {
3697     vB = this.viewBox.baseVal;
3698     par = this.preserveAspectRatio.baseVal;    
3699   } else {
3700     vB = this.currentView.viewBox.baseVal;
3701     par = this.currentView.preserveAspectRatio.baseVal;
3702   }
3703   if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3704     this._tx = this._ty = 0;
3705     m = this.createSVGMatrix();
3706     this._cacheScreenCTM = m; //キャッシュを作っておく
3707     return m;
3708   } else {
3709     vbx = vB.x;
3710     vby = vB.y;
3711     vbw = vB.width;
3712     vbh = vB.height;
3713     rw = vw / vbw;
3714     rh = vh / vbh;
3715     xr = 1;
3716     yr = 1;
3717     tx = 0;
3718     ty = 0;
3719     if (par.align === 1) { //none
3720       xr = rw;
3721       yr = rh;
3722       tx = -vbx * xr;
3723       ty = -vby * yr;
3724     } else {
3725       var ax = (par.align + 1) % 3 + 1;
3726       var ay = Math.round(par.align / 3);
3727       switch (par.meetOrSlice) {
3728         case 1: //meet
3729           xr = yr = Math.min(rw, rh);
3730         break;
3731         case 2: //slice
3732           xr = yr = Math.max(rw, rh);
3733         break;
3734       }
3735       tx = -vbx * xr;
3736       ty = -vby * yr;
3737       switch (ax) {
3738         case 1: //xMin
3739         break;
3740         case 2: //xMid
3741           tx += (vw - vbw * xr) / 2;
3742         break;
3743         case 3: //xMax
3744           tx += vw - vbw * xr;
3745         break;
3746       }
3747       switch (ay) {
3748         case 1: //YMin
3749         break;
3750         case 2: //YMid
3751           ty += (vh - vbh * yr) / 2;
3752         break;
3753         case 3: //YMax
3754           ty += vh - vbh * yr;
3755         break;
3756       }
3757     }
3758   }
3759   //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3760   this._tx = tx;
3761   this._ty = ty;
3762   ttps =  this._tar.style;
3763   ttps.marginLeft = tx+ "px";
3764   ttps.marginTop = ty+ "px";
3765   m = this.createSVGMatrix();
3766   m.a = xr;
3767   m.d = yr;
3768   this._cacheScreenCTM = m; //キャッシュを作っておく
3769   vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3770   return m;
3771 };
3772
3773   /*interface SVGZoomAndPan*/
3774   // Zoom and Pan Types
3775 SVGZoomAndPan = {
3776   /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3777   /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3778   /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3779 };
3780
3781 function SVGFitToViewBox() {
3782   /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3783   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3784   return this;
3785 };
3786 function SVGViewSpec(ele) {
3787   SVGFitToViewBox.apply(this, arguments);
3788   /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3789   /*readonly SVGElement*/       this.viewTarget = ele;
3790   /*readonly DOMString*/        this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3791   return this;
3792 };
3793 SVGViewSpec.prototype = new SVGFitToViewBox();
3794
3795 function SVGGElement(_doc) {
3796   SVGElement.apply(this);
3797   this._tar = _doc.createElement("v:group");
3798   _doc = void 0;
3799   /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3800    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3801    */
3802   this.addEventListener("DOMNodeInserted", function(evt){
3803     var tar = evt.target;
3804     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3805       return; //強制終了させる
3806     }
3807     var tnext = tar.nextSibling,
3808         tpart = tar.parentNode._tar,
3809         isLast = true;
3810     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3811       tpart.insertBefore(tar._tar, tnext._tar);
3812     } else if (tnext && !tnext._tar && tpart) {
3813       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3814        *use要素や実体参照などは_tarプロパティがないことに注意
3815        */
3816       while (tnext) {
3817         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3818           tpart.insertBefore(tar._tar, tnext._tar);
3819           isLast = false;
3820         } 
3821         tnext = tnext.nextSibling;
3822       }
3823       if (isLast) {
3824         tpart.appendChild(tar._tar);
3825       }
3826     } else if (!tnext && tpart) {
3827       tpart.appendChild(tar._tar);      
3828     }
3829     tnext = tpart = isLast = evt = tar = void 0;
3830   }, false);
3831   return this;
3832 };
3833 SVGGElement.prototype = new SVGElement();
3834
3835 function SVGDefsElement() {
3836   SVGElement.apply(this, arguments);
3837   this.style.setProperty("display", "none");
3838   return this;
3839 };
3840 SVGDefsElement.prototype = new SVGElement();
3841
3842 function SVGDescElement() {
3843   SVGElement.apply(this, arguments);
3844   return this;
3845 }
3846 SVGDescElement.prototype = new SVGElement();
3847
3848 function SVGTitleElement() {
3849   SVGElement.apply(this, arguments);
3850   this.addEventListener("DOMCharacterDataModified", function(evt){
3851     evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3852   }, false);
3853   return this;
3854 }
3855 SVGTitleElement.prototype = new SVGElement();
3856
3857 function SVGSymbolElement(_doc) {
3858   SVGElement.apply(this, arguments);
3859   return this;
3860 }
3861 SVGSymbolElement.prototype = new SVGElement();
3862
3863 function SVGUseElement() {
3864   SVGGElement.apply(this, arguments);
3865   var slen = SVGAnimatedLength;
3866   /*readonly SVGAnimatedLength*/   this.x = new slen();           //use要素のx属性に対応(以下、同様)
3867   /*readonly SVGAnimatedLength*/   this.y = new slen();
3868   /*readonly SVGAnimatedLength*/   this.width = new slen();
3869   /*readonly SVGAnimatedLength*/   this.height = new slen();
3870   slen = void 0;
3871   /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3872   /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3873   this.addEventListener("DOMNodeInserted", function(evt){
3874     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3875       return; //強制終了させる
3876     }
3877     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3878   }, false);
3879   this.addEventListener("S_Load", function(evt){
3880     var tar = evt.target,
3881         style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3882         fontSize = parseFloat(style.getPropertyValue("font-size")),
3883         trans = tar.ownerDocument.documentElement.createSVGTransform(),
3884         tari = tar._instance,
3885         svg, ti, ta, tn;
3886     tar.x.baseVal._emToUnit(fontSize);
3887     tar.y.baseVal._emToUnit(fontSize);
3888     tar.width.baseVal._emToUnit(fontSize);
3889     tar.height.baseVal._emToUnit(fontSize);
3890     tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tari, true);
3891     trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3892     tar.transform.baseVal.appendItem(trans);
3893     if (tar._instance.localName === "symbol") {
3894       /*symbol要素の場合、別途svg要素に置き換える*/
3895       svg = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "svg");
3896       svg.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3897         /*viewportをsymbol要素として新規に設定*/
3898         evt.target.nearestViewportElement = evt.currentTarget;
3899       }, true);
3900       tar._tar.appendChild(svg._tar);
3901       tn = tar.getScreenCTM();
3902       svg.setAttributeNS(null, "width", tar.width.baseVal.value);
3903       svg.setAttributeNS(null, "height", tar.height.baseVal.value);
3904         tari.hasAttributeNS(null, "viewBox") &&  svg.setAttributeNS(null, "viewBox", tari.getAttributeNS(null, "viewBox"));
3905         tari.hasAttributeNS(null, "preserveAspectRatio") &&  svg.setAttributeNS(null, "preserveAspectRatio", tari.getAttributeNS(null, "preserveAspectRatio"));
3906          svg._cacheScreenCTM = tn.multiply(svg.getScreenCTM());
3907       ti = tar.instanceRoot.firstChild;
3908       while (ti) {
3909         ta = ti.nextSibling;
3910         svg.appendChild(ti);
3911                ti.getScreenCTM && ti.getScreenCTM();
3912         ti = ta;
3913       }
3914       tar.appendChild(svg);
3915     } else {
3916       tar.appendChild(tar.instanceRoot);
3917     }
3918     evt = trans = tar = evtt = style = fontSize = svg = ti = ta = tn = void 0;
3919   }, false);
3920   SVGURIReference.apply(this);
3921   return this;
3922 };
3923 SVGUseElement.prototype = new SVGElement();
3924
3925 function SVGElementInstance() {
3926   /*EventTargetの代用として
3927    *Nodeオブジェクトを継承させる
3928    */
3929   Node.apply(this, arguments);
3930   /*readonly SVGElement*/ this.correspondingElement;       //use要素で使われる参照先の要素
3931   /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3932   /*readonly SVGElementInstance*/ this.parentNode;
3933   /*readonly SVGElementInstanceList*/ this.childNodes;
3934   /*readonly SVGElementInstance*/ this.firstChild;
3935   /*readonly SVGElementInstance*/ this.lastChild;
3936   /*readonly SVGElementInstance*/ this.previousSibling;
3937   /*readonly SVGElementInstance*/ this.nextSibling;
3938   return this;
3939 };
3940 SVGElementInstance.prototype = new Node();
3941 /*SVGElementInstanceList
3942  */
3943 function SVGElementInstanceList() { 
3944   /*readonly unsigned long*/ this.length = 0;
3945   return this;
3946 };
3947 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3948   return (this[index]);
3949 }
3950 function SVGImageElement(_doc) {
3951   SVGElement.apply(this, arguments);
3952   this._tar = _doc.createElement("v:image");
3953   //以下は、与えられた属性の値に対応する
3954   var slen = SVGAnimatedLength;
3955   /*readonly SVGAnimatedLength*/ this.x = new slen();
3956   /*readonly SVGAnimatedLength*/ this.y = new slen();
3957   /*readonly SVGAnimatedLength*/ this.width = new slen();
3958   /*readonly SVGAnimatedLength*/ this.height = new slen();
3959   _doc = slen = void 0;
3960   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3961   this.addEventListener("DOMNodeInserted", function(evt){
3962     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3963       return; //強制終了させる
3964     }
3965     var tar = evt.target;
3966     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3967     if (tar.nextSibling) {
3968       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3969         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3970       }
3971     } else if (!!tar.parentNode._tar){
3972       tar.parentNode._tar.appendChild(tar._tar);
3973     }
3974     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3975       var tar = evt.target,
3976           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3977           fontSize = parseFloat(style.getPropertyValue("font-size")),
3978           ts = tar._tar.style,
3979           ctm = tar.getScreenCTM(),
3980           po = tar.ownerDocument.documentElement.createSVGPoint(),
3981           fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3982           ttfia;
3983       tar.x.baseVal._emToUnit(fontSize);
3984       tar.y.baseVal._emToUnit(fontSize);
3985       tar.width.baseVal._emToUnit(fontSize);
3986       tar.height.baseVal._emToUnit(fontSize);
3987       ts.position = "absolute";
3988       po.x = tar.x.baseVal.value;
3989       po.y = tar.y.baseVal.value;
3990       po = po.matrixTransform(ctm);
3991       ts.left = po.x + "px";
3992       ts.top = po.y + "px";
3993       ts.width = tar.width.baseVal.value * ctm.a + "px";
3994       ts.height = tar.height.baseVal.value * ctm.d + "px";
3995       if (fillOpacity !== 1) {
3996         ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3997         ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3998         ttfia.Style = 0;
3999         ttfia.Opacity = fillOpacity * 100;
4000         ttfia = void 0;
4001       }
4002       evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
4003     }, false);
4004     evt = tar = void 0;
4005   }, false);
4006   SVGURIReference.apply(this);
4007   return this;
4008 };
4009 SVGImageElement.prototype = new SVGElement();
4010
4011 function SVGSwitchElement() {
4012   SVGElement.apply(this, arguments);
4013   return this;
4014 };
4015 SVGSwitchElement.prototype = new SVGElement();
4016
4017 //bookmarkletから呼び出されたらtrue
4018 var sieb_s;
4019 function GetSVGDocument(ele) {
4020   this._tar = ele;
4021   this._next = null;
4022   return this;
4023 }
4024 function _ca_() {
4025   if ((NAIBU._that.xmlhttp.readyState === 4)  &&  (NAIBU._that.xmlhttp.status === 200)) {
4026     NAIBU._that._ca();
4027   }
4028 };
4029  GetSVGDocument.prototype = {
4030   /*_initメソッド
4031    *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
4032    */
4033   _init : function() {
4034     /*objeiはobject要素かembed要素*/
4035     var xmlhttp = NAIBU.xmlhttp,
4036         objei = this._tar,
4037         data;
4038     if (this._tar.nodeName === "OBJECT") {
4039       data = "data";
4040     } else {
4041       data = "src";
4042     }
4043     xmlhttp.open("GET", objei.getAttribute(data), true);
4044     objei.style.display = "none";
4045     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4046     this.xmlhttp = xmlhttp;
4047     /*クロージャを利用しないことで、軽量化を計る*/
4048     NAIBU._that = this;
4049     xmlhttp.onreadystatechange = _ca_;
4050     xmlhttp.send(null);
4051     xmlhttp = objei = data = void 0;
4052   },
4053   /*コール関数。全処理を担う*/
4054   _ca : function() {
4055     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4056      *ここでは、responseTextを用いる
4057      */
4058     var ifr = this._tar.previousSibling,
4059         ifcw = ifr.contentWindow,
4060         _doc;
4061     if (ifcw) {
4062       ifr.contentWindow.screen.updateInterval = 999;
4063       _doc = ifr.contentWindow.document;
4064       _doc.write("");
4065       _doc.close(); // これがないと document.body は null になる
4066     } else {        //インラインSVGの場合
4067       _doc = document;
4068     }
4069     if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4070       _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4071       _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4072       var st = _doc.createStyleSheet(),
4073           vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4074       st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4075         + "dn\\:defs{display:none}"
4076         + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4077         + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4078       st = vmlUrl = void 0;
4079     }
4080     DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4081     var str = this.xmlhttp.responseText,
4082         objei = this._tar,
4083         s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4084         tar = s.documentElement,
4085         tview = tar.viewport,
4086         objw, objh, fi, n, attr, att, w, h,
4087         sdt = tar._tar,
4088         sp = _doc.createElement("div"),
4089         dcp = _doc.createElement("v:group"),
4090         backr = _doc.createElement("v:rect"),
4091         style, fontSize, sw, sh, trstyle, backrs, viewWidth, viewHeight, backdown, backright,
4092         bfl, bft, bl, text,
4093         _parseFloat = parseFloat,
4094         ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4095           oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4096     if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4097       this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4098       return;
4099     }
4100     s._iframe = ifr;                     //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4101     oba.setAttribute("id","_NAIBU_outline");
4102     _doc.body.appendChild(oba);
4103     sp.style.margin = "-1px,0px,0px,-1px"
4104     if (ifcw) {
4105        _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4106     }
4107     ndoc.async = false;
4108     /*下記のプロパティについては、Microsoftのサイトを参照
4109      *ResolveExternals Property [Second-level DOM]
4110      * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4111      *ValidateOnParse Property [Second-level DOM]
4112      * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4113      */
4114     ndoc.validateOnParse = false;
4115     ndoc.resolveExternals = false;
4116     ndoc.preserveWhiteSpace = true;
4117     ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4118     /*IE6-8のみで使えるupdateIntervalは、
4119      *描画間隔の調整が可能。デフォルトは0。
4120      *スクロール時にバグが起きるので、0に戻してやる必要がある。
4121      */
4122     screen.updateInterval = 999;
4123     if (/&[^;]+;/.test(str)) {
4124       /*以下の処理は、実体参照を使ったとき
4125        *代替の処理を用いて、実体参照を処理するもの
4126        */
4127       var tmp = str;
4128       var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4129       for (var i=0; i<enti.length; i++) {
4130       var map = enti.item(i);
4131       var regex = new RegExp("&"+map.nodeName+";", "g");
4132       tmp = tmp.replace(regex, map.firstChild.xml);
4133       }
4134       ndoc.loadXML(tmp);
4135       tmp = void 0;
4136     }
4137     tview.top = 0;
4138     tview.left = 0;
4139     tview.width = objei.clientWidth;
4140     tview.height = objei.clientHeight;
4141     if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4142       tview.height = screen.availHeight;
4143     }
4144     if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4145       tar.viewport.height = screen.width;
4146     }
4147     objw = objei.getAttribute("width");
4148     objh = objei.getAttribute("height");
4149     if (objw) {
4150       tar.setAttributeNS(null, "width", objw);
4151     }
4152     if (objh) {
4153       tar.setAttributeNS(null, "height", objh);
4154     }
4155     fi = ndoc.documentElement.firstChild;
4156     attr = ndoc.documentElement.attributes;
4157     /*ルート要素のNamedNodeMapを検索する*/
4158     for (var i=0,atli=attr.length;i<atli;++i) {
4159       att = s.importNode(attr[i], false);
4160       tar.setAttributeNodeNS(att);
4161     }
4162     str = attr = void 0;
4163     dcp.style.width = tview.width+ "px";
4164     dcp.style.height = tview.height+ "px";
4165     dcp.coordsize = tview.width+ " " +tview.height;
4166     sp.appendChild(dcp);
4167     if (ifcw) {
4168       _doc.body.appendChild(sp);
4169     } else {
4170       this._tar.parentNode.insertBefore(sp, this._tar);
4171     }
4172     dcp.appendChild(sdt);
4173     while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4174       n = s.importNode(fi, true);
4175       tar.appendChild(n);
4176       fi = fi.nextSibling;
4177     }
4178     fi = void 0;
4179     /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4180      *ドキュメントにそのオブジェクトを結び付けておく
4181      */
4182     s._window = ifcw;
4183     /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4184      *作り出す作業を行う。これは必須
4185      */
4186     style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4187     fontSize = _parseFloat(style.getPropertyValue("font-size"));
4188     tar.x.baseVal._emToUnit(fontSize);
4189     tar.y.baseVal._emToUnit(fontSize);
4190     tar.width.baseVal._emToUnit(fontSize);
4191     tar.height.baseVal._emToUnit(fontSize);
4192     sw = tar.width.baseVal.value;
4193     sh = tar.height.baseVal.value;
4194     backr.style.position = "absolute";
4195     w = tview.width;
4196     h = tview.height;
4197     backr.style.width = w+ "px";
4198     backr.style.height = h+ "px";
4199     backr.style.zIndex = -1;
4200     backr.stroked = "false";
4201     backr.filled = "false";
4202     tar._tar.appendChild(backr);
4203     trstyle = tar._tar.style;
4204     trstyle.visibility = "visible";
4205     trstyle.position = "absolute";
4206     /*以下、画像を切り取り*/
4207     trstyle.overflow = "hidden";
4208     /*ウィンドウ枠の長さを決定する*/
4209     viewWidth = w > sw ? sw : w;
4210     viewHeight = h > sh ? sh : h;
4211     backrs = backr.currentStyle;
4212     bfl = _parseFloat(backrs.left);
4213     bft = _parseFloat(backrs.top);
4214     bl = -tar._tx;                  //blやbtは、ずれを調整するのに使う
4215     bt = -tar._ty;
4216     if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4217       bl = bfl;
4218       dcp.style.left = -bl+ "px";
4219     }
4220     if (bft !== 0 && !isNaN(bfl)) {
4221       bt = bft;
4222       dcp.style.top = -bt+ "px";
4223     }
4224     backright = bl + viewWidth + 1;
4225     backdown = bt + viewHeight + 1;
4226     trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4227     this._document = s;
4228     if ("_svgload_limited" in s.documentElement) {
4229       /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4230        *xlink:href属性が指定されるたびに+1となる。
4231        *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4232        *
4233        *目的:
4234        * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4235        */
4236       s.documentElement._svgload_limited--;
4237       if (s.documentElement._svgload_limited < 0) {
4238         var evt = s.createEvent("SVGEvents");
4239         evt.initEvent("SVGLoad", false, false);
4240         s.documentElement.dispatchEvent(evt);
4241       }
4242     }
4243     //以下、テキストの位置を修正
4244     text = s.documentElement._tar.getElementsByTagName("div");
4245     for (var i=0, texti;text[i];++i) {
4246       texti = text[i];
4247       if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4248         var tis = texti.style;
4249         tis.left = _parseFloat(tis.left) + bl + "px";
4250         tis.top = _parseFloat(tis.top) + bt + "px";
4251         tis = void 0;
4252       }
4253     }
4254     //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4255     ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4256     s._isLoaded = 1;  //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4257     s.defaultView._cache = s.defaultView._cache_ele = null;
4258     oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4259     trstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4260     /*IEのメモリリーク対策として、空関数を入力*/
4261     this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4262     if (this._next) {
4263       ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4264       ifr = ifcw = s = void 0;
4265       this._next._init();
4266     } else {
4267       /*全要素の読み込みが終了した場合*/
4268       if (s.implementation._buffer_) {
4269         screen.updateInterval = 0;
4270         /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4271         NAIBU._buff_num = 0;
4272         NAIBU._buff = setInterval(function(){
4273           var n = NAIBU._buff_num,
4274               dbuf = DOMImplementation._buffer_,
4275               dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
4276               s, evt;
4277           if (dbufli === 0) {
4278             clearInterval(NAIBU._buff);              
4279           } else {
4280             for (var i=0;i<50;++i) {
4281               s = dbuf[n];
4282               evt = dbuf[n+1];
4283               s.dispatchEvent(evt);
4284               n += 2;
4285               s = evt = void 0;
4286               if (n >= dbufli) {
4287                 clearInterval(NAIBU._buff);
4288                 DOMImplementation._buffer_ = null;
4289                 NAIBU.Time.start();
4290                 dbuf = n = dbufli = void 0;
4291                 return;
4292               }
4293             }
4294             NAIBU._buff_num = n;
4295           }
4296           dbuf = n = dbufli = void 0;
4297         }, 1);
4298         ifr = ifcw = s = void 0;
4299       } else {
4300         ifr = ifcw = s = void 0;
4301         NAIBU.Time.start();
4302       }
4303       delete NAIBU.doc;
4304     }
4305   },
4306   /*SVGDocument*/  getSVGDocument : function() {
4307     return (this._document);
4308   }
4309 };
4310 /*空関数(IEのメモリリーク対策)*/
4311 NAIBU.emptyFunction = function() {};
4312
4313 /*SVGStyleElement
4314  *style要素をあらわすオブジェクト
4315  */
4316 function SVGStyleElement(_doc) {
4317   SVGElement.apply(this);
4318   LinkStyle.apply(this);
4319   /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4320    *CSS2 1. Document Object Model Style Sheets
4321    * 1.3. Document Extensions
4322    *   Interface LinkStyle (introduced in DOM Level 2)
4323    * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4324    */
4325   /*以下はそれぞれ、属性の値に対応している*/
4326   /*DOMString*/ this.xmlspace;
4327   /*DOMString*/ this.type = "text/css";
4328   /*DOMString*/ this.media;
4329   /*DOMString*/ this.title;
4330   SVGURIReference.apply(this);
4331   this.addEventListener("DOMAttrModified", function(evt){
4332     if (evt.attrName === "type") {
4333       evt.target.type = evt.newValue;
4334     } else if (evt.attrName === "title") {
4335       evt.target.title = evt.newValue;
4336     }
4337     evt = void 0;
4338   }, false);
4339   this.addEventListener("S_Load", function(evt){
4340     var tar = evt.target,
4341         sheet = tar.sheet,
4342         styleText = tar._text,
4343         tod = tar.ownerDocument,
4344         style = _doc.createElement("style"),
4345         ri, rsc, scri, rsi;
4346     NAIBU._temp_doc = tod;
4347     sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4348     sheet.ownerNode = tar;
4349     /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4350     _doc.documentElement.firstChild.appendChild(style);
4351     style.styleSheet.cssText = styleText;
4352     for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4353       ri = rules[i];
4354       scri = new CSSStyleRule();
4355       scri.selectorText = ri.selectorText;
4356       scri.style.cssText = ri.style.cssText;
4357       rsc = scri.style.cssText.split(";");
4358       for (var j=0, rsli=rsc.length;j<rsli;++j) {
4359         rsi = rsc[j].split(": ");
4360         scri.style.setProperty(rsi[0], rsi[1]);
4361       }
4362       sheet.cssRules[sheet.cssRules.length] = scri;
4363     }
4364     tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4365       var tar = evt.target,
4366           doc = tar.ownerDocument,
4367           rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4368           selector, ru, tcb = tar.className.baseVal || ".,.";
4369       for (var i=0, rli=rules.length;i<rli;++i) {
4370         selector = rules[i].selectorText;
4371         /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4372         ru = tar._rules || [];
4373         if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4374             || (tar.nodeName === selector)) {
4375           ru[ru.length] = rules[i];
4376         }
4377         tar._rules = ru;
4378       }
4379       tar = doc = rules = void 0;
4380     }, true);
4381     tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4382   }, false);
4383   this.addEventListener("DOMNodeInserted", function(evt){
4384     var tar = evt.target;
4385     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4386       if (tar.nodeName === "#cdata-section") {
4387         evt.currentTarget._text = tar.data;
4388       }
4389       return;
4390     }
4391     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4392       var tar = evt.target;
4393       if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4394         var evtt = tar.ownerDocument.createEvent("SVGEvents");
4395         evtt.initEvent("S_Load", false, false);
4396         evt.currentTarget.dispatchEvent(evtt);
4397       }
4398       tar = evt = void 0;
4399     }, false);
4400   }, false);
4401   return this;
4402 };
4403 SVGStyleElement.prototype = new SVGElement();
4404
4405 /*SVGPoint
4406  *2次元座標の点(x,y)を表すオブジェクト
4407  */
4408 function SVGPoint() { 
4409   return this;
4410 };
4411 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4412 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4413   if (!isFinite(matrix.a) || !isFinite(matrix.b) || !isFinite(matrix.c) || !isFinite(matrix.d) || !isFinite(matrix.e) || !isFinite(matrix.f)) {
4414     throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4415   }
4416   var s = new SVGPoint();
4417   s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
4418   s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
4419   return s;
4420 };
4421
4422 function SVGPointList() { 
4423   return this;
4424 };
4425 /*SVGPointListのメソッドはSVGPathSegListを参照*/
4426
4427 /*SVGMatrix
4428  *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4429  *[a c e]
4430  *[b d f]
4431  *[0 0 1]
4432  */
4433 function SVGMatrix() { 
4434   return this;
4435 };
4436 SVGMatrix.prototype = {
4437   /*float*/ a : 1,
4438   /*float*/ b : 0,
4439   /*float*/ c : 0,
4440   /*float*/ d : 1,
4441   /*float*/ e : 0,
4442   /*float*/ f : 0,
4443   /*multiplyメソッド
4444    *行列の積を求めて返す
4445    */
4446   /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4447     var s = new SVGMatrix(),
4448         m = secondMatrix,
4449         isf = isFinite,
4450         t = this;
4451     if (!isf(m.a) || !isf(m.b) || !isf(m.c) || !isf(m.d) || !isf(m.e) || !isf(m.f)) {
4452       throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4453     }
4454     s.a = t.a * m.a + t.c * m.b;
4455     s.b = t.b * m.a + t.d * m.b;
4456     s.c = t.a * m.c + t.c * m.d;
4457     s.d = t.b * m.c + t.d * m.d;
4458     s.e = t.a * m.e + t.c * m.f + t.e;
4459     s.f = t.b * m.e + t.d * m.f + t.f;
4460     m = t = secondMatrix = isf = void 0;
4461     return s;
4462   },
4463   /*inverseメソッド
4464    *逆行列を返す
4465    */
4466   /*SVGMatrix*/ inverse : function() {
4467     var s = new SVGMatrix(), n = this._determinant();
4468     if (n !== 0) {
4469       s.a = this.d / n;
4470       s.b = -this.b / n;
4471       s.c = -this.c / n;
4472       s.d = this.a / n;
4473       s.e = (this.c * this.f - this.d * this.e) / n;
4474       s.f = (this.b * this.e - this.a * this.f) / n;
4475       return s;
4476     } else {
4477       throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4478     }
4479   },
4480   /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4481     var m = new SVGMatrix();
4482     m.e = x;
4483     m.f = y;
4484     var s =  this.multiply(m);
4485     m = void 0;
4486     return s;
4487   },
4488   /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4489     var m = new SVGMatrix();
4490     m.a = scaleFactor;
4491     m.d = scaleFactor;
4492     var s =  this.multiply(m);
4493     m = void 0;
4494     return s;
4495   },
4496   /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4497     var m = new SVGMatrix();
4498     m.a = scaleFactorX;
4499     m.d = scaleFactorY;
4500     var s =  this.multiply(m);
4501     m = void 0;
4502     return s;
4503   },
4504   /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4505     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4506     m.a = Math.cos(rad);
4507     m.b = Math.sin(rad);
4508     m.c = -m.b;
4509     m.d = m.a;
4510     var s =  this.multiply(m);
4511     m = rad = void 0;
4512     return s;
4513   },
4514   //座標(x, y)と原点の角度の分だけ、回転する
4515   /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4516     if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4517       throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4518     }
4519     var m = new SVGMatrix(), rad = Math.atan2(y, x);
4520     m.a = Math.cos(rad);
4521     m.b = Math.sin(rad);
4522     m.c = -m.b;
4523     m.d = m.a;
4524     var s =  this.multiply(m);
4525     m = rad = void 0;
4526     return s;
4527   },
4528   /*SVGMatrix*/ flipX : function() {
4529     var m = new SVGMatrix();
4530     m.a = -m.a;
4531     var s =  this.multiply(m);
4532     m = void 0;
4533     return s;
4534   },
4535   /*SVGMatrix*/ flipY : function() {
4536     var m = new SVGMatrix();
4537     m.d = -m.d;
4538     var s =  this.multiply(m);
4539     m = void 0;
4540     return s;
4541   },
4542   /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4543     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4544     m.c = Math.tan(rad);
4545     var s =  this.multiply(m);
4546     m = void 0;
4547     return s;
4548   },
4549   /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4550     var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4551     m.b = Math.tan(rad);
4552     var s =  this.multiply(m);
4553     m = void 0;
4554     return s;
4555   },
4556   //行列式
4557   /*float*/ _determinant : function() {
4558     return (this.a * this.d - this.b * this.c);
4559   }
4560 };
4561
4562 function SVGTransform() { 
4563   /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4564   return this;
4565 };
4566     // Transform Types
4567   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN   = 0;
4568   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX    = 1;
4569   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4570   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE     = 3;
4571   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE    = 4;
4572   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX     = 5;
4573   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY     = 6;
4574 SVGTransform.prototype = {
4575   /*ダミーの単位行列。各メソッドで使う*/
4576   _matrix : (new SVGMatrix()),
4577   /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4578   /*readonly float*/ angle : 0,
4579   /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4580     this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4581     this.matrix = this._matrix.multiply(matrix);
4582   },
4583   /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4584     this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4585     this.matrix = this._matrix.translate(tx, ty);
4586   },
4587   /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4588     this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4589     this.matrix = this._matrix.scaleNonUniform(sx, sy);
4590   },
4591   /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4592     this.angle = angle;
4593     this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4594     this.matrix = this._matrix.rotate(angle);
4595     this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4596     this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4597   },
4598   /*void*/ setSkewX : function(/*float*/ angle ) {
4599     this.angle = angle;
4600     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4601     this.matrix = this._matrix.skewX(angle);
4602   },
4603   /*void*/ setSkewY : function(/*float*/ angle ) {
4604     this.angle = angle;
4605     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4606     this.matrix = this._matrix.skewY(angle);
4607   }
4608 };
4609
4610 function SVGTransformList() { 
4611   return this;
4612 };
4613 /*SVGTransformListのメソッドはSVGPathSegListを参照*/
4614
4615 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4616   var t = new SVGTransform();
4617   t.setMatrix(matrix);
4618   return t;
4619 }
4620 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4621   if(this.numberOfItems === 0) {
4622     return null;
4623   } else {
4624     var s = this.getItem(0), m = s.matrix;
4625     for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4626       m = m.multiply(this.getItem(i).matrix);
4627     }
4628     s.setMatrix(m);
4629     this.initialize(s);
4630     return s;
4631   }
4632 }
4633
4634 function SVGAnimatedTransformList() { 
4635   /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4636   return this;
4637 };
4638 function SVGPreserveAspectRatio() { 
4639   /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4640   /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4641   return this;
4642 };
4643 (function(t) {
4644     // Alignment Types
4645   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN  = 0;
4646   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE     = 1;
4647   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4648   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4649   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4650   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4651   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4652   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4653   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4654   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4655   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4656     // Meet-or-slice Types
4657   /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN   = 0;
4658   /*unsigned short*/ t.SVG_MEETORSLICE_MEET  = 1;
4659   /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4660 })(SVGPreserveAspectRatio);
4661
4662 function SVGAnimatedPreserveAspectRatio() { 
4663   /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4664   return this;
4665 };
4666
4667 function SVGPathSeg() { 
4668   /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4669   /*readonly DOMString*/      this.pathSegTypeAsLetter = null;
4670   return this;
4671 };
4672
4673 (function(t) {
4674     // Path Segment Types
4675   /*unsigned short*/ t.PATHSEG_UNKNOWN                      = 0;
4676   /*unsigned short*/ t.PATHSEG_CLOSEPATH                    = 1;
4677   /*unsigned short*/ t.PATHSEG_MOVETO_ABS                   = 2;
4678   /*unsigned short*/ t.PATHSEG_MOVETO_REL                   = 3;
4679   /*unsigned short*/ t.PATHSEG_LINETO_ABS                   = 4;
4680   /*unsigned short*/ t.PATHSEG_LINETO_REL                   = 5;
4681   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS            = 6;
4682   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL            = 7;
4683   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS        = 8;
4684   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL        = 9;
4685   /*unsigned short*/ t.PATHSEG_ARC_ABS                      = 10;
4686   /*unsigned short*/ t.PATHSEG_ARC_REL                      = 11;
4687   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS        = 12;
4688   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL        = 13;
4689   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS          = 14;
4690   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL          = 15;
4691   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS     = 16;
4692   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL     = 17;
4693   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4694   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4695 })(SVGPathSeg);
4696 /*SVGPathSegxx
4697  *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4698  */
4699 function SVGPathSegClosePath() {
4700   return this;
4701 };
4702 SVGPathSegClosePath.prototype = {
4703   pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4704   pathSegTypeAsLetter : "z"
4705 };
4706 function SVGPathSegMovetoAbs() { 
4707   /*float* this.x;
4708   /*float* this.y;*/
4709   return this;
4710 };
4711 SVGPathSegMovetoAbs.prototype = {
4712   pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4713   pathSegTypeAsLetter : "M"
4714 };
4715 function SVGPathSegMovetoRel() { 
4716   /*float*/ this.x;
4717   /*float*/ this.y;
4718   return this;
4719 };
4720 SVGPathSegMovetoRel.prototype = {
4721   pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4722   pathSegTypeAsLetter : "m"
4723 };
4724 function SVGPathSegLinetoAbs() { 
4725   /*float* this.x;
4726   /*float* this.y;*/
4727   return this;
4728 };
4729 SVGPathSegLinetoAbs.prototype = {
4730   pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4731   pathSegTypeAsLetter : "L"
4732 };
4733 function SVGPathSegLinetoRel() { 
4734   /*float*/ this.x;
4735   /*float*/ this.y;
4736   return this;
4737 };
4738 SVGPathSegLinetoRel.prototype = {
4739   pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4740   pathSegTypeAsLetter : "l"
4741 };
4742 function SVGPathSegCurvetoCubicAbs() { 
4743   /*float* this.x;
4744   /*float* this.y;
4745   /*float* this.x1;
4746   /*float* this.y1;
4747   /*float* this.x2;
4748   /*float* this.y2;*/
4749   return this;
4750 };
4751 SVGPathSegCurvetoCubicAbs.prototype = {
4752   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4753   pathSegTypeAsLetter : "C"
4754 };
4755 function SVGPathSegCurvetoCubicRel() { 
4756   /*float* this.x;
4757   /*float* this.y;
4758   /*float* this.x1;
4759   /*float* this.y1;
4760   /*float* this.x2;
4761   /*float* this.y2;*/
4762   return this;
4763 };
4764 SVGPathSegCurvetoCubicRel.prototype = {
4765   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4766   pathSegTypeAsLetter : "c"
4767 };
4768 function SVGPathSegCurvetoQuadraticAbs() { 
4769   /*float*/ this.x;
4770   /*float*/ this.y;
4771   /*float*/ this.x1;
4772   /*float*/ this.y1;
4773   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4774   this.pathSegTypeAsLetter = "Q";
4775   return this;
4776 };
4777 function SVGPathSegCurvetoQuadraticRel() { 
4778   /*float*/ this.x;
4779   /*float*/ this.y;
4780   /*float*/ this.x1;
4781   /*float*/ this.y1;
4782   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4783   this.pathSegTypeAsLetter = "q";
4784   return this;
4785 };
4786
4787 function SVGPathSegArcAbs() { 
4788   /*float*/ this.x;
4789   /*float*/ this.y;
4790   /*float*/ this.r1;
4791   /*float*/ this.r2;
4792   /*float*/ this.angle;
4793   return this;
4794 };
4795 SVGPathSegArcAbs.prototype = {
4796   /*boolean*/ largeArcFlag : true,
4797   /*boolean*/ sweepFlag : true,
4798   pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4799   pathSegTypeAsLetter : "A"
4800 };
4801 function SVGPathSegArcRel() { 
4802   /*float*/ this.x;
4803   /*float*/ this.y;
4804   /*float*/ this.r1;
4805   /*float*/ this.r2;
4806   /*float*/ this.angle;
4807   return this;
4808 };
4809 SVGPathSegArcRel.prototype = {
4810   /*boolean*/ largeArcFlag : true,
4811   /*boolean*/ sweepFlag : true,
4812   pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4813   pathSegTypeAsLetter : "a"
4814 };
4815 function SVGPathSegLinetoHorizontalAbs() { 
4816   /*float*/ this.x;
4817   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4818   this.pathSegTypeAsLetter = "H";
4819   return this;
4820 };
4821 function SVGPathSegLinetoHorizontalRel() { 
4822   /*float*/ this.x;
4823   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4824   this.pathSegTypeAsLetter = "h";
4825   return this;
4826 };
4827 function SVGPathSegLinetoVerticalAbs() { 
4828   /*float*/ this.y;
4829   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4830   this.pathSegTypeAsLetter = "V";
4831   return this;
4832 };
4833 function SVGPathSegLinetoVerticalRel() { 
4834   /*float*/ this.y;
4835   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4836   this.pathSegTypeAsLetter = "v";
4837   return this;
4838 };
4839 function SVGPathSegCurvetoCubicSmoothAbs() { 
4840   /*float*/ this.x;
4841   /*float*/ this.y;
4842   /*float*/ this.x2;
4843   /*float*/ this.y2;
4844   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4845   this.pathSegTypeAsLetter = "S";
4846   return this;
4847 };
4848 function SVGPathSegCurvetoCubicSmoothRel() {
4849   /*float*/ this.x;
4850   /*float*/ this.y;
4851   /*float*/ this.x2;
4852   /*float*/ this.y2;
4853   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4854   this.pathSegTypeAsLetter = "s";
4855   return this;
4856 };
4857 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4858   /*float*/ this.x;
4859   /*float*/ this.y;
4860   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4861   this.pathSegTypeAsLetter = "T";
4862   return this;
4863 };
4864 function SVGPathSegCurvetoQuadraticSmoothRel() {
4865   /*float*/ this.x;
4866   /*float*/ this.y;
4867   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4868   this.pathSegTypeAsLetter = "t";
4869   return this;
4870 };
4871 function SVGPathSegList() {
4872   return this;
4873 };
4874 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4875   SVGNumberList.prototype[prop] = SVGLengthList.prototype[prop] = SVGPointList.prototype[prop] = SVGTransformList.prototype[prop] = SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4876 };
4877 prop = void 0;
4878
4879 /*documentは引数の変数として登録しておく*/
4880 (function(_doc, _math) {
4881 //freeArg関数はunloadで使う解放処理
4882 NAIBU.freeArg = function() {
4883   SVGPathElement = _doc = _math = void 0;
4884 };
4885 //仮のfill属性とstroke属性の処理
4886 NAIBU._setPaint = function(tar, matrix) {
4887   /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4888    *処理を行う。SVGPaintインターフェースをも用いる
4889    */
4890   var tod = tar.ownerDocument,
4891       _doc = tod._document_,
4892       el = tar._tar,
4893       style = tod.defaultView.getComputedStyle(tar, ""),
4894       fill = style.getPropertyCSSValue("fill"),
4895       stroke = style.getPropertyCSSValue("stroke"),
4896       fp = fill.paintType,
4897       sp = stroke.paintType,
4898       fillElement, fc,
4899       num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4900       t, evtt, fillOpacity, strs, cursor, vis, disp,
4901       strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4902   if (!el) {
4903     return;
4904   }
4905   /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4906   while (el.firstChild) {
4907     el.removeChild(el.firstChild);
4908   }
4909   if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4910     if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4911       /*再度、設定。css.jsのsetPropertyを参照*/
4912       style.setProperty("color", style.getPropertyValue("color"));
4913     }
4914     fillElement = _doc.createElement("v:fill");
4915     fc = fill.rgbColor;
4916     num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4917     fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4918     fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4919     if (fillOpacity < 1) {
4920       fillElement.setAttribute("opacity", fillOpacity+"");
4921     }
4922     el.appendChild(fillElement);
4923     fillElement = fc = fillOpacity = void 0;
4924   } else if (fill.uri) {
4925     /*以下では、Gradation関連の要素に、イベントを渡すことで、
4926      *この要素の、グラデーション描画を行う
4927      */
4928     t = tod.getElementById(fill.uri);
4929     if (t) {
4930       evtt = tod._domnodeEvent();
4931       evtt._tar = _doc.createElement("v:fill");
4932       evtt._style = style;
4933       evtt._ttar = tar;
4934       t.dispatchEvent(evtt);
4935       if (t.localName !== "radialGradient") {
4936         el.appendChild(evtt._tar);
4937       }
4938       t = evtt = void 0;
4939     }
4940   } else {
4941     el.filled = "false";
4942   }
4943   if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4944     if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4945       /*再度、設定。css.jsのsetPropertyを参照*/
4946       style.setProperty("color", style.getPropertyValue("color"));
4947     }
4948     strokeElement = _doc.createElement("v:stroke");
4949     sgsw = style.getPropertyCSSValue("stroke-width");
4950     w = tod.documentElement.viewport.width;
4951     h = tod.documentElement.viewport.height;
4952     sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4953     swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4954     strokeElement.setAttribute("weight", swx + "px");
4955     sgsw = w = h = void 0;
4956     if (!stroke.uri) {
4957       fc = stroke.rgbColor;
4958       strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4959       strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4960       if (swx < 1) {
4961         strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4962       }
4963       if (strokeOpacity < 1) {
4964         strokeElement.setAttribute("opacity", strokeOpacity+"");
4965       }
4966       fc = strokeOpacity = void 0;
4967     }
4968     strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4969     strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4970     if (style.getPropertyValue("stroke-linecap") === "butt") {
4971       strokeElement.setAttribute("endcap", "flat");
4972     } else {
4973       strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4974     }
4975     tsd = style.getPropertyValue("stroke-dasharray");
4976     if (tsd !== "none") {
4977       if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4978         strs = tsd.split(",");
4979         for (var i = 0, sli = strs.length; i < sli; ++i) {
4980           strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4981         }
4982         strokedasharray = strs.join(" ");
4983         if (strs.length % 2 === 1) {
4984           strokedasharray += " " + strokedasharray;
4985         }
4986       }
4987       strokeElement.setAttribute("dashstyle", strokedasharray);
4988       tsd = strs = void 0;
4989     }
4990     el.appendChild(strokeElement);
4991     strokeElement = tsd = void 0;
4992   } else {
4993     el.stroked = "false";
4994   }
4995   cursor = style.getPropertyCSSValue("cursor");
4996   if (cursor && !cursor._isDefault) { //初期値でないならば
4997     el.style.cursor = cursor.cssText.split(":")[1];
4998   }
4999   vis = style.getPropertyCSSValue("visibility");
5000   if (vis && !vis._isDefault) {
5001     el.style.visibility = vis.cssText.split(":")[1];
5002   }
5003   disp = style.getPropertyCSSValue("display");
5004   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
5005     el.style.display = "none";
5006    } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
5007     el.style.display = "inline-block";
5008   }
5009   tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
5010 };
5011
5012 function SVGPathElement(_doc) {
5013   SVGElement.apply(this);
5014   this._tar = _doc.createElement("v:shape");
5015   //interface SVGAnimatedPathData
5016   var sp = SVGPathSegList;
5017   /*readonly SVGPathSegList*/ this.pathSegList = new sp();
5018   this.animatedPathSegList = this.pathSegList;
5019   /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
5020   sp = _doc = void 0;
5021   this.animatedNormalizedPathSegList = this.normalizedPathSegList;
5022   /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
5023   //以下は、d属性に変更があった場合の処理
5024   this.addEventListener("DOMAttrModified", this._attrModi, false);
5025   /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
5026    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
5027    */
5028   this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
5029   return this;
5030 };
5031 SVGPathElement.prototype = new SVGElement();
5032 (function(_sproto) {
5033 _sproto._attrModi = function(evt){
5034   var tar = evt.target;
5035   if (evt.attrName === "d" && evt.newValue !== ""){
5036     /* d属性の値が空の場合は、描画を行わないようにする
5037      * 
5038      *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5039      */
5040     var tnl = tar.normalizedPathSegList,
5041         tlist = tar.pathSegList;
5042     if (tnl.numberOfItems > 0) {
5043       tnl.clear();
5044       tlist.clear();
5045     }
5046     /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5047      *JSONにおける表現は以下のとおり
5048      *D = [["M", 20, 30], ["L", 20 40]]
5049      */
5050     var taco = tar._com,
5051         sgs = taco.isSp,
5052         dd = evt.newValue
5053     .replace(taco.isRa, " -")
5054     .replace(taco.isRb, " ")
5055     .replace(taco.isRc, ",$1 ")
5056     .replace(taco.isRd, ",$1 1")
5057     .replace(taco.isRe, "")
5058     .split(","),
5059         dli=dd.length,
5060         isZ = taco._isZ,
5061         isM = taco._isM,
5062         isC = taco._isC,
5063         isL = taco._isL,
5064         tcc = tar.createSVGPathSegCurvetoCubicAbs,
5065         tcll = tar.createSVGPathSegLinetoAbs;
5066     for (var i=0;i<dli;++i) {
5067       var di = dd[i].match(sgs),
5068           s;
5069       for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5070         if (isC[dii]) {
5071           s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5072           j += 5;
5073         } else if (isL[dii]) {
5074           s = tcll(+di[j], +di[j+1]);
5075           ++j;
5076         } else if (isM[dii]) {
5077           s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5078           ++j;
5079         } else if (isZ[dii]) {
5080           s = tar.createSVGPathSegClosePath();
5081         } else if (dii === "A") {
5082           s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5083           j += 6;
5084         } else if (dii === "m") {
5085           s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5086           ++j;
5087         } else if (dii === "l") {
5088           s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5089           ++j;
5090         } else if (dii === "c") {
5091           s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5092           j += 5;
5093         } else if (dii === "Q") {
5094           s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5095           j += 3;
5096         } else if (dii === "q") {
5097           s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5098           j += 3;
5099         } else if (dii === "a") {
5100           s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5101           j += 6;
5102         } else if (dii === "S") {
5103           s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5104           j += 3;
5105         } else if (dii === "s") {
5106           s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5107           j += 3;
5108         } else if (dii === "T") {
5109           s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5110           ++j;
5111         } else if (dii === "t") {
5112           s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5113           ++j;
5114         } else if (dii === "H") {
5115           s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5116         } else if (dii === "h") {
5117           s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5118         } else if (dii === "V") {
5119           s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5120         } else if (dii === "v") {
5121           s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5122         } else {
5123           s = new SVGPathSeg();
5124         }
5125         tlist.appendItem(s);
5126       }
5127     }
5128     di = s = sgs = dd = void 0;
5129     /*以下の処理は、pathSegListからnormalizedPathSegListへの
5130      *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5131      */
5132     var cx = 0, cy = 0,         //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5133         xn = 0, yn = 0,         //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5134         startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5135     for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5136       var ti = tlist.getItem(j),
5137           ts = ti.pathSegType,
5138           dii = ti.pathSegTypeAsLetter;
5139       if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5140       } else {
5141         var rx = cx, ry = cy;   //rx, ryは前のセグメントの終了点
5142         if (ts % 2 === 1) {     //相対座標ならば
5143           cx += ti.x;
5144           cy += ti.y;
5145         } else {
5146           cx = ti.x;
5147           cy = ti.y;
5148         }
5149         if (isC[dii]) {
5150           tnl.appendItem(ti);
5151         } else if (isL[dii]) {
5152           tnl.appendItem(ti);
5153         } else if (isM[dii]) {
5154           if (j !== 0) {
5155             /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5156              *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5157              *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5158              */
5159             var tg = tlist.getItem(j-1);
5160             if (tg.pathSegTypeAsLetter === "M") {
5161               tnl.appendItem(tcll(cx, cy));
5162               continue;
5163             }
5164           }
5165           startx = cx;
5166           starty = cy;
5167           tnl.appendItem(ti);
5168         } else if (dii === "m") {
5169           if (j !== 0) {
5170             var tg = tlist.getItem(j-1);
5171             if (tg.pathSegTypeAsLetter === "m") {
5172               tnl.appendItem(tcll(cx, cy));
5173               continue;
5174             }
5175           }
5176           startx = cx;
5177           starty = cy;
5178           tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5179         } else if (dii === "l") {
5180           tnl.appendItem(tcll(cx, cy));
5181         } else if (dii === "c") {
5182           tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5183         } else if (isZ[dii]) {
5184           cx = startx;
5185           cy = starty;
5186           tnl.appendItem(ti);
5187         } else if (dii === "Q") {
5188           xn = 2*cx - ti.x1;
5189           yn = 2*cy - ti.y1;
5190           //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5191           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));
5192         } else if (dii === "q") {
5193           var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5194           xn = 2*cx - x1;
5195           yn = 2*cy - y1;
5196           tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5197           x1 = y1 = void 0;
5198         } else if (dii === "A" || dii === "a") {
5199           (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5200             /*以下は、Arctoを複数のCuvetoに変換する処理
5201              *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5202              *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5203              */
5204             if (ti.r1 === 0 || ti.r2 === 0) {
5205               return;
5206             }
5207             var fS = ti.sweepFlag,
5208                 psai = ti.angle,
5209                 r1 = _math.abs(ti.r1),
5210                 r2 = _math.abs(ti.r2),
5211                 ctx = (rx - cx) / 2,  cty = (ry - cy) / 2,
5212                 cpsi = _math.cos(psai * _math.PI / 180),
5213                 spsi = _math.sin(psai * _math.PI / 180),
5214                 rxd = cpsi*ctx + spsi*cty,
5215                 ryd = -1*spsi*ctx + cpsi*cty,
5216                 rxdd = rxd * rxd, rydd = ryd * ryd,
5217                 r1x = r1 * r1,
5218                 r2y = r2 * r2,
5219                 lamda = rxdd/r1x + rydd/r2y,
5220                 sds;
5221             if (lamda > 1) {
5222               r1 = _math.sqrt(lamda) * r1;
5223               r2 = _math.sqrt(lamda) * r2;
5224               sds = 0;
5225             }  else{
5226               var seif = 1;
5227               if (ti.largeArcFlag === fS) {
5228                 seif = -1;
5229               }
5230               sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5231             }
5232             var txd = sds*r1*ryd / r2,
5233                 tyd = -1 * sds*r2*rxd / r1,
5234                 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5235                 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5236                 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5237                 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5238                 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5239                 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5240             if (!fS  &&  dr > 0) {
5241               dr -=   2*_math.PI;
5242             } else if (fS  &&  dr < 0) {
5243               dr += 2*_math.PI;
5244             }
5245             var sse = dr * 2 / _math.PI,
5246                 seg = _math.ceil(sse<0 ? -1*sse  :  sse),
5247                 segr = dr / seg,
5248                 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5249                 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5250                 spsir1 = spsi * r1, spsir2 = spsi * r2,
5251                 mc = _math.cos(s1),
5252                 ms = _math.sin(s1),
5253                 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5254                 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5255             for (var n = 0; n < seg; ++n) {
5256               s1 += segr;
5257               mc = _math.cos(s1);
5258               ms = _math.sin(s1);
5259               var x3 = cpsir1*mc - spsir2*ms + tx,
5260                   y3 = spsir1*mc + cpsir2*ms + ty,
5261                   dx = -t * (cpsir1*ms + spsir2*mc),
5262                   dy = -t * (spsir1*ms - cpsir2*mc);
5263               tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5264               x2 = x3 + dx;
5265               y2 = y3 + dy;
5266             }
5267             ti= cx= cy= rx= ry= tar= tnl = void 0;
5268           })(ti, cx, cy, rx, ry, tar, tnl);
5269         } else if (dii === "S") {
5270           if (j !== 0) {
5271             var tg = tnl.getItem(tnl.numberOfItems-1);
5272             if (tg.pathSegTypeAsLetter === "C") {
5273               var x1 = 2*tg.x - tg.x2,
5274                   y1 = 2*tg.y - tg.y2;
5275             } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5276               var x1 = rx,
5277                   y1 = ry;
5278             }
5279           } else {
5280             var x1 = rx,
5281                 y1 = ry;
5282           }
5283           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5284           x1 = y1 = void 0;
5285         } else if (dii === "s") {
5286           if (j !== 0) {
5287             var tg = tnl.getItem(tnl.numberOfItems-1);
5288             if (tg.pathSegTypeAsLetter === "C") {
5289               var x1 = 2*tg.x - tg.x2,
5290                   y1 = 2*tg.y - tg.y2;
5291             } else {
5292               var x1 = rx,
5293                   y1 = ry;
5294             }
5295           } else {
5296             var x1 = rx,
5297                 y1 = ry;
5298           }
5299           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5300           x1 = y1 = void 0;
5301         } else if (dii === "T" || dii === "t") {
5302           if (j !== 0) {
5303             var tg = tlist.getItem(j-1);
5304             if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5305              } else {
5306               xn = rx, yn = ry;
5307             }
5308           } else {
5309             xn = rx, yn = ry;
5310           }
5311           tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5312           xn = 2*cx - xn;
5313           yn = 2*cy - yn;
5314           xx1 = yy1 = void 0;
5315         } else if (dii === "H" || dii === "h") {
5316           tnl.appendItem(tcll(cx, ry));
5317           cy = ry; //勝手にti.yが0としているため
5318         } else if (dii === "V" || dii === "v") {
5319           tnl.appendItem(tcll(rx, cy));
5320           cx = rx;
5321         }
5322       }
5323     }
5324   }
5325   evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5326 };
5327 _sproto._nodeInsert = function(evt){
5328   var tar = evt.target;
5329   if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5330     return; //強制終了させる
5331   }
5332   var tnext = tar.nextSibling,
5333       tpart = tar.parentNode._tar,
5334       isLast = true;
5335   if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5336     tpart.insertBefore(tar._tar, tnext._tar);
5337   } else if (tnext && !tnext._tar && tpart) {
5338     /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5339      *use要素や実体参照などは_tarプロパティがないことに注意
5340      */
5341     while (tnext) {
5342       if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5343         tpart.insertBefore(tar._tar, tnext._tar);
5344         isLast = false;
5345       } 
5346       tnext = tnext.nextSibling;
5347     }
5348     if (isLast) {
5349       tpart.appendChild(tar._tar);
5350     }
5351   } else if (!tnext && tpart) {
5352     tpart.appendChild(tar._tar);      
5353   }
5354   tnext = tpart = isLast = void 0;
5355   tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5356   evt = tar = void 0;
5357 };
5358 _sproto._nodeInsertInto = function(evt){
5359   /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5360    *SVGのd属性をVMLに変換していく処理である。
5361    */
5362   var tar = evt.target,
5363       matrix = tar.getScreenCTM(),
5364       tlist = tar.normalizedPathSegList,
5365       dat = [],
5366       ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5367       cname = tar._com._nameCom,
5368       isZ = tar._com._isZ, isC = tar._com._isC,
5369       mr = _math.round;
5370   for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5371     var ti = tlist[i],
5372         tx = ti.x,
5373         ty = ti.y,
5374         tps = ti.pathSegTypeAsLetter,
5375         t = cname[tps];
5376     if (isC[tps]) {
5377       /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5378        *[ma mc me]   [x]
5379        *[mb md mf] * [y]
5380        *[0  0  1 ]   [1]
5381        */
5382       t += [mr(ma*ti.x1 + mc*ti.y1 + me),
5383              mr(mb*ti.x1 + md*ti.y1 + mf),
5384              mr(ma*ti.x2 + mc*ti.y2 + me),
5385              mr(mb*ti.x2 + md*ti.y2 + mf),
5386              mr(ma*tx + mc*ty + me),
5387              mr(mb*tx + md*ty + mf)].join(" ");
5388     } else if (!isZ[tps]) {
5389       t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
5390     }
5391     dat[i] = t;
5392   }
5393   var vi = tar.ownerDocument.documentElement,
5394       tt = tar._tar;
5395   dat.push(" e");
5396   tt.path = dat.join(" ");
5397   tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5398   NAIBU._setPaint(tar, matrix);
5399   delete tar._cacheMatrix;
5400   evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
5401 };
5402 _sproto._com = {
5403   _nameCom : {
5404     z : " x ",
5405     Z : " x ",
5406     C : "c",
5407     L : "l",
5408     M : "m"
5409   },
5410   _isZ : {
5411     z : 1,
5412     Z : 1
5413   },
5414   _isC : {
5415     C : 1
5416   },
5417   _isL : {
5418     L : 1
5419   },
5420   _isM : {
5421     M : 1
5422   },
5423   isRa : /\-/g,
5424   isRb : /,/g,
5425   isRc : /([a-yA-Y])/g,
5426   isRd : /([zZ])/g,
5427   isRe : /,/,
5428   isSp : /\S+/g
5429 };
5430   /*float*/         _sproto.getTotalLength = function() {
5431     var s = 0,
5432         nl = this.normalizedPathSegList;
5433     for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5434       var seg = nl.getItem(i);
5435       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5436         var ps = nl.getItem(i-1);
5437         s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5438       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5439         var ps = nl.getItem(i-1), dd = 0;
5440         /*2点のハンドルを結んだ線分の3辺と、
5441          *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5442          *
5443          *注意
5444          *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5445          *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5446          */
5447         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5448         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5449         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5450         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5451         s += dd / 2;
5452       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5453         var ps = nl.getItem(i-1), ms = nl.getItem(0);
5454         s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5455       }
5456
5457     }
5458     this.pathLength.baseVal = s;
5459     return s;
5460   };
5461   /*SVGPoint*/      _sproto.getPointAtLength = function(/*float*/ distance ) {
5462     var segn = this.getPathSegAtLength(distance),
5463         x = 0,
5464         y = 0,
5465         nl = this.normalizedPathSegList,
5466         seg = nl.getItem(segn),
5467         s = this.ownerDocument.documentElement.createSVGPoint();
5468     if ((segn-1) <= 0) {
5469       s.x = seg.x;
5470       s.y = seg.y;
5471       return s;
5472     }
5473     var ps = nl.getItem(segn-1);
5474     if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5475       var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5476       var t = (segl + this._dis) / segl;
5477       s.x = ps.x + t * (seg.x-ps.x);
5478       s.y = ps.y + t * (seg.y-ps.y);
5479     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5480       var dd = 0;
5481       dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5482       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5483       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5484       dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5485       var segl = dd / 2;
5486       var t = (segl + this._dis) / segl;
5487       /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5488        *使って、ポイントの座標を演算する
5489        */
5490       s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5491            +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5492            +3*(seg.x1 - ps.x) * t
5493            +ps.x;
5494       s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5495            +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5496            +3*(seg.y1 - ps.y) * t
5497            +ps.y;
5498     } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5499       s.x = seg.x;
5500       s.y = seg.y;
5501     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5502       var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5503       var t = (segl + this._dis) / segl;
5504       s.x = ms.x + t * (seg.x-ms.x);
5505       s.y = ms.y + t * (seg.y-ms.y);
5506     }
5507     return s;
5508   };
5509   /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5510     var nl = this.normalizedPathSegList; //仕様ではpathSegList
5511     for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5512       var seg = nl.getItem(i);
5513       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5514         var ps = nl.getItem(i-1);
5515         distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5516       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5517         var ps = nl.getItem(i-1), dd = 0;
5518         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5519         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5520         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5521         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5522         distance -= dd / 2;
5523         dd = void 0;
5524       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5525         var ps = nl.getItem(i-1), ms = nl.getItem(0);
5526         distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5527       }
5528       if (distance <= 0) {
5529         /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5530         this._dis = distance;
5531         distance = void 0;
5532         return i;
5533       }
5534     }
5535     /*もし、distanceがパスの距離よりも長い場合、
5536      *最後のセグメントの番号を返す
5537      *なお、これはSVG1.1の仕様の想定外のこと
5538      */
5539     return (nl.numberOfItems - 1);
5540   };
5541   /*SVGPathSegClosePath*/    _sproto.createSVGPathSegClosePath = function() {
5542     var _SVGPathSegClosePath = SVGPathSegClosePath;
5543     return (new _SVGPathSegClosePath());
5544   };
5545   /*SVGPathSegMovetoAbs*/    _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5546     var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5547     s.x = x;
5548     s.y = y;
5549     return s;
5550   };
5551   /*SVGPathSegMovetoRel*/    _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5552     var s = new SVGPathSegMovetoRel();
5553     s.x = x;
5554     s.y = y;
5555     return s;
5556   };
5557   /*SVGPathSegLinetoAbs*/    _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5558     var s = new SVGPathSegLinetoAbs();
5559     s.x = x;
5560     s.y = y;
5561     return s;
5562   };
5563   /*SVGPathSegLinetoRel*/    _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5564     var s = new SVGPathSegLinetoRel();
5565     s.x = x;
5566     s.y = y;
5567     return s;
5568   };
5569   /*SVGPathSegCurvetoCubicAbs*/    _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5570     var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5571     s.x = x;
5572     s.y = y;
5573     s.x1 = x1;
5574     s.y1 = y1;
5575     s.x2 = x2;
5576     s.y2 = y2;
5577     return s;
5578   };
5579   /*SVGPathSegCurvetoCubicRel*/    _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5580     var s = new SVGPathSegCurvetoCubicRel();
5581     s.x = x;
5582     s.y = y;
5583     s.x1 = x1;
5584     s.y1 = y1;
5585     s.x2 = x2;
5586     s.y2 = y2;
5587     return s;
5588   };
5589   /*SVGPathSegCurvetoQuadraticAbs*/    _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5590     var s = new SVGPathSegCurvetoQuadraticAbs();
5591     s.x = x;
5592     s.y = y;
5593     s.x1 = x1;
5594     s.y1 = y1;
5595     return s;
5596   };
5597   /*SVGPathSegCurvetoQuadraticRel*/    _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5598     var s = new SVGPathSegCurvetoQuadraticRel();
5599     s.x = x;
5600     s.y = y;
5601     s.x1 = x1;
5602     s.y1 = y1;
5603     return s;
5604   };
5605   /*SVGPathSegArcAbs*/    _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5606     var s = new SVGPathSegArcAbs();
5607     s.x = x;
5608     s.y = y;
5609     s.r1 = r1;
5610     s.r2 = r2;
5611     s.angle = angle;
5612     s.largeArcFlag = largeArcFlag;
5613     s.sweepFlag = sweepFlag;
5614     return s;
5615   };
5616   /*SVGPathSegArcRel*/    _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5617     var s = new SVGPathSegArcRel();
5618     s.x = x;
5619     s.y = y;
5620     s.r1 = r1;
5621     s.r2 = r2;
5622     s.angle = angle;
5623     s.largeArcFlag = largeArcFlag;
5624     s.sweepFlag = sweepFlag;
5625     return s;
5626   };
5627   /*SVGPathSegLinetoHorizontalAbs*/    _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5628     var s = new SVGPathSegLinetoHorizontalAbs();
5629     s.x = x;
5630     s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5631     return s;
5632   };
5633   /*SVGPathSegLinetoHorizontalRel*/    _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5634     var s = new SVGPathSegLinetoHorizontalRel();
5635     s.x = x;
5636     s.y = 0;
5637     return s;
5638   };
5639   /*SVGPathSegLinetoVerticalAbs*/    _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5640     var s = new SVGPathSegLinetoVerticalAbs();
5641     s.x = 0;
5642     s.y = y;
5643     return s;
5644   };
5645   /*SVGPathSegLinetoVerticalRel*/    _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5646     var s = new SVGPathSegLinetoVerticalRel();
5647     s.x = 0;
5648     s.y = y;
5649     return s;
5650   };
5651   /*SVGPathSegCurvetoCubicSmoothAbs*/    _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5652     var s = new SVGPathSegCurvetoCubicSmoothAbs();
5653     s.x = x;
5654     s.y = y;
5655     s.x2 = x2;
5656     s.y2 = y2;
5657     return s;
5658   };
5659   /*SVGPathSegCurvetoCubicSmoothRel*/    _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5660     var s = new SVGPathSegCurvetoCubicSmoothRel();
5661     s.x = x;
5662     s.y = y;
5663     s.x2 = x2;
5664     s.y2 = y2;
5665     return s;
5666   };
5667   /*SVGPathSegCurvetoQuadraticSmoothAbs*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5668     var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5669     s.x = x;
5670     s.y = y;
5671     return s;
5672   };
5673   /*SVGPathSegCurvetoQuadraticSmoothRel*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5674     var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5675     s.x = x;
5676     s.y = y;
5677     return s;
5678   };
5679 })(SVGPathElement.prototype)
5680   NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5681 })(document, Math);
5682
5683 function SVGRectElement(_doc) {
5684   SVGElement.apply(this);
5685   this._tar = _doc.createElement("v:shape");
5686   var slen = SVGAnimatedLength;
5687   /*readonly SVGAnimatedLength*/ this.x = new slen();
5688   /*readonly SVGAnimatedLength*/ this.y = new slen();
5689   /*readonly SVGAnimatedLength*/ this.width = new slen();
5690   /*readonly SVGAnimatedLength*/ this.height = new slen();
5691   /*readonly SVGAnimatedLength*/ this.rx = new slen();
5692   /*readonly SVGAnimatedLength*/ this.ry = new slen();
5693   _doc = slen = void 0;
5694   this.addEventListener("DOMNodeInserted", function(evt){
5695     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5696       return; //強制終了させる
5697     }
5698     var tar = evt.target,
5699         tnext = tar.nextSibling,
5700         tpart = tar.parentNode._tar,
5701         isLast = true;
5702     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5703       tpart.insertBefore(tar._tar, tnext._tar);
5704     } else if (tnext && !tnext._tar && tpart) {
5705       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5706        *use要素や実体参照などは_tarプロパティがないことに注意
5707        */
5708       while (tnext) {
5709         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5710           tpart.insertBefore(tar._tar, tnext._tar);
5711           isLast = false;
5712         } 
5713         tnext = tnext.nextSibling;
5714       }
5715       if (isLast) {
5716         tpart.appendChild(tar._tar);
5717       }
5718     } else if (!tnext && tpart) {
5719       tpart.appendChild(tar._tar);      
5720     }
5721     tnext = tpart = isLast = void 0;
5722     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5723       var tar = evt.target,
5724           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5725           fontSize = parseFloat(style.getPropertyValue("font-size"));
5726       tar.x.baseVal._emToUnit(fontSize);
5727       tar.y.baseVal._emToUnit(fontSize);
5728       tar.width.baseVal._emToUnit(fontSize);
5729       tar.height.baseVal._emToUnit(fontSize);
5730       var rx = tar.getAttributeNS(null, "rx"),
5731           ry = tar.getAttributeNS(null, "ry"),
5732           x = tar.x.baseVal.value,
5733           y = tar.y.baseVal.value,
5734           xw = x + tar.width.baseVal.value,
5735           yh = y + tar.height.baseVal.value,
5736           list;
5737       if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5738         tar.rx.baseVal._emToUnit(fontSize);
5739         tar.ry.baseVal._emToUnit(fontSize);
5740         var thrx = tar.rx.baseVal,
5741             thry = tar.ry.baseVal,
5742             twidth = tar.width.baseVal.value,
5743             theight = tar.height.baseVal.value;
5744         thrx.value = rx ? thrx.value : thry.value;
5745         thry.value = ry ? thry.value : thrx.value;
5746         //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5747         if (thrx.value > twidth / 2) {
5748           thrx.value = twidth / 2;
5749         }
5750         if (thry.value > theight / 2) {
5751           thry.value = theight / 2;
5752         }
5753         var rxv = thrx.value,
5754             ryv = thry.value,
5755             rrx = rxv * 0.55228,
5756             rry = ryv * 0.55228,
5757             a = xw - rxv,
5758             b = x + rxv,
5759             c = y + ryv,
5760             d = yh - ryv;
5761         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];
5762       } else {
5763         list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5764       }
5765       //以下は、配列listそのものをCTMで座標変換していく処理
5766       var par = tar.ownerDocument.documentElement,
5767           ctm = tar.getScreenCTM(),
5768           dat, p, pmt,
5769           ele = tar._tar,
5770           vi = tar.ownerDocument.documentElement,
5771           w = vi.width.baseVal.value,
5772           h = vi.height.baseVal.value,
5773           mr = Math.round;
5774       for (var i=0, lili=list.length;i<lili;) {
5775         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5776           ++i;
5777           continue;
5778         }
5779         p = par.createSVGPoint();
5780         p.x = list[i];
5781         p.y = list[i+1];
5782         pmt = p.matrixTransform(ctm);
5783         list[i] = mr(pmt.x);
5784         ++i;
5785         list[i] = mr(pmt.y);
5786         ++i;
5787         p = pmt = void 0;
5788       }
5789       dat = list.join(" ");
5790       //VMLに結び付けていく
5791       ele.path = dat;
5792       ele.coordsize = w + " " + h;
5793       NAIBU._setPaint(tar, ctm);
5794       delete tar._cacheMatrix;
5795       evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
5796     }, false);
5797     evt = tar = void 0;
5798   }, false);
5799   return this;
5800 };
5801 SVGRectElement.prototype = new SVGElement();
5802
5803 function SVGCircleElement(_doc) { 
5804   SVGElement.apply(this);
5805   this._tar = _doc.createElement("v:shape");
5806   var sl = SVGAnimatedLength;
5807   /*readonly SVGAnimatedLength*/ this.cx = new sl();
5808   /*readonly SVGAnimatedLength*/ this.cy = new sl();
5809   /*readonly SVGAnimatedLength*/ this.r = new sl();
5810   _doc = sl = void 0;
5811   this.addEventListener("DOMNodeInserted", function(evt){
5812     var tar = evt.target;
5813     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5814       return; //強制終了させる
5815     }
5816     var tnext = tar.nextSibling,
5817         tpart = tar.parentNode._tar,
5818         isLast = true;
5819     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5820       tpart.insertBefore(tar._tar, tnext._tar);
5821     } else if (tnext && !tnext._tar && tpart) {
5822       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5823        *use要素や実体参照などは_tarプロパティがないことに注意
5824        */
5825       while (tnext) {
5826         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5827           tpart.insertBefore(tar._tar, tnext._tar);
5828           isLast = false;
5829         } 
5830         tnext = tnext.nextSibling;
5831       }
5832       if (isLast) {
5833         tpart.appendChild(tar._tar);
5834       }
5835     } else if (!tnext && tpart) {
5836       tpart.appendChild(tar._tar);      
5837     }
5838     tnext = tpart = isLast = void 0;
5839     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5840       var tar = evt.target,
5841           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5842           fontSize = parseFloat(style.getPropertyValue("font-size"));
5843       tar.cx.baseVal._emToUnit(fontSize);
5844       tar.cy.baseVal._emToUnit(fontSize);
5845       tar.r.baseVal._emToUnit(fontSize);
5846       var cx = tar.cx.baseVal.value,
5847           cy = tar.cy.baseVal.value,
5848           rx = ry = tar.r.baseVal.value,
5849           top = cy - ry,
5850           left = cx - rx,
5851           bottom = cy + ry,
5852           right = cx + rx,
5853           rrx = rx * 0.55228,
5854           rry = ry * 0.55228,
5855           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"];
5856         //以下は、配列listそのものをCTMで座標変換していく処理
5857         var par = tar.ownerDocument.documentElement,
5858             ctm = tar.getScreenCTM(),
5859             mr = Math.round;
5860         for (var i=0, lili=list.length;i<lili;) {
5861           if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5862             ++i;
5863             continue;
5864           }
5865           var p = par.createSVGPoint();
5866           p.x = list[i];
5867           p.y = list[i+1];
5868           var pmt = p.matrixTransform(ctm);
5869           list[i] = mr(pmt.x);
5870           ++i;
5871           list[i] = mr(pmt.y);
5872           ++i;
5873           p = pmt = void 0;
5874         }
5875         var dat = list.join(" "),
5876             ele = tar._tar,
5877             vi = tar.ownerDocument.documentElement,
5878             w = vi.width.baseVal.value,
5879             h = vi.height.baseVal.value;
5880         //VMLに結び付けていく
5881         ele.path = dat;
5882         ele.coordsize = w + " " + h;
5883         NAIBU._setPaint(tar, ctm);
5884         delete tar._cacheMatrix;
5885         evt = tar = list = mr = style = fontSize = dat = ele = void 0;
5886     }, false);
5887     evt = tar = void 0;
5888   }, false);
5889   return this;
5890 };
5891 SVGCircleElement.prototype = new SVGElement();
5892
5893 function SVGEllipseElement(_doc) { 
5894   SVGElement.apply(this);
5895   this._tar = _doc.createElement("v:shape");
5896   var sl = SVGAnimatedLength;
5897   /*readonly SVGAnimatedLength*/ this.cx = new sl();
5898   /*readonly SVGAnimatedLength*/ this.cy = new sl();
5899   /*readonly SVGAnimatedLength*/ this.rx = new sl();
5900   /*readonly SVGAnimatedLength*/ this.ry = new sl();
5901   _doc = sl = void 0;
5902   this.addEventListener("DOMNodeInserted", function(evt){
5903     var tar = evt.target;
5904     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5905       return; //強制終了させる
5906     }
5907     var tnext = tar.nextSibling,
5908     tpart = tar.parentNode._tar,
5909     isLast = true;
5910     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5911       tpart.insertBefore(tar._tar, tnext._tar);
5912     } else if (tnext && !tnext._tar && tpart) {
5913       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5914        *use要素や実体参照などは_tarプロパティがないことに注意
5915        */
5916       while (tnext) {
5917         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5918           tpart.insertBefore(tar._tar, tnext._tar);
5919           isLast = false;
5920         } 
5921         tnext = tnext.nextSibling;
5922       }
5923       if (isLast) {
5924         tpart.appendChild(tar._tar);
5925       }
5926     } else if (!tnext && tpart) {
5927       tpart.appendChild(tar._tar);      
5928     }
5929     tnext = tpart = isLast = void 0;
5930     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5931       var tar = evt.target,
5932           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5933           fontSize = parseFloat(style.getPropertyValue("font-size"));
5934       tar.cx.baseVal._emToUnit(fontSize);
5935       tar.cy.baseVal._emToUnit(fontSize);
5936       tar.rx.baseVal._emToUnit(fontSize);
5937       tar.ry.baseVal._emToUnit(fontSize);
5938       var cx = tar.cx.baseVal.value,
5939           cy = tar.cy.baseVal.value,
5940           rx = tar.rx.baseVal.value,
5941           ry = tar.ry.baseVal.value,
5942           top = cy - ry,
5943           left = cx - rx,
5944           bottom = cy + ry,
5945           right = cx + rx,
5946           rrx = rx * 0.55228,
5947           rry = ry * 0.55228,
5948           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"];
5949       //以下は、配列listそのものをCTMで座標変換していく処理
5950       var par = tar.ownerDocument.documentElement,
5951           ctm = tar.getScreenCTM(),
5952           mr = Math.round;
5953       for (var i=0, lili=list.length;i<lili;) {
5954         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5955           ++i;
5956           continue;
5957         }
5958         var p = par.createSVGPoint();
5959         p.x = list[i];
5960         p.y = list[i+1];
5961         var pmt = p.matrixTransform(ctm);
5962         list[i] = mr(pmt.x);
5963         ++i;
5964         list[i] = mr(pmt.y);
5965         ++i;
5966         p = pmt = void 0;
5967       }
5968       var dat = list.join(" "),
5969           ele = tar._tar, 
5970           vi = tar.ownerDocument.documentElement,
5971           w = vi.width.baseVal.value,
5972           h = vi.height.baseVal.value;
5973       //VMLに結び付けていく
5974       ele.path = dat;
5975       ele.coordsize = w + " " + h;
5976       NAIBU._setPaint(tar, ctm);
5977       delete tar._cacheMatrix;
5978       evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
5979     }, false);
5980     evt = tar = void 0;
5981   }, false);
5982   return this;
5983 };
5984 SVGEllipseElement.prototype = new SVGElement();
5985
5986 function SVGLineElement(_doc) { 
5987   SVGElement.apply(this);
5988   this._tar = _doc.createElement("v:shape");
5989   var sl = SVGAnimatedLength;
5990   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5991   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5992   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5993   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5994   _doc = sl = void 0;
5995   this.addEventListener("DOMNodeInserted", function(evt){
5996     var tar = evt.target;
5997     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5998       return; //強制終了させる
5999     }
6000     var tnext = tar.nextSibling,
6001         tpart = tar.parentNode._tar,
6002         isLast = true;
6003     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6004       tpart.insertBefore(tar._tar, tnext._tar);
6005     } else if (tnext && !tnext._tar && tpart) {
6006       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6007        *use要素や実体参照などは_tarプロパティがないことに注意
6008        */
6009       while (tnext) {
6010         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6011           tpart.insertBefore(tar._tar, tnext._tar);
6012           isLast = false;
6013         } 
6014         tnext = tnext.nextSibling;
6015       }
6016       if (isLast) {
6017         tpart.appendChild(tar._tar);
6018       }
6019     } else if (!tnext && tpart) {
6020       tpart.appendChild(tar._tar);      
6021     }
6022     tnext = tpart = isLast = void 0;
6023     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6024       var tar = evt.target,
6025           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
6026           fontSize = parseFloat(style.getPropertyValue("font-size"));
6027       tar.x1.baseVal._emToUnit(fontSize);
6028       tar.y1.baseVal._emToUnit(fontSize);
6029       tar.x2.baseVal._emToUnit(fontSize);
6030       tar.y2.baseVal._emToUnit(fontSize);
6031       //以下は、配列listそのものをCTMで座標変換していく処理
6032       var vi = tar.ownerDocument.documentElement,
6033           ctm = tar.getScreenCTM(),
6034           dat = "m ",
6035           mr = Math.round,
6036           p = vi.createSVGPoint();
6037       p.x = tar.x1.baseVal.value;
6038       p.y = tar.y1.baseVal.value;
6039       var pmt = p.matrixTransform(ctm);
6040       dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
6041       p.x = tar.x2.baseVal.value;
6042       p.y = tar.y2.baseVal.value;
6043       pmt = p.matrixTransform(ctm);
6044       dat += mr(pmt.x)+ " " +mr(pmt.y);
6045       p = pmt = void 0;
6046       //VMLに結び付けていく
6047       var ele = tar._tar,
6048           w = vi.width.baseVal.value,
6049           h = vi.height.baseVal.value;
6050       ele.path = dat;
6051       ele.coordsize = w + " " + h;
6052       NAIBU._setPaint(tar, ctm);
6053       delete tar._cacheMatrix;
6054       evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
6055     }, false);
6056     evt = tar = void 0;
6057   }, false);
6058   return this;
6059 };
6060 SVGLineElement.prototype = new SVGElement();
6061
6062 /*_GenericSVGPolyElementインターフェース
6063  * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6064  * ファイルサイズを軽量にすることができる
6065  */
6066 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6067   SVGElement.apply(this);
6068   this._tar = _doc.createElement("v:shape");
6069   _doc = void 0;
6070   //interface SVGAnimatedPoints
6071   /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
6072   this.addEventListener("DOMAttrModified", function(evt){
6073     var tar = evt.target;
6074     if (evt.attrName === "points") {
6075       var tp = tar.points, par = tar.ownerDocument.documentElement;
6076       var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6077       for (var i=0, p, lili=list.length;i<lili;i+=2) {
6078         if (isNaN(list[i])) {
6079           --i;
6080           continue;
6081         }
6082         p = par.createSVGPoint();
6083         p.x = parseFloat(list[i]);
6084         p.y = parseFloat(list[i+1]);
6085         tp.appendItem(p);
6086       }
6087     }
6088     evt = tar = list = tp = par = p = void 0;
6089   }, false);
6090   this.addEventListener("DOMNodeInserted", function(evt){
6091     var tar = evt.target;
6092     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6093       return; //強制終了させる
6094     }
6095     var tnext = tar.nextSibling,
6096         tpart = tar.parentNode._tar,
6097         isLast = true;
6098     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6099       tpart.insertBefore(tar._tar, tnext._tar);
6100     } else if (tnext && !tnext._tar && tpart) {
6101       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6102        *use要素や実体参照などは_tarプロパティがないことに注意
6103        */
6104       while (tnext) {
6105         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6106           tpart.insertBefore(tar._tar, tnext._tar);
6107           isLast = false;
6108         } 
6109         tnext = tnext.nextSibling;
6110       }
6111       if (isLast) {
6112         tpart.appendChild(tar._tar);
6113       }
6114     } else if (!tnext && tpart) {
6115       tpart.appendChild(tar._tar);      
6116     }
6117     tnext = tpart = isLast = void 0;
6118     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6119       var tar = evt.target,
6120           tp = tar.points,
6121           ctm = tar.getScreenCTM(),
6122           mr = Math.round;
6123       //以下は、配列listそのものをCTMで座標変換していく処理
6124       for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6125         var p = tp.getItem(i),
6126             pmt = p.matrixTransform(ctm);
6127         list[2*i] = mr(pmt.x);
6128         list[2*i + 1] = mr(pmt.y);
6129         p = pmt = void 0;
6130       }
6131       list.splice(2, 0, "l");
6132       var dat = "m" + list.join(" ") + xclose,
6133           ele = tar._tar,
6134           vi = tar.ownerDocument.documentElement;
6135           w = vi.width.baseVal.value,
6136           h = vi.height.baseVal.value;
6137       //VMLに結び付けていく
6138       ele.path = dat;
6139       ele.coordsize = w + " " + h;
6140       NAIBU._setPaint(tar, ctm);
6141       delete tar._cacheMatrix;
6142       evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
6143     }, false);
6144     evt = tar = void 0;
6145   }, false);
6146   return this;
6147 }
6148 function SVGPolylineElement(_doc) {
6149   NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6150   _doc = void 0;
6151   return this;
6152 };
6153 SVGPolylineElement.prototype = new SVGElement();
6154
6155 function SVGPolygonElement(_doc) {
6156   NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6157   _doc = void 0;
6158   return this;
6159 };
6160 SVGPolygonElement.prototype = new SVGElement();
6161
6162 function SVGTextContentElement(_doc) { 
6163   SVGElement.apply(this);
6164   /*readonly SVGAnimatedLength*/      this.textLength = new SVGAnimatedLength();
6165   /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6166   this.addEventListener("DOMNodeInserted", function(evt){
6167     var tar = evt.target,
6168         cur = evt.currentTarget,
6169         eph = evt.eventPhase;
6170     /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6171      *あらかじめ、Capturingフェーズで処理しておく
6172      */
6173     if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6174       /*a要素の場合はtarをすりかえておく*/
6175       tar = tar.firstChild;
6176     }
6177     if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
6178       /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6179       tar._tars = [];
6180       var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6181       tar.data = data;
6182       tar.length = data.length
6183       data = data.split('');
6184       for (var i=0, tdli=data.length;i<tdli;++i) {
6185         var d = _doc.createElement("div"),
6186             dstyle = d.style;
6187         dstyle.position = "absolute";
6188         dstyle.textIndent = dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = dstyle.paddingTop = dstyle.paddingLeft = "0px";
6189         dstyle.whiteSpace = "nowrap";
6190         d.appendChild(_doc.createTextNode(data[i]));
6191         tar._tars[tar._tars.length] = d;
6192       }
6193       data = void 0;
6194     }
6195     evt = tar = cur = eph = void 0;
6196   }, true);
6197   this.addEventListener("DOMNodeRemoved", function(evt){
6198     var tar = evt.target;
6199     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6200       delete evt.currentTarget._length;
6201       tar = evt = void 0;
6202     }
6203   }, false);
6204  return this;
6205 };
6206
6207 (function(t) {
6208 t.prototype = new SVGElement();
6209     // lengthAdjust Types
6210   /*unsigned short*/ t.LENGTHADJUST_UNKNOWN           = 0;
6211   /*unsigned short*/ t.LENGTHADJUST_SPACING           = 1;
6212   /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS  = 2;
6213   t.prototype._list = null;         //文字の位置を格納しておくリストのキャッシュ
6214   t.prototype._length = null;       //全文字数のキャッシュ
6215   t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6216   t.prototype._chars = 0;           //tspan (tref)要素が全体の何文字目から始まっているか
6217   t.prototype._isYokogaki = true;   //横書きかどうか
6218 /*long*/     t.prototype.getNumberOfChars = function() {
6219   if (this._length) {
6220     return (this._length);
6221   } else {
6222     var s = 0,
6223         f = function (ts) {
6224               while (ts) {
6225                 if (ts.length && (ts.nodeType === /*Node.TEXT_NODE*/ 3)) {
6226                   s += ts.length;
6227                 } else if (ts.getNumberOfChars) { //tspan要素などであれば
6228                   s += ts.getNumberOfChars();
6229                 } else if (ts.firstChild && (ts.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
6230                   f(ts.firstChild);                          //再帰的に呼び出す
6231                 }
6232                 ts = ts.nextSibling;
6233               }
6234               ts = void 0;
6235             };
6236     f(this.firstChild);
6237     this._length = s;
6238     return s;
6239   }
6240 };
6241 /*float*/    t.prototype.getComputedTextLength = function() {
6242   var l = this.textLength.baseVal;
6243   if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6244     /*何も設定されていない場合のみ、初期化を行う*/
6245     l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6246   }
6247   l = void 0;
6248   return (this.textLength.baseVal.value);
6249 };
6250 /*getSubStringLengthメソッド
6251  *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6252  */
6253 /*float*/    t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6254   if (nchars === 0) {
6255     return 0;
6256   }
6257   var tg = this.getNumberOfChars();
6258   if (tg < (nchars+charnum)) {
6259     /*ncharsが文字列の長さよりも長くなってしまったときには、
6260      *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6261      */
6262     nchars = tg - charnum + 1;
6263   }
6264   var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6265   if (this._isYokogaki) {
6266     var s = end.x - st.x;
6267   } else {
6268     var s = end.y - st.y;
6269   }
6270   tg = end = st = void 0;
6271   return s;
6272 }
6273 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6274   if (charnum > this.getNumberOfChars() || charnum < 0) {
6275     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6276   } else {
6277     var tar = this,
6278         ti = tar.firstChild,
6279         tp = tar.parentNode;
6280     if (!!!tar._list) {
6281       tar._list = [];
6282       var chars = tar._chars, //現在、何文字目にあるのか
6283           x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6284           style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6285           isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6286           fontSize = parseFloat(style.getPropertyValue("font-size")),
6287           tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6288       /*親要素の属性も参照しておく*/
6289       if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6290         var ptx = tp.x.baseVal,
6291             pty = tp.y.baseVal,
6292             ptdx = tp.dx.baseVal,
6293             ptdy = tp.dy.baseVal;
6294       } else {
6295         var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6296       }
6297       var kern = "f ijltIr.,:;'-\"()",
6298           akern = "1234567890abcdeghknopquvxyz",
6299           tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6300       if (isYokogaki && (tar.localName === "text")) {
6301         y += fontSize * 0.2;
6302       } else if (tar.localName === "text"){
6303         x -= fontSize * 0.5;
6304       }
6305       while (ti) {
6306         if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6307           tt = ti._tars;
6308           /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6309            *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6310            *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6311            *この処理はdx属性やdy、y属性でも同様とする
6312            *参照資料SVG1.1 Text
6313            *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6314            *
6315            *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6316            */
6317           for (var i=0, tli=tt.length;i<tli;++i) {
6318             if (n < ptx.numberOfItems - chars) {
6319               x = ptx.getItem(n).value;
6320               if (!isYokogaki) {
6321                 x -= fontSize * 0.5;
6322               }
6323             } else if (n < tx.numberOfItems) {
6324               x = tx.getItem(n).value;
6325               if (!isYokogaki) {
6326                 x -= fontSize * 0.5;
6327               }
6328             }
6329             if (n < pty.numberOfItems - chars) {
6330               y = pty.getItem(n).value;
6331               if (isYokogaki) {
6332                 y += fontSize * 0.2;
6333               }
6334             } else if (n < ty.numberOfItems) {
6335               y = ty.getItem(n).value;
6336               if (isYokogaki) {
6337                 y += fontSize * 0.2;
6338               }
6339             }
6340             if (n < ptdx.numberOfItems - chars) {
6341               x += ptdx.getItem(n).value;
6342             } else if (n < tdx.numberOfItems) {
6343               x += tdx.getItem(n).value;
6344             }
6345             if (n < ptdy.numberOfItems - chars) {
6346               y += ptdy.getItem(n).value;
6347             } else if (n < tdy.numberOfItems) {
6348               y += tdy.getItem(n).value;
6349             }
6350             alm = 0;
6351             if (isYokogaki) {
6352               //カーニングを求めて、字の幅を文字ごとに調整する
6353               tdc = ti.data.charAt(i);
6354               if (kern.indexOf(tdc) > -1) {
6355                 alm = fontSize * 0.68;
6356               } else if (tdc === "s"){
6357                 alm = fontSize * 0.52;
6358               } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6359                 alm = fontSize * 0.2;
6360               } else if (akern.indexOf(tdc) > -1){
6361                 alm = fontSize * 0.45;
6362               } else {
6363                 alm = fontSize * 0.3;
6364               }
6365               tcca = tdc.charCodeAt(0);
6366               if ((12288 <= tcca) && (tcca <= 65533)) {
6367                 alm = -fontSize * 0.01;
6368                 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6369                   alm += fontSize * 0.2;
6370                 }
6371               }
6372             }
6373             tlist = tar._list;
6374             tlist[tlist.length] = x;
6375             tlist[tlist.length] = y;
6376             tlist[tlist.length] = fontSize - alm;
6377             if (isYokogaki) {
6378               x += fontSize;
6379               x -= alm;
6380             } else {
6381               y += fontSize;
6382             }
6383             ++n;
6384           }
6385           chars += tli;
6386           if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6387             ti = ti.parentNode;
6388           }
6389           ti = ti.nextSibling;
6390         } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
6391             && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6392           /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
6393            *さらに、現在のテキスト位置を更新する
6394            */
6395           ti._stx = x;
6396           ti._sty = y;
6397           ti._chars = chars;
6398           p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6399           almx = 0;
6400           almy = 0;
6401           tlist = ti._list;
6402           if (isYokogaki) {
6403             almx = tlist[tlist.length-1];
6404           } else {
6405             almy = tlist[tlist.length-1];
6406           }
6407           x = tlist[tlist.length-3] + almx;
6408           y = tlist[tlist.length-2] + almy;
6409           tar._list = tar._list.concat(tlist);
6410           tg = ti.getNumberOfChars();
6411           n += tg;
6412           chars += tg;
6413           ti = ti.nextSibling;
6414         } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6415           /*a要素のテキストノードも処理する*/
6416           ti = ti.firstChild;
6417         } else {
6418           ti = ti.nextSibling;
6419         }
6420       }
6421       tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6422     }
6423     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;
6424     var s = this.ownerDocument.documentElement.createSVGPoint();
6425     s.x = this._list[charnum*3];
6426     s.y = this._list[charnum*3 + 1];
6427     s = s.matrixTransform(this.getScreenCTM());
6428     return s;
6429   }
6430 };
6431 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6432   if (charnum > this.getNumberOfChars() || charnum < 0) {
6433     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6434   } else {
6435     var s = this.getStartPositionOfChar(charnum);
6436     //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6437     var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6438     if (this._isYokogaki) {
6439       s.x += n;
6440     } else {
6441       s.y += n;
6442     }
6443     return s;
6444   }
6445 };
6446 /*SVGRect*/  t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6447   
6448 };
6449 /*float*/    t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6450   
6451 };
6452 /*long*/     t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6453   
6454 };
6455 /*void*/     t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6456   
6457 };
6458 })(SVGTextContentElement);
6459
6460 function SVGTextPositioningElement(_doc) { 
6461   SVGTextContentElement.apply(this, arguments);
6462   var sl = SVGAnimatedLengthList;
6463   /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6464   /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6465   /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6466   /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6467   sl = void 0;
6468   /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6469   this.addEventListener("DOMAttrModified", function(evt){
6470     var tar = evt.target,
6471         name = evt.attrName,
6472         tod = tar.ownerDocument.documentElement,
6473         _parseFloat = parseFloat;
6474     if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6475       var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
6476           teas = tar[name].baseVal;
6477       for (var i=0, tli=enr.length;i<tli;++i) {
6478         var tea = tod.createSVGLength(),
6479             n = enr[i].slice(-1),
6480             type = 0;
6481         if (n >= "0" && n <= "9") {
6482           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6483         } else if (n === "%") {
6484           if ((name === "x") || (name === "dx")) {
6485             tea._percent *= tod.viewport.width;
6486           } else if ((name === "y") || (name === "dy")) {
6487             tea._percent *= tod.viewport.height;
6488           }
6489           type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6490         } else {
6491           n = enr[i].slice(-2);
6492           if (n === "em") {
6493             var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6494             tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6495             style = void 0;
6496             type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6497           } else if (n === "ex") {
6498             type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6499           } else if (n === "px") {
6500             type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6501           } else if (n === "cm") {
6502             type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6503           } else if (n === "mm") {
6504             type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6505           } else if (n === "in") {
6506             type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6507           } else if (n === "pt") {
6508             type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6509           } else if (n === "pc") {
6510             type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6511           }
6512         }
6513         var s = _parseFloat(enr[i]);
6514         s = isNaN(s) ? 0 : s;
6515         tea.newValueSpecifiedUnits(type, s);
6516         teas.appendItem(tea);
6517       }
6518       tar._list = null;
6519     }
6520     evt = tar = void 0;
6521   }, false);
6522   this.addEventListener("DOMNodeInserted", function(evt){
6523     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6524       var tar = evt.target;
6525       if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6526         tar._list = void 0;
6527         evt.currentTarget._list = null;
6528       }
6529       evt = tar = void 0;
6530     }
6531   }, false);
6532   if (_doc) {
6533     this._tar = _doc.createElement("v:group");
6534     this._doc = _doc; //_docプロパティは_texto関数内で使われる
6535   }
6536   this.addEventListener("DOMNodeInserted", function(evt){
6537     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6538       return; //強制終了させる
6539     }
6540     var tar = evt.target,
6541         tnext = tar.nextSibling,
6542         tpart = tar.parentNode._tar,
6543         isLast = true;
6544     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6545       tpart.insertBefore(tar._tar, tnext._tar);
6546     } else if (tnext && !tnext._tar && tpart) {
6547       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6548        *use要素や実体参照などは_tarプロパティがないことに注意
6549        */
6550       while (tnext) {
6551         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6552           tpart.insertBefore(tar._tar, tnext._tar);
6553           isLast = false;
6554         } 
6555         tnext = tnext.nextSibling;
6556       }
6557       if (isLast) {
6558         tpart.appendChild(tar._tar);
6559       }
6560     } else if (!tnext && tpart) {
6561       tpart.appendChild(tar._tar);      
6562     }
6563     tnext = tpart = isLast = void 0;
6564     tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
6565     evt = tar = void 0;
6566   },false);
6567   return this;
6568 };
6569 SVGTextPositioningElement.constructor = SVGTextContentElement;
6570 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6571 SVGTextPositioningElement.prototype._texto = function(evt) {
6572   var tar = evt.target,
6573       ti = tar.firstChild,
6574       ttp = tar._tar,
6575       style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6576       deter = Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6577       n = parseFloat(style.getPropertyValue("font-size")) * deter,
6578       tod = tar.ownerDocument.documentElement,
6579       ttpc = ttp, //ttpcはttpのキャッシュ
6580       tlen = tar.getComputedTextLength(),
6581       anchor = style.getPropertyValue("text-anchor"),
6582       tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6583       ttps = ttp.style,
6584       ae = [],
6585       lts = parseFloat(style.getPropertyValue("letter-spacing")),
6586       wds = parseFloat(style.getPropertyValue("word-spacing"));
6587   ttps.fontSize = n + "px"; //nは算出された文字の大きさ (CSSではなく、SVG独自のCTM方式による)
6588   ttps.fontFamily = style.getPropertyValue("font-family");
6589   ttps.fontStyle = style.getPropertyValue("font-style");
6590   ttps.fontWeight = style.getPropertyValue("font-weight");
6591   if (isFinite(lts)) {
6592     ttps.letterSpacing = lts * deter + "px";
6593   }
6594   if (isFinite(parseFloat(wds))) {
6595     ttps.wordSpacing = wds * deter + "px";
6596   }
6597   /*ここでの変数jは前回ノードまでの総文字数*/
6598   for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6599     if (ti) {
6600       if (!!ti._tars && (ti._tars.length !== 0)) {
6601         var ij = (i > j) ? i - j : j - i
6602         var sty = ti._tars[ij].style,
6603             p = tar.getStartPositionOfChar(i);
6604         sty.position = "absolute";
6605         if (tar._isYokogaki) {
6606           if (anchor === "middle") {
6607             p.x -= tlen / 2;
6608           } else if (anchor === "end") {
6609             p.x -= tlen;
6610           }
6611         } else {
6612           if (anchor === "middle") {
6613             p.y -= tlen / 2;
6614           } else if (anchor === "end") {
6615             p.y -= tlen;
6616           }
6617         }
6618         sty.left = p.x + "px";
6619         sty.top = p.y + "px";
6620         sty.width = "0px";
6621         sty.height = "0px";
6622         sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6623         sty.lineHeight = n+10+ "px";
6624         sty.textDecoration = tedeco;
6625         sty.display = "none"
6626         ttp.appendChild(ti._tars[ij]);
6627         sty = p = void 0;
6628       }
6629       if (ti.nodeName === "#text") {
6630         if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6631           j = j + ti.data.length;
6632           if (ti.parentNode.localName === "a") {
6633             ti =  ti.parentNode;
6634             ttp = ttpc;
6635           }
6636           ti = ti.nextSibling;
6637         }
6638       } else if (!!ti.getNumberOfChars) {
6639           if ((ti.getNumberOfChars()+j) <= i+1) {
6640             j = j + ti.getNumberOfChars();
6641             ti = ti.nextSibling;
6642           }
6643       } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6644         ttp = ti._tar;
6645         ti = ti.firstChild;
6646         ae[ae.length] = ti;
6647         i-=2;
6648       }
6649     }
6650   }
6651   var color = style.getPropertyValue("fill"),
6652       cursor = style.getPropertyCSSValue("cursor"),
6653       vis = style.getPropertyCSSValue("visibility"),
6654       disp = style.getPropertyCSSValue("display"),
6655       tts = tar._tar.style,
6656       tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6657       ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6658       tfti;
6659   if (color === "none"){
6660     tts.color = "transparent";
6661   } else if (color.indexOf("url") === -1) {
6662     tts.color = color;
6663   } else {
6664     tts.color = "black";
6665   }
6666   if (cursor && !cursor._isDefault) { //初期値でないならば
6667     var tc = cursor.cssText;
6668     tts.cursor = tc.split(":")[1];
6669     tc = void 0;
6670   }
6671   if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6672       && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6673     /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6674      *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6675      */
6676     for (var i=1, tli=tft.length;i<tli;++i) {
6677       tfti = tft[i];
6678       ttt += tfti.innerText;
6679       tfti.parentNode.removeChild(tfti);
6680     }
6681     //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6682     if (tft[0] && tft[0].replaceChild) {
6683       tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
6684     }
6685     ttt = void 0;
6686   }
6687   var isRect = true,
6688       di = "block";
6689   if (ttp.lastChild) {
6690     if (ttp.lastChild.nodeName !== "rect") {
6691       isRect = false;
6692     }
6693   } else {
6694     isRect = false;
6695   }
6696   if (!isRect) {
6697     var backr = tar._doc.createElement("v:rect"),
6698         backrs = backr.style; //ずれを修正するためのもの
6699     backrs.width = backrs.height = "1px";
6700     backrs.left = backrs.top = "0px";
6701     backr.stroked = backr.filled = "false";
6702     ttp.appendChild(backr);
6703   }
6704   if (vis && !vis._isDefault) {
6705     tts.visibility = vis.cssText.split(":")[1];
6706   }
6707   /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6708    *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6709    */
6710   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6711     di = "none";
6712         } else if (disp && !disp._isDefault) {
6713     di = "block";
6714   }
6715   var jt = tar._tar.firstChild,
6716       j = 0;
6717   while (jt) {
6718     jt.style.display = di;
6719     jt = jt.nextSibling;
6720   }
6721   while (ae[j]) { //要素内部にあるa要素の処理
6722     for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6723       ae[j]._tars[l].style.display = di;
6724     }
6725     l = void 0;
6726     ++j;
6727   }
6728   delete tar._cacheMatrix;
6729   ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0;
6730 };
6731
6732 function SVGTextElement(_doc) {
6733   SVGTextPositioningElement.apply(this, arguments);
6734   return this;
6735 };
6736 SVGTextElement.constructor = SVGTextPositioningElement;
6737 SVGTextElement.prototype = new SVGTextPositioningElement();
6738
6739 function SVGTSpanElement() {
6740   SVGTextElement.apply(this, arguments);
6741   return this;
6742 };
6743 SVGTSpanElement.constructor = SVGTextPositioningElement;
6744 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6745
6746 function SVGTRefElement(_doc) {
6747   SVGTextPositioningElement.apply(this, arguments);
6748   this.addEventListener("DOMNodeInserted", function(evt){
6749     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6750       return; //強制終了させる
6751     }
6752     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
6753   }, false);
6754   this.addEventListener("S_Load", function(evt){
6755     var tar = evt.target,
6756         tic = tar._instance.firstChild;
6757     /*textノードのデータだけを処理*/
6758     while (tic && (tic.nodeName !== "#text")) {
6759       tic = tic.nextSibling;
6760     }
6761     tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
6762     evt.target = tar.parentNode;
6763     tar.parentNode._texto(evt);
6764     tar = tic = evtt = void 0;
6765   }, false);
6766   SVGURIReference.apply(this, arguments);
6767   return this;
6768 };
6769 SVGTRefElement.constructor = SVGTextPositioningElement;
6770 SVGTRefElement.prototype = new SVGTextPositioningElement();
6771
6772 function SVGTextPathElement() { 
6773   SVGTextContentElement.apply(this, arguments);
6774   /*readonly SVGAnimatedLength*/      this.startOffset;
6775   /*readonly SVGAnimatedEnumeration*/ this.method;
6776   /*readonly SVGAnimatedEnumeration*/ this.spacing;
6777   SVGURIReference.apply(this, arguments);
6778   return this;
6779 };
6780 SVGTextPathElement.constructor = SVGTextContentElement;
6781 SVGTextPathElement.prototype = new SVGTextContentElement();
6782
6783 (function(t){
6784     // textPath Method Types
6785   /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN   = 0;
6786   /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN     = 1;
6787   /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH     = 2;
6788     // textPath Spacing Types
6789   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN   = 0;
6790   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO     = 1;
6791   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT     = 2;
6792 })(SVGTextPathElement);
6793
6794 function SVGAltGlyphElement() { 
6795   SVGTextPositioningElement.apply(this, arguments);
6796   /*DOMString*/ this.glyphRef;
6797   /*DOMString*/ this.format;
6798   SVGURIReference.apply(this, arguments);
6799   return this;
6800 };
6801 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6802 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6803
6804 function SVGAltGlyphDefElement() {
6805   SVGElement.apply(this, arguments);
6806   return this;
6807 };
6808 SVGAltGlyphDefElement.prototype = new SVGElement();
6809
6810 function SVGAltGlyphItemElement() {
6811   SVGElement.apply(this, arguments);
6812   return this;
6813 };
6814 SVGAltGlyphItemElement.prototype = new SVGElement();
6815
6816 function SVGGlyphRefElement() { 
6817   SVGElement.apply(this, arguments);
6818   /*DOMString*/ this.glyphRef;
6819   /*DOMString*/ this.format;
6820   /*float*/    this.x;
6821   /*float*/    this.y;
6822   /*float*/    this.dx;
6823   /*float*/    this.dy;
6824   SVGURIReference.apply(this, arguments);
6825   return this;
6826 };
6827 SVGGlyphRefElement.prototype = new SVGElement();
6828
6829 function SVGPaint() { 
6830   SVGColor.apply(this, arguments);
6831   return this;
6832 };
6833
6834 (function(t){
6835 t.prototype = new SVGColor();
6836     // Paint Types
6837   /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN               = 0;
6838   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR              = 1;
6839   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR     = 2;
6840   /*unsigned short*/ t.SVG_PAINTTYPE_NONE                  = 101;
6841   /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR          = 102;
6842   /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE              = 103;
6843   /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR      = 104;
6844   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR          = 105;
6845   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6846   /*unsigned short*/ t.SVG_PAINTTYPE_URI                   = 107;
6847   /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6848   /*readonly DOMString*/      t.prototype.uri = null;
6849 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6850   this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6851 };
6852 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6853   if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6854     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6855   }
6856   this.uri = uri;
6857   this.paintType = paintType;
6858   if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6859     paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6860   }
6861   this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6862 };
6863 //                    raises( SVGException );
6864 t = void 0;
6865 })(SVGPaint);
6866
6867 function SVGMarkerElement(){ 
6868   SVGSVGElement.apply(this, [{createElement:function(){}}]);
6869   this._tar = {style:{}}; //getScreenCTMメソッド対策
6870   var sl = SVGAnimatedLength;
6871   /*readonly SVGAnimatedLength*/      this.refX = new sl();
6872   /*readonly SVGAnimatedLength*/      this.refY = new sl();
6873   /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6874   this.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH;
6875   /*readonly SVGAnimatedLength*/      this.markerWidth = new sl();
6876   /*readonly SVGAnimatedLength*/      this.markerHeight = new sl();
6877   this.refX.baseVal.newValueSpecifiedUnits(1, 0);
6878   this.refY.baseVal.newValueSpecifiedUnits(1, 0);
6879   this.markerWidth.baseVal.newValueSpecifiedUnits(1, 3);
6880   this.markerHeight.baseVal.newValueSpecifiedUnits(1, 3);
6881   sl = void 0;
6882   /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6883   this.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE;
6884   /*readonly SVGAnimatedAngle*/       this.orientAngle = new SVGAnimatedAngle();
6885     //SVGFitToViewBoxのインターフェースはSVGSVGElementで代用
6886   this.addEventListener("DOMAttrModified", function(evt) {
6887     var tar = evt.target,
6888         en = evt.newValue,
6889         angle;
6890     if (evt.attrName === "orient") {
6891       if (en === "auto") {
6892         tar.setOrientToAuto();
6893       } else {
6894         angle = tar.ownerDocument.documentElement.createSVGAngle();
6895         angle.newValueSpecifiedUnits(1, +en);
6896         tar.setOrientToAngle(angle);
6897       }
6898     } else if (evt.attrName === "markerUnits") {
6899       if (en === "strokeWidth") {
6900         tar.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH;
6901       } else {
6902         tar.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_USERSPACEONUSE;
6903       }
6904     }
6905   }, false);
6906   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6907     /*注意: グローバル関数を書き換えているので注意を要する*/
6908     var ns = NAIBU._setPaint,
6909         id = evt.target.getAttributeNS(null, "id");
6910     NAIBU._setPaint = (function(ns, id) {
6911       return function(tar, ctm) {
6912         ns(tar, ctm);
6913         var td = tar.ownerDocument,
6914             tde = td.documentElement,
6915             style = td.defaultView.getComputedStyle(tar, ""),
6916             ms = style.getPropertyValue("marker-start").slice(5, -1),
6917             me = style.getPropertyValue("marker-end").slice(5, -1),
6918             mid = style.getPropertyValue("marker-mid").slice(5, -1),
6919             marker,
6920             cmarker,
6921             gmarker,
6922             tr,
6923             tn,
6924             ttr,
6925             sth,
6926             ctm,
6927             plist;
6928         /*url(#id)で一致する文字列があるかどうか*/
6929         if (ms === id) {
6930           marker = td.getElementById(ms);
6931           if (tar.normalizedPathSegList || tar.points) {
6932             tn = tar.normalizedPathSegList || tar.points;
6933             plist = [tn.getItem(0), tn.getItem(1)];
6934           } else if (tar.x1) {
6935             plist = [{x:tar.x1, y:tar.y1}, {x:tar.x2, y:tar.y2}];
6936           }
6937           cmarker = marker.cloneNode(true);
6938           gmarker = td.createElementNS("http://www.w3.org/2000/svg", "g");
6939           /*marker要素の子要素はすべて、g要素としてまとめておく*/
6940           while (cmarker.lastChild) {
6941             gmarker.appendChild(cmarker.lastChild);
6942           }
6943           tr = gmarker.transform.baseVal;
6944           ttr = tar.transform.baseVal.consolidate() || td.documentElement.createSVGMatrix();
6945           if (marker.markerUnits.baseVal === SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH) {
6946             sth = +style.getPropertyValue("stroke-width");
6947           } else {
6948             /*参照要素の行列の積を適用*/
6949             sth = 1;
6950           }
6951           if (marker.hasAttributeNS(null, "viewBox")) {
6952             marker.viewport.width = marker.markerWidth.baseVal.value;
6953             marker.viewport.height = marker.markerHeight.baseVal.value;
6954             /*applyを使って、marker要素のCTMを算出*/
6955             ctm = tde.getScreenCTM.apply(marker);
6956           } else {
6957             ctm = tde.createSVGMatrix();
6958           }
6959           if (marker.orientType.baseVal === SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
6960             angle = Math.atan2(plist[1].y-plist[0].y, plist[1].x-plist[0].x)*180/Math.PI;
6961           } else {
6962             angle = marker.orientAngle.baseVal.value;
6963           }
6964           tr.appendItem(tr.createSVGTransformFromMatrix(ttr.translate(plist[0].x, plist[0].y)
6965               .rotate(angle)
6966               .scale(sth)
6967               .multiply(ctm)
6968               .translate(-marker.refX.baseVal.value, -marker.refY.baseVal.value)));
6969           tar.parentNode.insertBefore(gmarker, tar.nextSibling);
6970         }
6971         if (me === id) {
6972           marker = td.getElementById(me);
6973           if (tar.normalizedPathSegList || tar.points) {
6974             tn = tar.normalizedPathSegList || tar.points;
6975             plist = [tn.getItem(tn.numberOfItems-2), tn.getItem(tn.numberOfItems-1)];
6976           } else if (tar.x1) {
6977             plist = [{x:tar.x1, y:tar.y1}, {x:tar.x2, y:tar.y2}];
6978           }
6979           cmarker = marker.cloneNode(true);
6980           gmarker = td.createElementNS("http://www.w3.org/2000/svg", "g");
6981           /*marker要素の子要素はすべて、g要素としてまとめておく*/
6982           while (cmarker.lastChild) {
6983             gmarker.appendChild(cmarker.lastChild);
6984           }
6985           tr = gmarker.transform.baseVal;
6986           ttr = tar.transform.baseVal.consolidate() || td.documentElement.createSVGMatrix();
6987           if (marker.markerUnits.baseVal === SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH) {
6988             sth = +style.getPropertyValue("stroke-width");
6989           } else {
6990             sth = 1;
6991           }
6992           if (marker.hasAttributeNS(null, "viewBox")) {
6993             marker.viewport.width = marker.markerWidth.baseVal.value;
6994             marker.viewport.height = marker.markerHeight.baseVal.value;
6995             /*applyを使って、marker要素のCTMを算出*/
6996             ctm = tde.getScreenCTM.apply(marker);
6997           } else {
6998             ctm = tde.createSVGMatrix();
6999           }
7000           if (marker.orientType.baseVal === SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
7001             angle = Math.atan2(plist[1].y-plist[0].y, plist[1].x-plist[0].x)*180/Math.PI;
7002           } else {
7003             angle = marker.orientAngle.baseVal.value;
7004           }
7005           tr.appendItem(tr.createSVGTransformFromMatrix(ttr.translate(plist[1].x, plist[1].y)
7006               .rotate(angle)
7007               .scale(sth)
7008               .multiply(ctm)
7009               .translate(-marker.refX.baseVal.value, -marker.refY.baseVal.value)));
7010           tar.parentNode.insertBefore(gmarker, tar.nextSibling);
7011         }
7012         if (mid === id) {
7013           marker = td.getElementById(mid);
7014         }
7015         td = tde = style = ms = me = mid = marker = cmarker = gmarker = ctm = sth = tr = tn = ttr = plist = void 0;
7016      };
7017     })(ns, id);
7018   }, false);
7019   return this;
7020 };
7021 (function(t){
7022     // Marker Unit Types
7023   /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN        = 0;
7024   /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
7025   /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH    = 2;
7026     // Marker Orientation Types
7027   /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN      = 0;
7028   /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO         = 1;
7029   /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE        = 2;
7030   t.prototype = new SVGSVGElement();
7031   t.prototype.getScreenCTM = SVGElement.prototype.getScreenCTM;
7032   /*void*/ t.prototype.setOrientToAuto = function() {
7033   this.orientType.baseVal = t.SVG_MARKER_ORIENT_AUTO;
7034 };
7035 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
7036   this.orientType.baseVal = t.SVG_MARKER_ORIENT_ANGLE;
7037   this.orientAngle.baseVal = angle;
7038
7039 };
7040 })(SVGMarkerElement);
7041 function SVGColorProfileElement() { 
7042   SVGElement.apply(this);
7043   /*DOMString*/      this._local;
7044                          // raises DOMException on setting
7045                        // (NOTE: is prefixed by "_"
7046                        // as "local" is an IDL keyword. The
7047                        // prefix will be removed upon processing)
7048   /*DOMString*/      this.name;
7049   /*unsigned short*/ this.renderingIntent;
7050   SVGURIReference.apply(this, arguments);
7051   return this;
7052 };
7053 SVGColorProfileElement.prototype = new SVGElement();
7054
7055 function SVGColorProfileRule() { 
7056   SVGCSSRule.apply(this);
7057   /*DOMString*/      this.src;
7058   /*DOMString*/      this.name;
7059   /*unsigned short*/ this.renderingIntent;
7060   return this;
7061 };
7062 SVGColorProfileRule.prototype = new SVGCSSRule();
7063
7064 function SVGGradientElement() { 
7065   SVGElement.apply(this);
7066   SVGURIReference.apply(this);
7067   /*readonly SVGAnimatedEnumeration*/   this.gradientUnits = new SVGAnimatedEnumeration();
7068   /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
7069   /*readonly SVGAnimatedEnumeration*/   this.spreadMethod = new SVGAnimatedEnumeration();
7070   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7071     var grad = evt.target,
7072         ele = evt._tar,
7073         t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
7074         grad2 = grad,
7075         href, stops, length,
7076         color = [],
7077         colors = [],
7078         opacity = [],
7079         stop, sstyle, ci;
7080     if (!ele || !grad) { //まだ、path要素などが設定されていない場合
7081       grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
7082       return;
7083     }
7084     if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
7085       grad2 = grad._instance;
7086     }
7087     stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
7088     if (!stops) {
7089       ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
7090       return;
7091     }
7092     length = stops.length;
7093     for (var i = 0; i < length; ++i) {
7094       stop = stops[i];
7095       sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
7096       ci = sstyle.getPropertyCSSValue("stop-color");
7097       if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
7098         /*再度、設定。css.jsのsetPropertyを参照*/
7099         sstyle.setProperty("color", sstyle.getPropertyValue("color"));
7100       }
7101       color[i] =  "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
7102       colors[i] = stop.offset.baseVal + " " + color[i];
7103       opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
7104     }
7105     ele["method"] = "none";
7106     ele["color"] = color[0];
7107     ele["color2"] = color[length-1];
7108     ele["colors"] = colors.join(",");
7109     // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
7110     ele["opacity"] = opacity[length-1]+ "";
7111     ele["o:opacity2"] = opacity[0]+ "";
7112     /*SVGRadialGradientElementインターフェースで利用する*/
7113     grad._color = color;
7114     var gt = grad2.getAttributeNS(null, "gradientTransform");
7115     if (gt) {
7116       grad.setAttributeNS(null, "transform", gt);
7117     }
7118     grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
7119   }, false);
7120   return this;
7121 };
7122 SVGGradientElement.prototype = new SVGElement();
7123     // Spread Method Types
7124   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
7125   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD     = 1;
7126   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
7127   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT  = 3;
7128
7129 function SVGLinearGradientElement() { 
7130   SVGGradientElement.apply(this);
7131   var sl = SVGAnimatedLength;
7132   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
7133   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
7134   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
7135   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
7136   sl = void 0;
7137   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7138     var grad = evt.target, ele = evt._tar, angle = 270;
7139     if (!!!ele) { //まだ、path要素などが設定されていない場合
7140       return;
7141     }
7142     var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
7143     var fontSize = parseFloat(style.getPropertyValue("font-size"));
7144     grad.x1.baseVal._emToUnit(fontSize);
7145     grad.y1.baseVal._emToUnit(fontSize);
7146     grad.x2.baseVal._emToUnit(fontSize);
7147     grad.y2.baseVal._emToUnit(fontSize);
7148     angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
7149     if (angle >= 360) {
7150       angle -= 360;
7151     }
7152     ele.setAttribute("type", "gradient");
7153     ele.setAttribute("angle", angle + "");
7154     evt = ele = grad = angle = style = fontSize = void 0;
7155   }, false);
7156   return this;
7157 };
7158 SVGLinearGradientElement.prototype = new SVGGradientElement();
7159
7160 function SVGRadialGradientElement(_doc) { 
7161   SVGGradientElement.apply(this);
7162   var sl = SVGAnimatedLength;
7163   /*readonly SVGAnimatedLength*/ this.cx = new sl();
7164   /*readonly SVGAnimatedLength*/ this.cy = new sl();
7165   /*readonly SVGAnimatedLength*/ this.r = new sl();
7166   /*readonly SVGAnimatedLength*/ this.fx = new sl();
7167   /*readonly SVGAnimatedLength*/ this.fy = new sl();
7168   sl = void 0;
7169   this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
7170   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7171     var grad = evt.target,
7172         ele = evt._tar,
7173         tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
7174     if (!!!ele) { //まだ、path要素などが設定されていない場合
7175       return;
7176     }
7177     ele.setAttribute("type", "gradientTitle");
7178     ele.setAttribute("focus", "100%");
7179     ele.setAttribute("focusposition", "0.5 0.5");
7180     if (tar.localName === "rect") {
7181       /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
7182        *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
7183        */
7184       var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
7185           fontSize = parseFloat(style.getPropertyValue("font-size"));
7186       grad.cx.baseVal._emToUnit(fontSize);
7187       grad.cy.baseVal._emToUnit(fontSize);
7188       grad.r.baseVal._emToUnit(fontSize);
7189       grad.fx.baseVal._emToUnit(fontSize);
7190       grad.fy.baseVal._emToUnit(fontSize);
7191       var cx = grad.cx.baseVal.value,
7192           cy = grad.cy.baseVal.value,
7193           r = grad.r.baseVal.value,
7194           mr = Math.round,
7195           rx, ry;
7196       rx = ry = r;
7197       var tarrect = tar.getBBox(),
7198           vi = tar.ownerDocument.documentElement.viewport,
7199           el = mr(vi.width),
7200           et = mr(vi.height),
7201           er = 0,
7202           eb = 0,
7203           units = grad.getAttributeNS(null, "gradientUnits");
7204       if (!units || units === "objectBoundingBox") {
7205         //%の場合は小数点に変換(10% -> 0.1)
7206         cx = cx > 1 ? cx/100 : cx;
7207         cy = cy > 1 ? cy/100 : cy;
7208         r = r > 1 ? r/100 : r;
7209         //要素の境界領域を求める(四隅の座標を求める)
7210         var nx = tarrect.x,
7211             ny = tarrect.y,
7212             wid = tarrect.width,
7213             hei = tarrect.height;
7214         cx = cx*wid + nx;
7215         cy = cy*hei + ny;
7216         rx = r*wid;
7217         ry = r*hei;
7218         nx = ny = wid = hei = void 0;
7219       }
7220       var matrix = tar.getScreenCTM().multiply(grad.getCTM());
7221       el = cx - rx;
7222       et = cy - ry;
7223       er = cx + rx;
7224       eb = cy + ry;
7225       var rrx = rx * 0.55228,
7226           rry = ry * 0.55228,
7227           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"];
7228       for (var i = 0, lili = list.length; i < lili;) {
7229         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
7230           ++i;
7231           continue;
7232         }
7233         var p = grad.ownerDocument.documentElement.createSVGPoint();
7234         p.x = parseFloat(list[i]);
7235         p.y = parseFloat(list[i+1]);
7236         var pmt = p.matrixTransform(matrix);
7237         list[i] = mr(pmt.x);
7238         i++;
7239         list[i] = mr(pmt.y);
7240         i++;
7241         p = pmt = void 0;
7242       }
7243       var ellipse = list.join(" "),
7244           outline = _doc.getElementById("_NAIBU_outline"),
7245           background = _doc.createElement("div"),
7246           bstyle = background.style;
7247       bstyle.position = "absolute";
7248       bstyle.display = "inline-block";
7249       var w = vi.width,
7250           h = vi.height;
7251       bstyle.textAlign = "left";
7252       bstyle.top = "0px";
7253       bstyle.left = "0px";
7254       bstyle.width = w+ "px";
7255       bstyle.height = h+ "px";
7256       outline.appendChild(background);
7257       bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
7258       background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
7259       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>',
7260           data = tar._tar.path.value;
7261       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>';
7262       background.filters[0].apply();
7263       background.innerHTML = circle;
7264       background.filters[0].play();
7265       tar._tar.parentNode.insertBefore(background, tar._tar);
7266       tar._tar.filled = "false";
7267       ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
7268     } else if (!ele.parentNode){
7269       tar._tar.appendChild(ele);
7270     }
7271     evt = tar = ele = gard = void 0;
7272   }, false);
7273   return this;
7274 };
7275 SVGRadialGradientElement.prototype = new SVGGradientElement();
7276
7277 function SVGStopElement() { 
7278   SVGElement.apply(this, arguments);
7279   /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7280   this.addEventListener("DOMAttrModified", function(evt) {
7281     if (evt.attrName === "offset") {
7282       evt.target.offset.baseVal = parseFloat(evt.newValue);
7283     }
7284     evt = void 0;
7285   }, false);
7286   return this;
7287 };
7288 SVGStopElement.prototype = new SVGElement();
7289
7290 function SVGPatternElement() { 
7291   SVGElement.apply(this);
7292   var sl = SVGAnimatedLength;
7293   /*readonly SVGAnimatedEnumeration*/   this.patternUnits = new SVGAnimatedEnumeration();
7294   /*readonly SVGAnimatedEnumeration*/   this.patternContentUnits = new SVGAnimatedEnumeration();
7295   /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7296   /*readonly SVGAnimatedLength*/        this.x = new sl();
7297   /*readonly SVGAnimatedLength*/        this.y = new sl();
7298   /*readonly SVGAnimatedLength*/        this.width = new sl();
7299   /*readonly SVGAnimatedLength*/        this.height = new sl();
7300   sl = void 0;
7301   SVGURIReference.apply(this, arguments);
7302     //SVGFitToViewBoxのインターフェースを用いる
7303   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
7304   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7305   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7306   return this;
7307 };
7308 SVGPatternElement.prototype = new SVGElement();
7309
7310 function SVGClipPathElement() { 
7311   SVGElement.apply(this, arguments);
7312   /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7313   return this;
7314 };
7315 SVGClipPathElement.prototype = new SVGElement();
7316
7317 function SVGMaskElement() { 
7318   SVGElement.apply(this);
7319   var sl = SVGAnimatedLength;
7320   /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7321   /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7322   /*readonly SVGAnimatedLength*/      this.x = new sl();
7323   /*readonly SVGAnimatedLength*/      this.y = new sl();
7324   /*readonly SVGAnimatedLength*/      this.width = new sl();
7325   /*readonly SVGAnimatedLength*/      this.height = new sl();
7326   sl = void 0;
7327   return this;
7328 };
7329 SVGMaskElement.prototype = new SVGElement();
7330
7331 function SVGFilterElement() { 
7332   SVGElement.apply(this);
7333   var sl = SVGAnimatedLength;
7334   /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7335   /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7336   /*readonly SVGAnimatedLength*/      this.x = new sl();
7337   /*readonly SVGAnimatedLength*/      this.y = new sl();
7338   /*readonly SVGAnimatedLength*/      this.width = new sl();
7339   /*readonly SVGAnimatedLength*/      this.height = new sl();
7340   sl = void 0;
7341   /*readonly SVGAnimatedInteger*/     this.filterResX = new SVGAnimatedInteger();
7342   /*readonly SVGAnimatedInteger*/     this.filterResY = new SVGAnimatedInteger();
7343   SVGURIReference.apply(this, arguments);
7344   //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7345   return this;
7346 };
7347 SVGFilterElement.prototype = new SVGElement();
7348
7349 function SVGFilterPrimitiveStandardAttributes(ele) { 
7350   SVGStylable.apply(this, arguments);
7351   this._tar = ele;
7352   var sl = SVGAnimatedLength;
7353   /*readonly SVGAnimatedLength*/ this.x = new sl();
7354   /*readonly SVGAnimatedLength*/ this.y = new sl();
7355   /*readonly SVGAnimatedLength*/ this.width = new sl();
7356   /*readonly SVGAnimatedLength*/ this.height = new sl();
7357   /*readonly SVGAnimatedString*/ this.result = new sl();
7358   sl = void 0;
7359   };
7360 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7361
7362 function SVGFEBlendElement() {
7363   SVGElement.apply(this, arguments);
7364   /*readonly SVGAnimatedString*/      this.in1 = new SVGAnimatedString();
7365   /*readonly SVGAnimatedString*/      this.in2 = new SVGAnimatedString();
7366   /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7367   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7368   return this;
7369 };
7370 SVGFEBlendElement.prototype = new SVGElement();
7371     // Blend Mode Types
7372   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN  = 0;
7373   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL   = 1;
7374   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7375   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN   = 3;
7376   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN   = 4;
7377   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN  = 5;
7378
7379 function SVGFEGaussianBlurElement() { 
7380   SVGElement.apply(this, arguments);
7381   /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7382   /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7383   /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7384   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7385   return this;
7386 };
7387 SVGFEGaussianBlurElement.prototype = new SVGElement();
7388 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7389   
7390 };
7391
7392 function SVGCursorElement() { 
7393   SVGElement.apply(this, arguments);
7394   /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7395   /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7396   SVGURIReference.apply(this, arguments);
7397   return this;
7398 };
7399 SVGCursorElement.prototype = new SVGElement();
7400
7401 function SVGAElement(_doc) {
7402   SVGElement.apply(this);
7403   this._tar = _doc.createElement("a");
7404   _doc = void 0;
7405   /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7406   this.target.baseVal = "_self";
7407   this.addEventListener("DOMAttrModified", function(evt){
7408     var tar = evt.target;
7409     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7410       return; //強制終了させる
7411     }
7412     if (evt.attrName === "target") {
7413       tar.target.baseVal = evt.newValue;
7414     } else if (evt.attrName === "xlink:title") {
7415       tar._tar.setAttribute("title", evt.newValue);
7416     }
7417     evt = void 0;
7418   }, false);
7419   this.addEventListener("DOMNodeInserted", function(evt){
7420     var tar = evt.target;
7421     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7422       return; //強制終了させる
7423     }
7424     if (tar.nextSibling) {
7425       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7426         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7427       }
7428     } else if (!!tar.parentNode._tar){
7429       tar.parentNode._tar.appendChild(tar._tar);
7430     }
7431     var txts = tar._tar.style;
7432     txts.cursor = "hand";
7433     txts.left = "0px";
7434     txts.top = "0px";
7435     txts.textDecoration = "none";
7436     txts = void 0;
7437     var t = tar.target.baseVal;
7438     var st = "replace";
7439     if (t === "_blank") {
7440       st = "new";
7441     }
7442     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7443     tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7444     tar = evt = void 0;
7445   }, false);
7446   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7447     var tar = evt.target;
7448     if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7449       var txts = tar._tar.style;
7450       txts.cursor = "hand";
7451       txts.textDecoration = "none";
7452       txts = void 0;
7453     }
7454     tar = evt = void 0;
7455     return; //強制終了させる
7456   }, true);
7457   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7458     var tar = evt.target;
7459     tar._tar.setAttribute("target", tar.target.baseVal);
7460     if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7461       tar.addEventListener("click", function(evt){
7462           var tar = evt.target,
7463               sd = document.body,
7464               ob, nd;
7465           sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7466           if (tar.target.baseVal === "_self") {
7467             nd = tar.ownerDocument._iframe;
7468             nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7469             ob = nd.nextSibling;
7470             if (ob && (ob.tagName === "OBJECT")) {
7471               nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7472               nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7473               nd.parentNode.removeChild(ob);
7474             }
7475             ob = NAIBU._search([nd.previousSibling]);
7476             nd.parentNode.removeChild(nd);
7477           } else {
7478             sd.appendChild(sd.lastChild.firstChild);
7479             while (sd.firstChild !== sd.lastChild) {     //オブジェクト要素以外を除去
7480               sd.removeChild(sd.firstChild);
7481             }
7482             ob = NAIBU._search([sd.lastChild]);
7483           }
7484           NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7485           evt.preventDefault();
7486           ob._next = {
7487             _init: (function (ob) {
7488               return (function(){
7489                 document.title = ob.getSVGDocument().title;
7490                 ob = void 0;
7491               });
7492             })(ob)
7493           };
7494           ob._init();
7495           sd = ob = nd = void 0;
7496       }, false);
7497     }
7498     tar = void 0;
7499   }, false);
7500   SVGURIReference.apply(this, arguments);
7501   return this;
7502 };
7503 SVGAElement.prototype = new SVGElement();
7504
7505 function SVGViewElement() { 
7506   SVGElement.apply(this, arguments);
7507   /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7508       //SVGFitToViewBoxのインターフェースを用いる
7509   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
7510   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7511   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7512   return this;
7513 };
7514 SVGViewElement.prototype = new SVGElement();
7515
7516 function SVGScriptElement() { 
7517   SVGElement.apply(this);
7518   /*DOMString*/ this.type;
7519   SVGURIReference.apply(this, arguments);
7520   this.addEventListener("DOMAttrModified", function(evt){
7521     if (evt.attrName === "type") {
7522       evt.target.type = evt.newValue;
7523     }
7524     evt = void 0;
7525   }, false);
7526   this.addEventListener("S_Load", function(evt){
7527     var tar = evt.target, script = tar._text;
7528     var tod = tar.ownerDocument;
7529     NAIBU._temp_doc = tod;
7530     script = script.replace(/function\s+(\w+)/g, "$1 = function");
7531     script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7532     try {
7533       eval(script);
7534     } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7535       script = script.replace(/function\(document\){/, "function() {");
7536       eval(script);
7537     }
7538     tar = evt = script = void 0;
7539   }, false);
7540   this.addEventListener("DOMNodeInserted", function(evt){
7541     var tar = evt.target;
7542     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7543       if (tar.nodeName === "#cdata-section") {
7544         evt.currentTarget._text = tar.data;
7545       }
7546       return;
7547     }
7548     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7549       var tar = evt.target;
7550       if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7551         var evtt = tar.ownerDocument.createEvent("SVGEvents");
7552         evtt.initEvent("S_Load", false, false);
7553         evt.currentTarget.dispatchEvent(evtt);
7554       }
7555       tar = evt = void 0;
7556     }, false);
7557   }, false);
7558   return this;
7559 };
7560 SVGScriptElement.prototype = new SVGElement();
7561
7562 function SVGEvent() {
7563   Event.apply(this, arguments);
7564   return this;
7565 };
7566 SVGEvent.prototype = new Event();
7567
7568 function SVGZoomEvent() { 
7569   UIEvent.apply(this, arguments);
7570   /*readonly SVGRect*/  this.zoomRectScreen = new SVGRect();
7571   /*readonly float*/    this.previousScale = 1;
7572   /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7573   /*readonly float*/    this.newScale = 1;
7574   /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7575   return this;
7576 };
7577 SVGZoomEvent.prototype = new UIEvent();
7578
7579 function SVGAnimationElement(es) {
7580   if (!!es) {
7581     return this;
7582   }
7583   SVGElement.apply(this);
7584   /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7585    *styleのsetPropertyメソッドを無効化させておく必要がある
7586    */
7587   this.style.setProperty = function(){};
7588   this._tar = null;
7589   /*readonly SVGElement*/ this.targetElement;
7590   /*それぞれのプロパティは、_を除いた属性に対応している*/
7591   this._begin = this._end = this._repeatCount = this._repeatDur = this._dur = this._resatrt = null;
7592   this._currentFrame = 0;
7593   /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
7594   this._isRepeat = false;
7595   this._numRepeat = 0;
7596   /*_isStartプロパティは一度は起動したかどうか*/
7597   this._isStarted = false;
7598   /*_startと_finishプロパティはミリ秒数のリストを収納する。
7599    *_startはアニメ開始時の秒数リスト。_finishはアニメ終了時の秒数のリスト。
7600    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7601    *_startingプロパティは現在アニメーションでの開始時刻。getSartTimeメソッドで使う
7602    */
7603   this._start = this._finish = this._starting = null;
7604   /*_activeDurプロパティは現時点でのアニメーションの活動期間*/
7605   this._activeDur = 0; 
7606   this._from = this._to = this._values = this._by = null;
7607   this._keyTimes = null;
7608   this.addEventListener("beginEvent", function(evt) {
7609     try {
7610       var tar = evt.target,
7611       begin = tar.getStartTime(),
7612       durv = tar._dur,
7613       dur = tar._getOffset(durv),
7614       end = tar._finish,
7615       endv= tar._end,
7616       td = tar._repeatDur,
7617       tc = tar._repeatCount,
7618       ac = null;
7619       if (end) {
7620         for (var i=0, eli=end.length;i<eli;++i) {
7621           /*endの配列(ソース済み)からbeginに最も近い数値を選ぶ*/
7622           if (end[i] >= begin) {
7623             end = end[i];
7624             break;
7625           }
7626         }
7627       } else {
7628         /*イベント待ちの場合は、endの値を、indefiniteとみなす。参照: http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7629          * 
7630          * 3.3.4. Computing the active duration
7631          * 
7632          * If the value of end cannot be resolved (e.g. when it is event-based),
7633          * the value is considered to be "indefinite" for the purposes of evaluating the active duration.
7634          *
7635          */
7636         endv = null;
7637       }
7638       /*Activate Duration (活性持続時間と呼ぶことにする)を計算
7639        *計算方法は以下を参照のこと
7640        *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7641        *3.3.4. Computing the active duration
7642        */
7643       if ((td === "indefinite") || (tc === "indefinite")) {
7644         if (endv) {
7645           ac = end - begin;
7646         } else {
7647           /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7648           ac = null;
7649         }
7650       } else if (durv === "indefinite") {
7651         if (!tc && !endv) {
7652           /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7653           ac = null;
7654         } else if (tc && !endv) {
7655           ac = tar._getOffset(td);
7656         } else if (!tc && endv) {
7657           ac = end - begin;
7658         } else {
7659           ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7660         }
7661       } else if (durv && !td && !tc && !endv) {
7662         ac = dur;
7663       } else if (durv && !td && tc && !endv) {
7664         ac = dur * (+tc);
7665       } else if (durv && td && !tc && !endv) {
7666         ac = tar._getOffset(td);
7667       } else if (durv && !td && !tc && endv) {
7668         ac = (dur > (end - begin)) ? dur : (end - begin);
7669       } else if (durv && td && tc && !endv) {
7670         ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
7671       } else if (durv && td && tc && endv) {
7672         ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
7673       } else if (durv && td && !tc && endv) {
7674         ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7675       } else if (durv && !td && tc && endv) {
7676         ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
7677       }
7678     } catch (e) {
7679       tar.endElementAt(1);
7680       throw new DOMException(DOMException.INVALID_STATE_ERR);
7681     }
7682     if ((ac || (ac === 0)) && isFinite(ac)) {
7683       /*endの値がすでにある場合は、二重指定を避ける*/
7684       endv || tar.endElementAt(ac);
7685       tar._activeDur = ac;
7686     }
7687     tar = begin = dur = durv = end = endv= td = tc = ac = void 0;
7688   }, false);
7689   this.addEventListener("DOMAttrModified", function(evt){
7690     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7691       return;
7692     }
7693     var tar = evt.target,
7694         name = evt.attrName,
7695         evtv = evt.newValue;
7696     if (name === "begin") {
7697       tar._begin = evtv.replace(/\s+/g, "").split(";"); //空白は取り除く
7698     } else if (name === "end") {
7699       tar._end = evtv.replace(/\s+/g, "").split(";");
7700     } else if (name === "dur") {
7701       tar._dur = evtv;
7702     } else if (name === "repeatCount") {
7703       tar._repeatCount = evtv;
7704       tar._isRepeat = true;
7705     } else if (name === "repeatDur") {
7706       tar._repeatCount = evtv;
7707       tar._isRepeat = true;
7708     } else if (name === "from") {
7709       tar._from = evtv;
7710     } else if (name === "to") {
7711       tar._to = evtv;
7712     } else if (name === "values") {
7713       tar._values = evtv.split(";");
7714     } else if (name === "by") {
7715       tar._by = evtv;
7716     } else if (name === "keyTimes") {
7717       var s = evtv.split(";");
7718       tar._keyTimes = []; //_keyTimesプロパティを初期化
7719       for (var i=0;i<s.length;++i) {
7720         tar._keyTimes[i] = parseFloat(s[i]);
7721       }
7722       s = void 0;
7723     } else if (name === "restart") {
7724       tar._restart = evtv;
7725     }
7726     evt = evtv = void 0;
7727   }, false);
7728   this.addEventListener("DOMNodeInserted", function(evt){
7729     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7730       return; //強制終了させる
7731     }
7732     var tar = evt.target;
7733     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7734       var tar = evt.target;
7735       /*以降の場合分けルールに関しては、下記の仕様を参照
7736        *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7737        */
7738       if (tar._values) {
7739       } else if (tar._from && tar._to) {
7740         tar._values = [tar._from, tar._to];
7741       } else if (tar._from && tar._by) {
7742         var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7743         tar._values = [tar._from, n+tanni[0]];
7744       } else if (tar._to) {
7745         tar._values = [null, tar._to];
7746       } else if (tar._by) {
7747         tar._values = [null, null, tar._by];
7748       } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7749         /*アニメーションの効果が出ないように調整する
7750          *SMILアニメーションの仕様を参照
7751          *
7752          *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7753          *「3.2.2. Animation function values」より引用
7754          *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7755          */
7756         return this;
7757       }
7758       /*begin属性とend属性を処理する*/
7759       var that = tar,
7760           timing = function(val, name, offset) {
7761         /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
7762          *まず、idを検出するためのsearcIdローカル関数を作る
7763          */
7764         var searchId = function () {
7765               var n = val.indexOf(".");
7766               if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
7767                 return (val.slice(0, n));
7768               }
7769               n = nn = void 0;
7770               return "";
7771             },
7772             id;
7773         /*
7774          *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
7775          */
7776         if (isFinite(parseFloat(val))) { //1) offset-valueの場合
7777           that[name](offset);
7778         } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
7779           var inte = parseFloat(val.slice(7)),
7780               ds = (function(that, name, offset) {
7781                 return function (evt) {
7782                    if (inte === evt.target._numRepeat) {
7783                      that[name](offset);
7784                    }
7785                 };
7786               })(that, name, offset),
7787               id = searchId();
7788               if (id) {
7789                 that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
7790               } else {
7791                 that.addEventListener("repeatEvent", ds);
7792               }
7793         } else if (/\.(begin|end)/.test(val)) { //3) syncbase-valueの場合
7794           id = searchId();
7795           if (id) {
7796             var ds = (function(that, name, offset) {
7797                   return function (evt) {
7798                     that[name](offset);
7799                   };
7800                 })(that, name, offset),
7801                 ev = "";
7802             /\.(begin|end)/.test(val); //RegExp.$1のために、もう一度する必要がある
7803            if (RegExp.$1 === "begin") {
7804               ev = "beginEvent";
7805             } else if (RegExp.$1 === "end") {
7806               ev = "endEvent";
7807             }
7808             that.ownerDocument.getElementById(id).addEventListener(ev, ds, false);
7809           }
7810         } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
7811           
7812         } else if (val === "indefinite") { //5) indefiniteの場合
7813         } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
7814           
7815         } else { //7) event-valueの場合
7816           id = searchId();
7817           var ds = (function(that, name, offset) {
7818                 return function (evt) {
7819                    that[name](offset);
7820                 };
7821               })(that, name, offset);
7822           if (id && val.match(/\.([a-z]+)/i)) {
7823             that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
7824           } else if (val){
7825             that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
7826           }
7827         }
7828         val = searchId = id = void 0;
7829       };
7830       if (tar._begin) {
7831         for (var i=0,tli=tar._begin.length;i<tli;++i) {
7832           timing(tar._begin[i], "beginElementAt", tar._getOffset(tar._begin[i]));
7833         }
7834       } else {
7835         tar.beginElementAt(0);
7836       }
7837       if (tar._end) {
7838         for (var i=0,tli=tar._end.length;i<tli;++i) {
7839           timing(tar._end[i], "endElementAt", tar._getOffset(tar._end[i]));
7840         }
7841       }
7842       that = void 0;
7843       if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7844         tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").slice(1))
7845       } else {
7846         tar.targetElement = tar.parentNode;
7847       }
7848       evt = tar = void 0;
7849     }, false);
7850     evt = tar = void 0;
7851   }, false);
7852   return this;
7853 };
7854 SVGAnimationElement.prototype = new SVGElement();
7855 /*以下のメソッド(beginElementなど)については、
7856  *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7857  */
7858 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7859   var ttd = this.ownerDocument,
7860       evt = ttd.createEvent("TimeEvents");
7861   this._starting = ttd.documentElement.getCurrentTime(); //getStartTimeメソッドで使う開始時刻
7862   if (this._isStarted && ((this._restart === "never")
7863       || ((this._restart === "whenNotActive") && (this.getCurrentTime() > 0)))) {
7864     return; //restart属性の設定により、再起動させないようにする
7865   }
7866   if (this.getCurrentTime() > 0) {
7867     /*アニメーションの最中で、beginEventが起きるときは、endEventが前もって起こされる。SVG1.1の仕様を参照
7868      * 
7869      * 19.4.2 Interface TimeEvent
7870      * Note that if an element is restarted while it is currently playing, the element will raise an end event and another begin event, as the element restarts. 
7871      * 
7872      * http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
7873      * 
7874      */
7875     this.endElement();
7876   }
7877   evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7878   this.dispatchEvent(evt);
7879   /*新しくリストの頭を更新して、別の値も実行させるようにする*/
7880   this._start && this._start.shift();
7881   this._isStarted = true;
7882   ttd = evt = void 0;
7883 };
7884 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7885   var ttd = this.ownerDocument,
7886       evt = ttd.createEvent("TimeEvents");
7887   evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7888   this.dispatchEvent(evt);
7889   this._finish && this._finish.shift();
7890   this._currentFrame = 0;
7891 };
7892 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7893   var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7894       start = this._start || [];
7895   for (var i=0,sli=start.length;i<sli;++i) {
7896     if (start[i] === (offset+ntc)) {
7897       ntc = start = offset = void 0;
7898       return;
7899     }
7900   }
7901   start.push(offset + ntc);
7902   start.sort(function(a, b) {
7903     return a - b;
7904   });
7905   this._start = start;
7906   ntc = start = offset = void 0;
7907 };
7908 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7909   var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7910   fin = this._finish || [];
7911   for (var i=0,fli=fin.length;i<fli;++i) {
7912     if (fin[i] === (offset+ntc)) {
7913       ntc = fin = offset = void 0;
7914       return;
7915     }
7916   }
7917   fin.push(offset + ntc);
7918   fin.sort(function(a, b) {
7919     return a - b;
7920   });
7921   this._finish = fin;
7922   ntc = start = offset = void 0;
7923 };
7924 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7925 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
7926 SVGAnimationElement.prototype._unit = {
7927     "h"   : 3600000,
7928     "min" : 60000,
7929     "s"   : 1000
7930 };
7931 /*_getOffsetメソッド
7932  * どれだけズレの時間があるかを計測するメソッド
7933  *tに数値が使われていないときは0を返す
7934  *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7935  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7936  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7937  ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7938  */
7939 SVGAnimationElement.prototype._getOffset = function(/*string*/ val) {
7940   var t = null, //tは最初の数値
7941       n = [val.indexOf("+"), val.indexOf("-")],
7942       s;
7943   if (n[0] > -1) {
7944     s = val.slice(n[0]);
7945     t = parseFloat(s);
7946   } else if (n[1] > -1) {
7947     s = val.slice(n[1]);
7948     t = parseFloat(s);
7949   } else {
7950     s = val;
7951     t = parseFloat(val);
7952   }
7953   if (isFinite(t)) {
7954     if (/\d+\:(\d\d)\:([\d\.]+)$/.test(s)) { //Full-Clock-Valueの場合
7955       t = (t*3600 + parseInt(RegExp.$1, 10)*60 + parseFloat(RegExp.$2)) * 1000;
7956     } else if (/\d\d\:([\d\.]+)$/.test(s)) {
7957       t = (t*60 + parseFloat(RegExp.$1)) * 1000;
7958     } else if (/(h|min|s)$/.test(s)) {
7959       t *= this._unit[RegExp.$1];
7960     }
7961     if (isFinite(t)) {
7962        t *= 0.8;
7963       return t;
7964     }
7965   }
7966   return 0;
7967 };
7968
7969 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7970   if (this._starting || (this._starting === 0)) {
7971     return (this._starting);
7972   } else {
7973     throw new DOMException(DOMException.INVALID_STATE_ERR);
7974   }
7975 };
7976 /*getCurrentTimeメソッド
7977  *現在の時間コンテナ内での時刻であり、
7978  *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7979  */
7980 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7981   return (this._currentFrame * 125 * 0.8);
7982 };
7983 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7984   if (!this._dur && !this._finish && (this._dur === "indefinite")) {
7985     throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7986   } else {
7987     return (this._getOffset(this._dur));
7988   }
7989 };
7990                     //raises( DOMException );
7991 NAIBU.Time = {
7992   currentFrame : 0,
7993   Max : 17000,
7994   start : function() {
7995   if (NAIBU.Clip.length > 0) {
7996     screen.updateInterval = 42; //24fpsとして描画処理
7997     window.onscroll = function () {
7998       screen.updateInterval = 0;
7999       screen.updateInterval = 42;
8000     }
8001     NAIBU.stop = setInterval( (function() {
8002 /*      try{*/
8003         var ntc = NAIBU.Time.currentFrame,
8004             nc = NAIBU.Clip,
8005             s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
8006         if (ntc > NAIBU.Time.Max) {
8007           clearInterval(NAIBU.stop);
8008         }
8009         nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
8010         for (var i=0,ncli=nc.length;i<ncli;++i) {
8011           var nci = nc[i]
8012               s2 = s + 100,
8013               s1 = s - 100;
8014           if (nci._start) {
8015               var sti = nci._start[0];
8016               if (sti && nci._finish && (sti === nci._finish[0])) { //アニメーションの途中ならば
8017                 nci.endElement();
8018               }
8019               if ((sti || (sti === 0)) && (s1 <= sti) && (sti < s)) {
8020                 nci.beginElement();
8021               }
8022               sti = void 0;
8023           }
8024           if (nci._isRepeat && (nci.getCurrentTime() >= nci.getSimpleDuration()*nci._numRepeat)) {
8025             /*リピート処理*/
8026             var ttd = nci.ownerDocument,
8027                 evt = ttd.createEvent("TimeEvents");
8028             ++nci._numRepeat;
8029             evt.initTimeEvent("repeatEvent", ttd.defaultView, nci._numRepeat);
8030             nci.dispatchEvent(evt);
8031             ttd = evt = void 0;
8032           }
8033           if (nci._finish && (nci.getCurrentTime() !== 0)) {
8034               var fti = nci._finish[0];
8035               if ((fti || (fti === 0)) && (s1 <= fti) && (fti <= s)) {
8036                 nci.endElement();
8037               }
8038               fti = void 0;
8039           }
8040           if (nci._frame) {
8041             ++nci._currentFrame;
8042             nci._frame();
8043           }
8044         }
8045         ++NAIBU.Time.currentFrame;
8046         ntc = nc = s = nci = s1 = s2 = void 0;
8047 /*      } catch (e) {
8048         stlog.add(e, 4157);
8049       }*/
8050         }),
8051          1
8052       );
8053     } else {
8054       window.onscroll = function () {
8055         screen.updateInterval = 0;
8056                window.onscroll = NAIBU.emptyFunction;
8057       }
8058     }
8059  }
8060 };
8061 NAIBU.Clip = [];
8062   
8063 function SVGAnimateElement(){
8064   SVGAnimationElement.apply(this);
8065   /*NAIBU.Clipについては、NAIBU.Timeで使う
8066    *くわしくはNAIBU.Time.start関数のコードを参照
8067    */
8068   NAIBU.Clip[NAIBU.Clip.length] = this;
8069   /*_valueListプロパティは、
8070    *機械が理解できる形で保管されているvalueの値の配列リスト
8071    */
8072   this._valueList = [];
8073   this._isDiscrete = false;
8074   this.addEventListener("DOMAttrModified", function(evt){
8075     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8076       return; //強制終了させる
8077     }
8078     if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
8079       evt.target._isDiscrete = true;
8080     }
8081   }, false);
8082   this.addEventListener("DOMNodeInserted", function(evt){
8083     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8084       return; //強制終了させる
8085     }
8086     var tar = evt.target;
8087     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8088       var tar = evt.target,
8089           attrName = tar.getAttributeNS(null, "attributeName"),
8090           ttr = tar.targetElement,
8091           tta = ttr[attrName];
8092       /*tar.valuesのリスト:  ["12px", "13px"]
8093        *tar._valueList:   [(new SVGPoint()), (new SVGPoint())]
8094        *  tar.valuesを機械が理解できるように変換したものがtar._valueList
8095        *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
8096        */
8097       var vi = ttr.cloneNode(false);
8098       if (!tar._values[0]) {   //to属性か、by属性が設定されている場合
8099         var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
8100         tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
8101         if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
8102           var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
8103           tar._values[1] = v2 + tanni[0];
8104           tar._values.pop();
8105           v2 = tanni = void 0;
8106         }
8107       }
8108       if (("animatedPoints" in ttr) && (attrName === "points")) {
8109         ttr.animatedPoints = vi.points;
8110         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8111           var vir = ttr.cloneNode(false);
8112           delete vir._tar;
8113           vir.setAttributeNS(null, "points", tav[i]);
8114           tar._valueList[tar._valueList.length] = vir.points;
8115         }
8116       } else if (!!tta) {
8117         tta.animVal = vi[attrName].baseVal;
8118         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8119           var vir = ttr.cloneNode(false); //仮の要素
8120           delete vir._tar;
8121           vir.setAttributeNS(null, attrName, tav[i]);
8122           tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
8123         }
8124       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8125         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8126           if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
8127             tar._valueList[i] = new SVGPaint();
8128             tar._valueList[i].setPaint(1, null, tav[i], null)
8129           } else {
8130             tar._valueList[i] = parseFloat(tav[i]);
8131           }
8132         }
8133       } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
8134         ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
8135         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8136           var vir = ttr.cloneNode(false);
8137           delete vir._tar;
8138           vir.setAttributeNS(null, "d", tav[i]);
8139           tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
8140         }
8141       } else {
8142         vi = void 0;
8143         return;
8144       }
8145       evt = tta = vir = vi = void 0;
8146     }, false);
8147   }, false);
8148   this.addEventListener("beginEvent", function(evt) {
8149     var _tar = evt.target,
8150         attrName = _tar.getAttributeNS(null, "attributeName"),
8151         newAttr = _tar.targetElement.attributes.getNamedItemNS(null, attrName),
8152         ttr = _tar.targetElement,
8153         tta = ttr[attrName];
8154     _tar._frame = function() {
8155       var tar = _tar,
8156           d = tar._isRepeat ? tar.getSimpleDuration() : tar._activeDur,
8157           n = tar._valueList.length-1,
8158           tg = tar.getCurrentTime();
8159       tar._activeDur || (d = 0);
8160       d *= 0.8;
8161       if ((n !== -1) && (d !== 0) && (tg <= d)) {
8162         if (tar._isDiscrete) {
8163           ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
8164         }
8165         var ii = Math.floor((tg*n) / d);
8166         if (ii === n) { //iiが境い目のときは、n-2を適用
8167           ii -= 1;
8168         }
8169       } else {
8170         return;
8171       }
8172       /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8173       *
8174       * 参照:アニメーションサンドイッチモデル
8175       * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8176       *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8177       */
8178       var evt = tar.ownerDocument._domnodeEvent();
8179       if (tar._keyTimes) {
8180         var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8181         var ti = tar._keyTimes[ii];
8182       } else {
8183         var di = d / n; //keyTimesがなければ均等に時間を配分しておく
8184         var ti = ii / n;
8185       }
8186       if (("animatedPoints" in ttr) && (attrName === "points")) {
8187         var base = ttr.points;
8188         ttr.points = ttr.animatedPoints;
8189         ttr.dispatchEvent(evt);
8190         ttr.animatedPoints = ttr.points;
8191         ttr.points = base;
8192       } else if (!!tta) {
8193         var base = tta.baseVal, tanim = tta.animVal;
8194         var v1 = tar._valueList[ii].value;
8195         /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8196          * 3.4.2 Specifying the simple animation function f(t)
8197          *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8198          */
8199         if (!tar._isDiscrete) {
8200           var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
8201         } else {
8202           var v = v1;
8203         }
8204         tanim.newValueSpecifiedUnits(base.unitType, v);
8205         tta.baseVal = tanim;
8206         tanim = void 0;
8207         ttr.dispatchEvent(evt);
8208         /*変化値はanimValプロパティに収納しておき、
8209          *変化する前の、元の値はbaseValプロパティに再び収納しておく
8210          */
8211         tta.animVal = tta.baseVal;
8212         tta.baseVal = base;
8213         di = void 0;
8214       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8215         var base = null;
8216         var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
8217         if (!tar._isDiscrete) {
8218           var v = v1 + (v2-v1) * (tg-ti*d) / di;
8219         } else {
8220           var v = v1;
8221         }
8222       } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
8223         var base = ttr.normalizedPathSegList;
8224         ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
8225         ttr.dispatchEvent(evt);
8226         ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
8227         ttr.normalizedPathSegList = base;
8228       }
8229      evt = tar = v1 = v2 = v = d = n = ii = tg = void 0;
8230     };
8231     evt = vir = void 0;
8232   }, false);
8233   this.addEventListener("endEvent", function(evt) {
8234     var tar = evt.target,
8235         fill = tar.getAttributeNS(null, "fill");
8236     if (!fill || (fill === "remove")) {
8237       var evt = tar.ownerDocument._domnodeEvent();
8238       tar.targetElement.dispatchEvent(evt);
8239       evt = void 0;
8240       tar._frame && tar._frame();
8241     }
8242     delete tar._frame;
8243   }, false);
8244   this.addEventListener("repeatEvent", function(evt) {
8245     var tar = evt.target;
8246   }, false);
8247   return this;
8248 };
8249 SVGAnimateElement.prototype = new SVGAnimationElement(1);
8250
8251 function SVGSetElement(){
8252   SVGAnimationElement.apply(this);
8253   NAIBU.Clip[NAIBU.Clip.length] = this;
8254   this._to = "";
8255   this.addEventListener("DOMAttrModified", function(evt) {
8256     var tar = evt.target, name = evt.attrName;
8257     if (name === "to") {
8258       tar._to = evt.newValue;
8259     }
8260     tar = name = void 0;
8261   }, false);
8262   this.addEventListener("beginEvent", function(evt) {
8263     var tar = evt.target;
8264     tar._currentFrame = 1; //これがないと、NAIBU.stopの内部の処理の都合上、endEventが発動しない。
8265     if (tar.targetElement) {
8266       var attrName = tar.getAttributeNS(null, "attributeName"),
8267           newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
8268           tta = tar.targetElement[attrName];
8269       if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8270         /*前もって、スタイルシートの値を取得しておいて、endEventの際に使う*/
8271         tar._prestyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "").getPropertyValue(attrName);
8272         var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8273         style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
8274         style = void 0;
8275       } else if (!!tta) {
8276         var base = tta.baseVal;
8277         if (base instanceof SVGLength) {
8278           tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
8279         } else if (base instanceof SVGRect) {
8280           tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
8281         }
8282         /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8283          *
8284          * 参照:アニメーションサンドイッチモデル
8285          * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8286          *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8287          */
8288         var evt = tar.ownerDocument.createEvent("MutationEvents");
8289         evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
8290         tar.targetElement.dispatchEvent(evt);
8291         evt = void 0;
8292         /*変化値はanimValプロパティに収納しておき、
8293          *変化する前の、元の値はbaseValプロパティに再び収納しておく
8294          */
8295         tta.animVal = tta.baseVal;
8296         tta.baseVal = base;
8297       }
8298     }
8299     evt = tar = attrName = void 0;
8300   }, false);
8301   this.addEventListener("endEvent", function(evt) {
8302     var tar = evt.target,
8303         fill = tar.getAttributeNS(null, "fill");
8304     if (!fill || (fill === "remove")) {
8305       var attrName = tar.getAttributeNS(null, "attributeName"),
8306           style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8307       if (tar._prestyle) { //スタイルシートの変更ならば
8308         style.setProperty(attrName, tar._prestyle, null);
8309       } else {
8310         var evtt = tar.ownerDocument._domnodeEvent();
8311         tar.targetElement.dispatchEvent(evtt);
8312       }
8313       attrName = style = evtt = void 0;
8314     }
8315     tar = fill = void 0;
8316   }, false);
8317   this.addEventListener("repeatEvent", function(evt) {
8318     var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8319   }, false);
8320   return this;
8321 };
8322 SVGSetElement.prototype = new SVGAnimationElement(1);
8323
8324 function SVGAnimateMotionElement(){
8325   SVGAnimationElement.apply(this);
8326   NAIBU.Clip[NAIBU.Clip.length] = this;
8327   this.addEventListener("DOMAttrModified", function(evt){
8328     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8329       return;
8330     }
8331     var tar = evt.target,
8332         name = evt.attrName;
8333     if (name === "path") {
8334       var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
8335       d.setAttributeNS(null, "d", evt.newValue);
8336       tar._path = d;
8337       d = void 0;
8338     }
8339   }, false);
8340   this.addEventListener("DOMNodeInserted", function(evt){
8341     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8342       return; //強制終了させる
8343     }
8344     var tar = evt.target;
8345     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8346       var vlist = [],
8347           ti;
8348       if (tar._values) {
8349         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8350           ti = tav[i];
8351           ti = ti.split(",");
8352           vlist[i] = [+ti[0], +ti[1]];
8353         }
8354         tar._valueList = vlist;
8355       }
8356     }, false);
8357   }, false);
8358   this.addEventListener("beginEvent", function(evt) {
8359     var tar = evt.target,
8360         trans = tar.targetElement.transform;
8361     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8362      *baseValと同じような値に設定。
8363      */
8364     trans.animVal = new SVGTransformList();
8365     if (trans.baseVal.numberOfItems !== 0) {
8366       trans.baseVal.consolidate();
8367       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8368       } else {
8369       trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8370     }
8371     tar._frame = function() {
8372       var _tar = tar,
8373           tpn = _tar._path,
8374           tgsd = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8375           d = tgsd * 0.8,
8376           tg = _tar.getCurrentTime(),
8377           ii;
8378       _tar._activeDur || (d = 0);
8379       if (tgsd === 0) {
8380          tgsd = void 0;
8381          return;
8382       }
8383       if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
8384         var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
8385             p = tpn.getPointAtLength(st),
8386             trans = _tar.targetElement.transform;
8387         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8388         var base = trans.baseVal;
8389         trans.baseVal = trans.animVal;
8390         _tar.targetElement._cacheMatrix = null;
8391         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8392         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8393         _tar.targetElement.dispatchEvent(evtt);
8394         trans.baseVal = base;
8395         evtt = base = trans = st = p = void 0;
8396       } else if (tar._valueList) {
8397         var total = 0, //totalは総距離
8398             st = 0,    //stは現在にいたるまでの距離
8399             tav = tar._valueList,
8400             n = tav.length - 1;
8401         if ((n !== -1) && (d !== 0) && (tg <= d)) {
8402           ii = Math.floor((tg*n) / d);
8403           if (ii === n) { //iiが境い目のときは、n-2を適用
8404             ii -= 1;
8405           }
8406         } else {
8407           return;
8408         }
8409         for (var i=1, tvli=tav.length;i<tvli;i+=2) {
8410           total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8411         }
8412         for (var i=1;i<ii;i+=2) {
8413           st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8414         }
8415         var p = tar.ownerDocument.documentElement.createSVGPoint(),
8416             trans = _tar.targetElement.transform;
8417         st = (st / total) * d;
8418         p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
8419         p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
8420         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8421         var base = trans.baseVal;
8422         trans.baseVal = trans.animVal;
8423         _tar.targetElement._cacheMatrix = void 0;
8424         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8425         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8426         _tar.targetElement.dispatchEvent(evtt);
8427         trans.baseVal = base;
8428         evtt = base = trans = st = p = i = void 0;
8429       }
8430     }
8431     evt = trans = tpn = tgsd = void 0;
8432   }, false);
8433   this.addEventListener("endEvent", function(evt) {
8434     var tar = evt.target,
8435         trans = tar.targetElement.transform,
8436         fill = tar.getAttributeNS(null, "fill"),
8437         tavli = tar._valueList,
8438         tb;
8439     if (!fill || (fill === "remove")) {
8440       /*アニメが開始される前の状態に戻す*/
8441       var evtt = tar.ownerDocument._domnodeEvent();
8442       tar.targetElement.dispatchEvent(evtt);
8443       tar._frame && tar._frame();
8444     } else {
8445       /*_frame関数で終了位置に会わないことがあるので、以下の処理で位置を修正*/
8446       trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(tavli[tavli.length-1][0], tavli[tavli.length-1][1]);
8447       tb = trans.baseVal;
8448       trans.baseVal = trans.animVal;
8449       var evtt = tar.ownerDocument._domnodeEvent();
8450       tar.targetElement.dispatchEvent(evtt);
8451       trans.baseVal = tb;      
8452     }
8453     delete tar._frame;
8454     evt = evtt = trans = fill = tar = tavli = tb = void 0;
8455   }, false);
8456   this.addEventListener("repeatEvent", function(evt) {
8457     var tar = evt.target;
8458   }, false);
8459   return this;
8460 };
8461 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
8462
8463 function SVGMPathElement() /* : 
8464                 SVGElement,
8465                 SVGURIReference,
8466                 SVGExternalResourcesRequired*/ {
8467   SVGElement.apply(this);
8468   SVGURIReference.apply(this);
8469   return this;
8470 };
8471 SVGMPathElement.prototype = new SVGElement();
8472
8473 function SVGAnimateColorElement() {
8474   SVGAnimationElement.apply(this);
8475   NAIBU.Clip[NAIBU.Clip.length] = this;
8476   this._valueList = [];
8477   this.addEventListener("DOMNodeInserted", function(evt){
8478     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8479       return; //強制終了させる
8480     }
8481     var tar = evt.target;
8482     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8483       var tar = evt.target,
8484           attrName = tar.getAttributeNS(null, "attributeName"),
8485           ttr = tar.targetElement,
8486           fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8487           css, n;
8488       if (!tar._values[0]) {
8489         tar._values[0] = fstyle.getPropertyValue(attrName);
8490       }
8491       for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8492         var to = new SVGColor();
8493         if (tar._values[i] === "currentColor") {
8494           to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8495         } else if (tar._values[i] === "inherit") {
8496           /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8497           css = fstyle.getPropertyCSSValue(attrName);
8498           n = css.cssValueType;
8499           css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8500           to = fstyle.getPropertyCSSValue(attrName);
8501           css.cssValueType = n;
8502         } else {
8503           to.setRGBColor(tar._values[i]);
8504         }
8505         tar._valueList[tar._valueList.length] = to;
8506         to = void 0;
8507       }
8508       tar = ttr = fstyle = css = n = attrName = void 0;
8509     }, false);
8510   }, false);
8511   this.addEventListener("beginEvent", function(evt) {
8512     var tar = evt.target,
8513         attrName = tar.getAttributeNS(null, "attributeName"),
8514         style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8515         fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8516     tar._frame = function() {
8517       var _tar = tar;
8518       /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8519        * 3.4.2 Specifying the simple animation function f(t)
8520        *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8521        */
8522       var d = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8523           n = _tar._valueList.length - 1,
8524           tg = _tar.getCurrentTime(),
8525           ii, di, ti;
8526       _tar._activeDur || (d = 0);
8527       d *= 0.8;
8528       if ((n !== -1) && (d !== 0) && (tg <= d)) {
8529         ii = Math.floor((tg*n) / d);
8530         if (ii === n) { //iiが境い目のときは、n-2を適用
8531           ii -= 1;
8532         }
8533       } else {
8534         return;
8535       }
8536       if (tar._keyTimes) {
8537         di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8538         ti = tar._keyTimes[ii];
8539       } else {
8540         di = d / n; //keyTimesがなければ均等に時間を配分しておく
8541         ti = ii / n;
8542       }
8543       var fc = _tar._valueList[ii].rgbColor,
8544           tc = _tar._valueList[ii+1].rgbColor,
8545           durd = (tg-ti*d) / di,
8546           num = CSSPrimitiveValue.CSS_NUMBER,
8547           fr = fc.red.getFloatValue(num),
8548           fg = fc.green.getFloatValue(num),
8549           fb = fc.blue.getFloatValue(num),
8550           r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8551           g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8552           b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8553       style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8554       _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = ii = void 0;
8555     };
8556     tar._frame();
8557   }, false);
8558   this.addEventListener("endEvent", function(evt) {
8559     var tar = evt.target,
8560         fill = tar.getAttributeNS(null, "fill");
8561     if (!fill || (fill === "remove")) {
8562       var evtt = tar.ownerDocument._domnodeEvent();
8563       tar.targetElement.dispatchEvent(evtt);
8564       tar._frame && tar._frame();
8565     }
8566     delete tar._frame;
8567     evt = evtt = tar = fill = void 0;
8568   }, false);
8569   this.addEventListener("repeatEvent", function(evt) {
8570     var tar = evt.target;
8571   }, false);
8572   return this;
8573 };
8574 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8575
8576 function SVGAnimateTransformElement() {
8577   SVGAnimationElement.apply(this);
8578   NAIBU.Clip[NAIBU.Clip.length] = this;
8579   this.addEventListener("beginEvent", function(evt) {
8580     var tar = evt.target, trans = tar.targetElement.transform;
8581     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8582      *baseValと同じような値に設定。
8583      */
8584     trans.animVal = new SVGTransformList();
8585     if (trans.baseVal.numberOfItems !== 0) {
8586       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8587     }
8588     trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8589   }, false);
8590   this.addEventListener("endEvent", function(evt) {
8591     var tar = evt.target,
8592         fill = tar.getAttributeNS(null, "fill");
8593     if (!fill || (fill === "remove")) {
8594       var evtt = tar.ownerDocument._domnodeEvent();
8595       tar.targetElement.dispatchEvent(evtt);
8596       tar._frame && tar._frame();
8597     }
8598     delete tar._frame;
8599     evt = evtt = tar = fill = void 0;
8600   }, false);
8601   this.addEventListener("repeatEvent", function(evt) {
8602     var tar = evt.target;
8603   }, false);
8604   return this;
8605 };
8606 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8607
8608 function SVGFontElement() /*: 
8609                 SVGElement,
8610                 SVGExternalResourcesRequired,
8611                 SVGStylable*/ {
8612   SVGElement.apply(this);
8613   /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8614   /*boolean or number*/ this._isExternal = 0;
8615   this.addEventListener("DOMNodeInserted", function(evt){
8616     var tar = evt.target;
8617     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8618       return;
8619     }
8620     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8621       var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8622       var nefunc = function(evt){
8623         var svg = evt.target;
8624         /*以下のtarはfont要素*/
8625         var familyName = fontFace.getAttributeNS(null, "font-family");
8626         var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8627         for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8628           var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8629           if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8630             NAIBU._noie_createFont(ti, _tar, true);
8631           }
8632         }
8633         evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8634       };
8635       if (!fontFace.__isLinked || tar._isExternal) {
8636         tar.ownerDocument.documentElement._svgload_limited = 0;
8637         tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8638       }
8639     }, false);
8640   }, false);
8641   return this;
8642 };
8643 SVGFontElement.prototype = new SVGElement();
8644
8645 function SVGGlyphElement() /*: 
8646                 SVGElement,
8647                 SVGStylable*/ {
8648   SVGElement.apply(this);
8649   return this;
8650 };
8651 SVGGlyphElement.prototype = new SVGElement();
8652
8653 function SVGMissingGlyphElement() /*: 
8654                 SVGElement,
8655                 SVGStylable*/ {
8656   SVGElement.apply(this);
8657   return this;
8658 };
8659 SVGMissingGlyphElement.prototype = new SVGElement();
8660
8661 function SVGHKernElement() {
8662   SVGElement.apply(this);
8663   return this;
8664 };
8665 SVGHKernElement.prototype = new SVGElement();
8666
8667 function SVGVKernElement() {
8668   SVGElement.apply(this);
8669   return this;
8670 };
8671 SVGVKernElement.prototype = new SVGElement();
8672
8673 function SVGFontFaceElement() {
8674   SVGElement.apply(this);
8675   /*boolean(or number)*/ this._isLinked = 0;
8676   this.addEventListener("DOMNodeInserted", function(evt){
8677     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8678       if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8679         evt.currentTarget._isLinked = 1;
8680       }
8681       return; //強制終了させる
8682     }
8683   }, false);
8684   return this;
8685 };
8686 SVGFontFaceElement.prototype = new SVGElement();
8687
8688 function SVGFontFaceSrcElement() {
8689   SVGElement.apply(this);
8690   return this;
8691 };
8692 SVGFontFaceSrcElement.prototype = new SVGElement();
8693
8694 function SVGFontFaceUriElement() {
8695   SVGElement.apply(this);
8696   this.addEventListener("DOMNodeInserted", function(evt){
8697     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8698       return; //強制終了させる
8699     }
8700     evt.target.ownerDocument.documentElement._svgload_limited--
8701     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8702   }, false);
8703   this.addEventListener("S_Load", function(evt){
8704     var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8705     if (tpp.localName === "defs") {
8706       tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8707     }
8708     tar._instance._isExternal = 1;
8709     tpp.parentNode.appendChild(tar._instance);
8710     evt = tar = tpp = void 0;
8711   }, false);
8712   SVGURIReference.apply(this);
8713   return this;
8714 };
8715 SVGFontFaceUriElement.prototype = new SVGElement();
8716
8717 function SVGFontFaceFormatElement() {
8718   SVGElement.apply(this);
8719   return this;
8720 };
8721 SVGFontFaceFormatElement.prototype = new SVGElement();
8722
8723 function SVGFontFaceNameElement() {
8724   SVGElement.apply(this);
8725   return this;
8726 };
8727 SVGFontFaceNameElement.prototype = new SVGElement();
8728
8729 function SVGDefinitionSrcElement() {
8730   SVGElement.apply(this);
8731   return this;
8732 };
8733 SVGDefinitionSrcElement.prototype = new SVGElement();
8734
8735 function SVGMetadataElement() {
8736   SVGElement.apply(this);
8737   return this;
8738 };
8739 SVGMetadataElement.prototype = new SVGElement();
8740
8741 function SVGForeignObjectElement() /*: 
8742                 SVGElement,
8743                 SVGTests,
8744                 SVGLangSpace,
8745                 SVGExternalResourcesRequired,
8746                 SVGStylable,
8747                 SVGTransformable,
8748                 events::EventTarget*/ { 
8749   SVGElement.apply(this);
8750   var sl = SVGAnimatedLength;
8751   /*readonly SVGAnimatedLength*/ this.x = new sl();
8752   /*readonly SVGAnimatedLength*/ this.y = new sl();
8753   /*readonly SVGAnimatedLength*/ this.width = new sl();
8754   /*readonly SVGAnimatedLength*/ this.height = new sl();
8755   sl = void 0;
8756   return this;
8757 };
8758 SVGForeignObjectElement.prototype = new SVGElement();
8759
8760 //#endif  _SVG_IDL_
8761 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8762  *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8763  *SIEでは軽量化のために、マッピングを用いた
8764  */
8765 DOMImplementation["http://www.w3.org/2000/svg"] = {
8766   Document:        SVGDocument,
8767   svg:             SVGSVGElement,
8768   g:               SVGGElement,
8769   path:            NAIBU.SVGPathElement,
8770   title:           SVGTitleElement,
8771   desc:            SVGDescElement,
8772   defs:            SVGDefsElement,
8773   linearGradient:  SVGLinearGradientElement,
8774   radialGradient:  SVGRadialGradientElement,
8775   stop:            SVGStopElement,
8776   rect:            SVGRectElement,
8777   circle:          SVGCircleElement,
8778   ellipse:         SVGEllipseElement,
8779   polyline:        SVGPolylineElement,
8780   polygon:         SVGPolygonElement,
8781   text:            SVGTextElement,
8782   tspan:           SVGTSpanElement,
8783   image:           SVGImageElement,
8784   line:            SVGLineElement,
8785   a:               SVGAElement,
8786   altGlyphDef:     SVGAltGlyphDefElement,
8787   altGlyph:        SVGAltGlyphElement,
8788   altGlyphItem:    SVGAltGlyphItemElement,
8789   animateColor:    SVGAnimateColorElement,
8790   animate:         SVGAnimateElement,
8791   animateMotion:   SVGAnimateMotionElement,
8792   animateTransform:SVGAnimateTransformElement,
8793   clipPath:        SVGClipPathElement,
8794   colorProfile:    SVGColorProfileElement,
8795   cursor:          SVGCursorElement,
8796   definitionSrc:   SVGDefinitionSrcElement,
8797   feBlend:         SVGFEBlendElement,
8798   feGaussianBlur:  SVGFEGaussianBlurElement,
8799   filter:          SVGFilterElement,
8800   font:            SVGFontElement,
8801   "font-face":     SVGFontFaceElement,
8802   "font-face-format":SVGFontFaceFormatElement,
8803   "font-face-name":SVGFontFaceNameElement,
8804   "font-face-src": SVGFontFaceSrcElement,
8805   "font-face-uri": SVGFontFaceUriElement,
8806   foreignObject:   SVGForeignObjectElement,
8807   glyph:           SVGGlyphElement,
8808   glyphRef:        SVGGlyphRefElement,
8809   hkern:           SVGHKernElement,
8810   marker:          SVGMarkerElement,
8811   mask:            SVGMaskElement,
8812   metadata:        SVGMetadataElement,
8813   missingGlyph:    SVGMissingGlyphElement,
8814   mpath:           SVGMPathElement,
8815   script:          SVGScriptElement,
8816   set:             SVGSetElement,
8817   style:           SVGStyleElement,
8818   "switch":        SVGSwitchElement,
8819   "symbol":        SVGSymbolElement,
8820   textPath:        SVGTextPathElement,
8821   tref:            SVGTRefElement,
8822   use:             SVGUseElement,
8823   view:            SVGViewElement,
8824   vkern:           SVGVKernElement,
8825   pattern:         SVGPatternElement
8826 };
8827
8828 NAIBU._fontSearchURI = function(evt){
8829   var doc = evt.target.ownerDocument;
8830   var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8831   for (var i=0;i<tsrc.length;++i) {
8832     var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8833         ids = src.split(":")[1],
8834         xmlhttp = NAIBU.xmlhttp;
8835     xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8836     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8837     xmlhttp.onreadystatechange = function() {
8838       if ((xmlhttp.readyState === 4)  &&  (xmlhttp.status === 200)) {
8839         var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8840         NAIBU._font({document:doce, docu:doc, id:ids});
8841         xmlhttp = doc = doce = void 0;
8842       }
8843     };
8844     xmlhttp.send(null);
8845   }
8846 };
8847 /*_font関数は、SVGFontで使う*/
8848 NAIBU._font = function (data) {
8849   var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8850   //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8851   var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8852   var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8853   if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8854     var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8855     for (var i=0,tli=textElements.length;i<tli;++i) {
8856       var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8857       if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8858         NAIBU._noie_createFont(ti, font, false);
8859       }
8860     }
8861   }
8862   doc = data = void 0;
8863 };
8864 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8865   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8866       svgns = "http://www.w3.org/2000/svg",
8867       //isTategakiは縦書きならば真
8868       isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8869       horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8870       node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8871       em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8872       advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8873       dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8874       dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8875       fontSize = parseFloat(style.getPropertyValue("font-size")),
8876       fe = fontSize / em,
8877       ds = false, npdlist = ["fill",
8878   "fill-opacity",
8879   "stroke",
8880   "stroke-width",
8881   "stroke-linecap",
8882   "stroke-linejoin",
8883   "stroke-miterlimit",
8884   "stroke-dasharray",
8885   "stroke-opacity",
8886   "opacity",
8887   "cursor"];
8888   if (/a/[-1] === 'a') { //Firefoxならば
8889     ds = true;
8890   } else if (isMSIE || isTategaki) {
8891     ds = true;
8892   }
8893   if (ds){
8894      while(node) {
8895       if (!glyphs) {
8896         break;
8897       }
8898       data = node.data;
8899       if (data !== void 0) { //dataがある場合
8900         var advanceX = [], glyphData = [];
8901         for (var i=0,gli=glyphs.length;i<gli;++i) {
8902           var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8903           var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8904           if (orientation) {
8905             if (orientation === "h") {
8906               isVert = false;
8907             }
8908           } else {
8909             isOrientationAttribute = false;
8910           }
8911           if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8912             //indexは該当する文字が何番目にあるかの数字
8913             var index = data.indexOf(unicode);
8914             while (index > -1) {
8915               advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8916               glyphData[index] = glyph.getAttributeNS(null, "d");
8917               index = data.indexOf(unicode, index+1);
8918             }
8919           }
8920         }
8921         for (var i=0,adv=0;i<data.length;++i) {
8922           if (advanceX[i] !== void 0) { //配列に含まれていれば
8923             var path = ti.ownerDocument.createElementNS(svgns, "path");
8924             //advance、すなわち字幅の長さ分、ずらしていく
8925             var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8926             matrix.a = fe;
8927             matrix.d = -fe;
8928             for (var j=0;j<npdlist.length;++j){
8929               var nj = npdlist[j],
8930                   tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
8931               if (nj === "stroke-width") {
8932                 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
8933                 tg += "";
8934               }
8935               if (tg) {
8936                 path.setAttributeNS(null, nj, tg);
8937               }
8938             }
8939             if (isTategaki) {
8940               var y= dy + adv*fe, x = dx;
8941               if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8942                 var fms = fontSize / Math.SQRT2;
8943                 x += fms;
8944                 y -= fms;
8945                 fms = void 0;
8946               }
8947               matrix.e = x;
8948               matrix.f = y;
8949             } else {
8950               matrix.e = dx + adv*fe;
8951               matrix.f = dy;
8952             }
8953             path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8954             path.setAttributeNS(null, "d", glyphData[i]);
8955             ti.parentNode.insertBefore(path, ti);
8956             adv += advanceX[i];
8957             matrix = void 0;
8958           }
8959         }
8960         adv = advanceX = glyphData = void 0;
8961       } else if ("tspan|a".indexOf(node.localName) > -1){
8962         NAIBU._noie_createFont(node, font, isMSIE);
8963       }
8964       node = node.nextSibling;
8965     }
8966     if (isMSIE) {
8967       var style = ti.ownerDocument.getOverrideStyle(ti, null);
8968       style.setProperty("visibility", "hidden");
8969       style = void 0;
8970     } else {
8971       ti.setAttributeNS(null, "opacity", "0");
8972     }
8973   }
8974   data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8975 };
8976
8977 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8978  *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8979  */
8980 (function(){
8981   var s = new CSSStyleDeclaration(),
8982        slis = s._list,
8983       n = 0,
8984       regAZ = /([A-Z])/,
8985       regm = /\-/,
8986       u, t;
8987   for (var i in CSS2Properties) {
8988     if(CSS2Properties.hasOwnProperty(i)) {
8989       t = i.replace(regAZ, "-");
8990       if (!!RegExp.$1) {
8991         u = "-" +RegExp.$1.toLowerCase();
8992       } else {
8993         u = "-";
8994       }
8995       t = t.replace(regm, u);
8996       s.setProperty(t, CSS2Properties[i]);
8997       slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8998       slis[n]._isDefault = 1;
8999       ++n;
9000       i = t = u =  void 0;
9001     }
9002   }
9003   slis._opacity = 1;
9004   slis._fontSize = 12;
9005   CSS2Properties._list = slis;
9006   Document.prototype.defaultView._defaultCSS = slis;
9007   s = n = regAZ = regm = slis =null;
9008 })();
9009
9010 NAIBU.addEvent = function(evt,lis){
9011   if (window.addEventListener) {
9012     window.addEventListener(evt, lis, false);
9013   } else if (window.attachEvent) {
9014     window.attachEvent('on'+evt, lis);
9015   } else {
9016     window['on'+evt] = lis;
9017   }
9018   //Sieb用
9019   if (sieb_s) {
9020     lis();
9021   }
9022 };
9023
9024 function unsvgtovml() {
9025   try {
9026     if ("stop" in NAIBU) {
9027       clearInterval(NAIBU.stop);
9028     }
9029     window.onscroll = NAIBU.emptyFunction;
9030     window.detachEvent("onload", NAIBU._main);
9031     NAIBU.freeArg();
9032     Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
9033     Array = ActiveXObject = void 0;
9034   } catch(e) {}
9035 }
9036 /*_main関数
9037  *一番最初に起動するべき関数 
9038  */
9039 NAIBU._main = (function() {
9040   stlog = new STLog(false);
9041   var xmlhttp,         //XMLHttpオブジェクトを生成
9042       _doc = document; //documentのエイリアスを作成
9043   try {
9044     if (XMLHttpRequest) {
9045       xmlhttp = false;
9046     } else {
9047       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
9048     }
9049   } catch (e) {
9050     try {
9051       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
9052     } catch (E) {
9053       xmlhttp = false;
9054     }
9055   }
9056   if (!xmlhttp) {
9057     try {
9058       xmlhttp = new XMLHttpRequest();
9059     } catch (e) {
9060       xmlhttp = false;
9061     }
9062   }
9063   NAIBU.xmlhttp = xmlhttp;
9064   var nd;
9065   if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
9066     try {
9067       NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
9068     } catch (e) {
9069       
9070     }
9071     nd = NAIBU.doc;
9072     _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
9073     _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
9074     var st = _doc.createStyleSheet(),
9075         vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
9076     st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
9077       + "dn\\:defs{display:none}"
9078       + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
9079       + "v\\:shape{width:100%;height:100%;" +vmlUrl;
9080   }
9081   var ary = _doc.getElementsByTagName("script");
9082   //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
9083   for (var i=0; ary[i]; ++i) {
9084     var ai = ary[i],
9085         hoge = ai.type;
9086     if (ai.type === "image/svg+xml") {
9087       var ait = ai.text;
9088       if (sieb_s && ait.match(/&lt;svg/)) {
9089         //ソース内のタグを除去
9090         ait = ait.replace(/<.+?>/g, "");
9091         //エンティティを文字に戻す
9092         ait = ait.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
9093       }
9094       if (NAIBU.isMSIE) {
9095         var gsd = new GetSVGDocument(ai);
9096         gsd.xmlhttp = {
9097           readyState : 4,
9098           status : 200,
9099           responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
9100         }
9101         gsd._ca();
9102       } else {
9103         var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
9104         ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
9105         var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
9106         ai.parentNode.insertBefore(s,ai);
9107       }
9108       ai = ait = void 0;
9109     }
9110     hoge = void 0;
9111   }
9112   NAIBU.doc = nd;
9113   nd = ary = void 0;
9114   if (xmlhttp && NAIBU.isMSIE) {
9115     if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
9116     } else { //IE6-8ならば
9117       var ob = _doc.getElementsByTagName("object"),
9118           em = _doc.getElementsByTagName("embed"),
9119           img = _doc.getElementsByTagName("img"),
9120           s=[],
9121           t = [],
9122           _search = function(_ob) {
9123             var ifr, obi, n,
9124                 w = "width",
9125                 h = "height";
9126             s || (s = []);             //NAIBU._searchで呼ばれたときに必要
9127             _doc || (_doc = document);
9128             for (var i=0;_ob[i];++i) {
9129               obi = _ob[i];
9130               s[s.length] = new GetSVGDocument(obi);
9131               ifr = _doc.createElement("iframe");
9132               ifr.style.cssText = obi.style.cssText;
9133               ifr.style.background = "black";
9134               n = obi.getAttribute(w);
9135               n && ifr.setAttribute(w, n);
9136               n = obi.getAttribute(h);
9137               n && ifr.setAttribute(h, n);
9138               ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
9139               ifr.scrolling = "no";
9140               ifr.frameBorder = "0";
9141              /*iframe要素を使って、描画のプロセスを分離する
9142               *したがって、_docはdocumentとは別のオブジェクトとなる
9143               */
9144               obi.parentNode.insertBefore(ifr, obi);
9145             }
9146             i = obi = ifr = _ob = w = h = void 0;
9147             return s[s.length-1];
9148           };
9149       _search(ob);
9150       _search(em);
9151       for (var i=0,j=0;img[i];++i) {
9152         /*img要素の処理*/
9153         if (img[i].getAttribute("src").indexOf(".svg") > -1) { //拡張子があればSVG画像と判断
9154           t[j] = img[i];
9155           ++j;
9156         }
9157       }
9158       _search(t);
9159       NAIBU._search = _search; //a要素がクリックされたときに使う関数
9160       ob = em = t = img = _search = void 0;
9161       for (var i=0;i<s.length;++i) {
9162         /*あとで変数iが使われるために、次の条件分岐が必要*/
9163         if (i < s.length-1) {
9164           s[i]._next = s[i+1]
9165         }
9166       }
9167       if (i > 0) {
9168         s[0]._init(); //初期化作業を開始
9169       }
9170       s = void 0;
9171     }
9172   } else {
9173     var ob = _doc.getElementsByTagName("object");
9174     for (var i=0;i<ob.length;++i) {
9175       if (ob[i].contentDocument) {
9176         NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
9177       } else if (ob[i].getSVGDocument) {
9178         ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
9179       } else {
9180       }
9181     }
9182   }
9183   xmlhttp = _doc = void 0;
9184 });
9185 NAIBU.addEvent("load", NAIBU._main);
9186 NAIBU.utf16 = function ( /*string*/ s)  {
9187   return unescape(s);
9188 }
9189 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
9190   return s.replace(/%u\w\w\w\w/g,  NAIBU.utf16);
9191 }
9192 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
9193 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
9194   /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
9195    *dataスキーム方式を採用する
9196    */
9197   if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
9198     var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
9199     var ob = document.createElement("object");
9200     ob.setAttribute("data",data);
9201     ob.setAttribute("width",w);
9202     ob.setAttribute("height",h);
9203     ob.setAttribute("type","image/svg+xml");
9204     return ob;
9205   } else {
9206     var doc = (new DOMParser()).parseFromString(source, "text/xml");
9207     return (document.importNode(doc.documentElement, true));
9208   }
9209 };
9210 NAIBU.addEvent("unload", unsvgtovml);
9211 //IEならばtrue
9212 NAIBU.isMSIE = /*@cc_on!@*/false;