OSDN Git Service

モジュールを統合
[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         n++;
526       }
527       var d = tnoi.getElementsByTagNameNS(namespaceURI, localName);
528       if (d) {
529         for (var j=0,dli=d.length;j<dli;++j) {
530           s[s.length] = d[j];
531         }
532         n += d.length;
533       }
534       ns = ln = d = void 0;
535     }
536   }
537   tno = i = j = tcli = dli = void 0;
538   if (n === 0) {
539     return null; //該当する要素なし
540   }
541   return s;
542 };
543 /*boolean*/ Element.prototype.hasAttribute = function( /*string*/ name) {
544   return (this.hasAttributeNS("http://www.w3.org/2000/svg", 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 EventException.constructor = DOMException;
974
975
976 /*  // Introduced in DOM Level 2:
977   interface EventTarget {*/
978 /*void*/  Node.prototype.addEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
979   this.removeEventListener(type, listener, useCapture);  //いったん、(あれば)リスナーを離す。
980   var s = new EventListener(useCapture, type, listener), //リスナーを作成
981       t = type.charAt(0),
982       that;
983   this._capter.push(s);                 //このノードにリスナーを登録しておく
984   if ((t !== "D") && (t !== "S") && (type !== "beginEvent") && (type !== "endEvent") && (type !== "repeatEvent")) { //MouseEventsならば
985     that = this;
986     that._tar && that._tar.attachEvent("on" +type, (function(node, type) { 
987       return  function(){
988         var evt = node.ownerDocument.createEvent("MouseEvents");
989         evt.initMouseEvent(type, true, true, node.ownerDocument.defaultView, 0);
990         node.dispatchEvent(evt);
991         /*cancelBubbleプロパティについては、IEのMSDNなどを参照*/
992         node.ownerDocument._window.event.cancelBubble = true;
993         evt = void 0;
994       };
995     })(that, type)
996     );
997   }
998   type = listener = useCapture = s = t = that = void 0;
999 };
1000 /*void*/  Node.prototype.removeEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
1001   var tce = this._capter;
1002   for (var i=0,tcli=tce.length;i<tcli;i++){
1003     if (tce[i]._listener === listener) {  //登録したリスナーと一致すれば
1004       tce[i] = void 0;
1005     }
1006   }
1007   i = tcli = tce = void 0;
1008 };
1009 /*boolean*/  Node.prototype.dispatchEvent = function( /*Event*/ evt) {
1010   if (!evt.type) { //Eventの型が設定されていないとき
1011     throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
1012   }
1013   var te = this,
1014       td = te.ownerDocument,
1015       etime = evt.timeStamp,
1016       etype = evt.type,
1017       ebub = evt.bubbles,
1018       tob,
1019       toli,
1020       type = /*Event.CAPTURING_PHASE*/ 1,
1021       ecptype = /*Event.CAPTURING_PHASE*/ "1",
1022       ebptype = /*Event.BUBBLING_PHASE*/ "3",
1023       tce;
1024   if (!td._isLoaded) {
1025     /*以下では、画像の処理に時間がかかりそうな場合、処理落ちとして、遅延処理
1026      *を行い、バッファリングにイベント送付処理をためていく作業となる
1027      */
1028     if (!td._limit_time_) {
1029       td._limit_time_ = etime;
1030     } else if ((etime - td._limit_time_) > 1000) {
1031       /*1秒を超えたらバッファにため込んで後で使う*/
1032       tob = td.implementation._buffer_ || [];
1033       toli = tob.length
1034       tob[toli] = this;
1035       tob[toli+1] = evt;
1036       td.implementation._buffer_ = tob;
1037       te = td = etime = etype = ebub = tob = toli = type = void 0;
1038       return true;
1039     }
1040   }
1041   evt.target = te;
1042   evt.eventPhase = 1;//Event.CAPTURING_PHASE
1043   //このノードからドキュメントノードにいたるまでの、DOMツリーのリストを作成しておく
1044   td[ebptype] = null;
1045   /*以下の処理では、documentElementのparentNodeが
1046    *Documentノードではなく、nullになっていることを前提としている。
1047    *したがって、documentElementのparentNodeがもし、Documentノードのオブジェクトならば、以下を書き換えるべきである
1048    */
1049   while (te.parentNode) {
1050     te.parentNode[ecptype] = te;
1051     te[ebptype] = te.parentNode;
1052     te = te.parentNode;
1053   }
1054   td[ecptype] = te;
1055   te[ebptype] = td;
1056   /*最初に捕獲フェーズでDOMツリーを下っていき、イベントのターゲットについたら、
1057    *そこで、浮上フェーズとして折り返すように、反復処理をおこなう。
1058    */
1059   te = this;
1060   while (td) {
1061     evt.currentTarget = td;
1062     if (td === te) { //イベントのターゲットに到着(折り返し地点)
1063       type = 2;//Event.AT_TARGET;
1064     }
1065     evt.eventPhase = type;
1066     tce = td._capter; //tceは登録しておいたリスナーのリスト
1067     for (var j=0,tcli=tce.length;j<tcli;++j){
1068       if (tce[j] && (etype === tce[j]._type)) {
1069         tce[j].handleEvent(evt);
1070       }
1071     }
1072     if (evt._stop) {
1073       break; //stopPropagationメソッドが呼ばれたら、停止する
1074     }
1075     if (td === te) {
1076       if (!ebub) {
1077         break; //浮上フェーズに移行せず、停止する
1078       }
1079       type = 3;//Event.BUBBLING_PHASE;
1080     }
1081     td = td[type];
1082   }
1083   var ed = evt._default;
1084   evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub = ecptype = ebptype = void 0;
1085   return ed;
1086 };
1087
1088 function EventListener(cap,type,listener) {
1089   this._cap = cap;
1090   this._type = type;
1091   this._listener = listener;
1092   return this;
1093 };
1094
1095 EventListener.prototype = {
1096 /*void*/ handleEvent : function( /*Event*/ evt) {
1097     try {
1098       var ph = evt.eventPhase,
1099           cap = this._cap;
1100       if (ph === /*Event.CAPTURING_PHASE*/ 1) { //イベントフェーズが捕獲段階であることを示し
1101         cap = cap ? false : true;         //このオブジェクト(EventListenr)が捕獲フェーズを指定するならば、リスナーを作動させる。指定しなければ、作動しない。
1102       }
1103       if (!cap && (evt.type === this._type)) {
1104         this._listener(evt);
1105       }
1106       evt = ph = cap = void 0;
1107     } catch (e) {
1108       
1109     }
1110   }
1111 };
1112
1113 /*Eventクラス
1114  *イベントの雛形となる。プロパティもすべて含めて、必須
1115  */
1116 function Event() {
1117   return this;
1118 };
1119 // PhaseType
1120 /*unsigned short*/ Event.CAPTURING_PHASE   = 1;
1121 /*unsigned short*/ Event.AT_TARGET         = 2;
1122 /*unsigned short*/ Event.BUBBLING_PHASE    = 3;
1123 Event.prototype = {
1124   /*DOMTimeStamp*/     timeStamp : 0,
1125   /*DOMString*/        type : null,
1126   /*EventTarget*/      target : null,
1127   /*EventTarget*/      currentTarget : null,
1128   /*unsigned short*/   eventPhase : Event.CAPTURING_PHASE,
1129   /*boolean*/          bubbles : false,
1130   /*boolean*/          cancelable : false,
1131   _stop : false, //stopPropagationメソッドで使う
1132   _default : true, //preventDefaultメソッドで使う
1133   /*void*/ stopPropagation : function(){
1134     this._stop = true;
1135   },
1136   /*void*/ preventDefault : function(){
1137     if (this.cancelable) {
1138       this._default = false;
1139       /*IEのみで使えるreturnValueプロパティ*/
1140       this.target.ownerDocument._window.event.returnValue = false;
1141     }
1142   },
1143   /*void*/ initEvent : function( /*string*/ eventTypeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg) {
1144     this.type = eventTypeArg;
1145     this.bubbles = canBubbleArg;
1146     this.cancelable = cancelableArg;
1147     eventTypeArg = canBubbleArg = cancelableArg = void 0;
1148   }
1149 };
1150 /*Documentノードに直接結びつける
1151 function DocumentEvent() {
1152   return this;
1153 }*/
1154 /*Event*/ Document.prototype.createEvent = function( /*string*/ eventType) {
1155   var evt,
1156       tc = this._cevent[eventType];
1157   if (tc) {
1158     evt = new tc();
1159   } else if (eventType === "SVGEvents") {
1160     evt = new SVGEvent();
1161   } else if (eventType === "TimeEvents") {
1162     evt = new TimeEvent();
1163   } else {
1164     evt =  new Event();
1165   }
1166   evt.type = eventType;
1167   evt.timeStamp = +(new Date());
1168   eventType = void 0;
1169   return evt;
1170 };
1171
1172 function UIEvent() {
1173 /*views::AbstractView*/  this.view;
1174 /*long*/                 this.detail = 0;
1175   return this;
1176 };
1177
1178 UIEvent.prototype = new Event();
1179 UIEvent.constructor = Event;
1180 /*void*/ UIEvent.prototype.initUIEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg) {
1181   this.initEvent(typeArg, canBubbleArg, cancelableArg);
1182   this.detail = detailArg;
1183   this.view = viewArg;
1184 };
1185 function MouseEvent(evt) {
1186   UIEvent.call(this, arguments);
1187 /*long*/             this.screenX;
1188 /*long*/             this.screenY;
1189 /*long*/             this.clientX = this.clientY = 0;
1190 /*boolean*/          this.ctrlKey = this.shiftKey = this.altKey = this.metaKey = false;
1191 /*unsigned short*/   this.button;
1192 /*EventTarget*/      this.relatedTarget;
1193   return this;
1194 };
1195 MouseEvent.prototype = new UIEvent();
1196 MouseEvent.constructor = UIEvent;
1197 /*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) {
1198   this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
1199   this.screenX = screenXArg;
1200   this.screenY = screenYArg;
1201   this.clientX  = clientXArg;
1202   this.clientY  = clientYArg;
1203   this.ctrlKey  = ctrlKeyArg;
1204   this.shiftKey = shiftKeyArg;
1205   this.altKey   = altKeyArg;
1206   this.metaKey  = metaKeyArg;
1207   this.button = buttonArg;
1208   this.relatedTarget = relatedTargetArg;
1209 };
1210
1211 function MutationEvent(){
1212   return this;
1213 };
1214 MutationEvent.prototype = new Event();
1215 MutationEvent.constructor = Event;
1216 (function() {
1217 /*void*/  this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
1218     /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
1219     /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
1220     this.initEvent(typeArg, canBubbleArg, cancelableArg);
1221     this.relatedNode = relatedNodeArg;
1222     this.prevValue = prevValueArg;
1223     this.newValue = newValueArg;
1224     this.attrName = attrNameArg;
1225     this.attrChange = attrChangeArg;
1226     typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = void 0;
1227   };
1228   /*Node*/  this.relatedNode = null;
1229   /*string*/  this.prevValue = this.newValue = this.attrName = null;
1230   /*unsigned short*/  this.attrChange = 2;
1231 }).apply(MutationEvent.prototype);
1232     // attrChangeType
1233 /*unsigned short*/  MutationEvent.MODIFICATION  = 1;
1234 /*unsigned short*/  MutationEvent.ADDITION      = 2;
1235 /*unsigned short*/  MutationEvent.REMOVAL       = 3;
1236
1237 /*MutationEventsの発動のために、setAttributeNodeNSを上書きする。ファイル統合やmakeの際は、
1238  *重複するのでコアモジュールのメソッドは削除する。モジュールテストを行うために、
1239  *このような形式をとることにする。なお、追加部分には区別を付けるために、前後にコメントを挿入する。
1240  */
1241 /*Attr*/ Element.prototype.setAttributeNodeNS = function( /*Attr*/ newAttr){
1242   if (newAttr.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1243     throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1244   }
1245   var s = this.attributes.setNamedItemNS(newAttr);
1246   newAttr.ownerElement = this;
1247   if (newAttr.localName === "id") {                   //id属性であったならば
1248     this.ownerDocument._id[newAttr.nodeValue] = this; //ドキュメントに登録しておく
1249   }
1250   /*ここから*/
1251   var evt = this.ownerDocument.createEvent("MutationEvents");
1252   if (!s) { //ノードがなければ
1253     /*initMutationEventメソッドは軽量化のため省略する*/
1254     evt.initEvent("DOMAttrModified", true, false);
1255     evt.relatedNode = newAttr;
1256     evt.newValue = newAttr.nodeValue;
1257     evt.attrName = newAttr.nodeName;
1258   } else {
1259     evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
1260   }
1261   this.dispatchEvent(evt); //このとき、MutationEventsが発動
1262   evt = void 0;
1263   /*ここまで追加*/
1264   return s;
1265 };
1266
1267 /*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
1268   var tp = this.parentNode,
1269       rp, evt,
1270       te = this,
1271       s, descend, di;
1272   if (tp) {
1273     while (!tp) {                              //先祖をたどっていく
1274       if (tp === n) {                          //先祖要素が追加ノードならばエラー
1275         throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1276       }
1277       tp = tp.parentNode;
1278     }
1279   }
1280   if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1281     throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1282   }
1283   if (n.parentNode === this) {                  //入力した要素が子要素ならば
1284     this.removeChild(n);
1285   }
1286   if (!ref) {                                   //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1287     this.childNodes[this.childNodes.length] = n;
1288     if (this.lastChild) {
1289       n.previousSibling = this.lastChild;
1290       this.lastChild.nextSibling = n;
1291     }
1292   } else {
1293     if (ref.parentNode !== this) {              //参照ノードが子要素でない場合
1294       throw (new DOMException(DOMException.NOT_FOUND_ERR));
1295     }
1296     this.childNodes.splice(ref._num,1,n,ref);   //Arrayのspliceを利用して、リストにnノードを追加
1297     rp = ref.previousSibling;
1298     if (rp) {
1299       rp.nextSibling = n;
1300     }
1301     ref.previousSibling = n;
1302   }
1303   n.nextSibling = ref;
1304   this.firstChild = this.childNodes[0];
1305   this.lastChild = this.childNodes[this.childNodes.length-1];
1306   n.parentNode = this;
1307   if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1308     /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1309      *それらを直接文書に埋め込む作業を以下で行う
1310      */
1311     var ch = n.childNodes.concat([]); //Arrayのコピー
1312     for (var i=0,chli=ch.length;i<chli;i++) {
1313       this.insertBefore(ch[i], n);
1314     }
1315     ch = void 0;
1316   }
1317   /*ここから*/
1318   evt = this.ownerDocument.createEvent("MutationEvents");
1319   evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1320   n.dispatchEvent(evt);
1321   /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1322    *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1323    *このイベントは浮上しないことに注意を要する
1324    */
1325   do {
1326     s = te;
1327     te = te.parentNode;
1328   } while (te);
1329   if (s !== this.ownerDocument.documentElement) {
1330     evt = s = void 0;
1331     return n;
1332   }
1333   evt = this.ownerDocument.createEvent("MutationEvents");
1334   evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1335   n.dispatchEvent(evt);
1336   if (!n.hasChildNodes()) {                       //子ノードがないので終了
1337     return n;
1338   }
1339   descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1340   if (descend) {
1341     for (var i=0,dli=descend.length;i<dli;++i) {
1342       di = descend[i];
1343       di.dispatchEvent(evt);
1344       di = null;
1345     }
1346   }
1347   evt = descend = void 0;
1348   /*ここまで追加*/
1349   tp = rp = te = s = di = void 0;
1350   return n;
1351 };
1352
1353 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1354   if (!(ele instanceof Node)) {                   //Nodeでなければ
1355     throw (new Error());
1356   }
1357   /*ここから*/
1358   var evt = this.ownerDocument.createEvent("MutationEvents");
1359   /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1360    *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1361    *このイベントは浮上しないことに注意を要する
1362    */
1363   evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1364   ele.dispatchEvent(evt);
1365   var descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1366   if (descend) {
1367     evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1368     for (var i=0,dli=descend.length;i<dli;++i) {
1369       var di = descend[i];
1370       evt.target = di;
1371       di.dispatchEvent(evt);
1372       di = void 0;
1373     }
1374   }
1375   evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1376   ele.dispatchEvent(evt);
1377   evt = descend = void 0;
1378   /*ここまで追加*/
1379   if (ele.parentNode === this) {
1380     this.childNodes.splice(ele._num,1);           //Arrayのspliceを利用して、リストからeleノードを排除
1381   } else {                                        //親が違う場合
1382     throw (new DOMException(DOMException.NOT_FOUND_ERR));
1383   }
1384   if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1385     throw (new Error());
1386   }
1387   return ele;
1388 };
1389
1390 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
1391   var pd = this.data,
1392       evt;
1393   this.data += arg;
1394   this.length = this.data.length;
1395   /*ここから*/
1396   evt = this.ownerDocument.createEvent("MutationEvents");
1397   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1398   this.parentNode.dispatchEvent(evt);
1399   evt = arg = pd = void 0;
1400   /*ここまで追加*/
1401 };
1402 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1403   var pd = this.data,
1404       pre = this.substring(0, offset - 1),                 //文字列を二つに分けた、前半部分
1405       next = this.substring(offset, this.length - offset), //後半部分
1406       evt;
1407   this.data = pre + this.data + next;
1408   this.length = this.data.length;
1409   /*ここから*/
1410   evt = this.ownerDocument.createEvent("MutationEvents");
1411   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1412   this.parentNode.dispatchEvent(evt);
1413   evt = arg = pd = pre = next = void 0;
1414   /*ここまで追加*/
1415 };
1416 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1417   var pd = this.data;
1418       pre = this.substring(0, offset - 1),                    //残すべき前半部分
1419       next = this.substring(offset + count, this.length - 1), //後半部分
1420       evt;
1421   if (offset + count > this.length) {                         //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1422     next = "";
1423   }
1424   this.data = pre + next;
1425   this.length = this.data.length;
1426   /*ここから*/
1427   evt = this.ownerDocument.createEvent("MutationEvents");
1428   evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1429   this.parentNode.dispatchEvent(evt);
1430   evt = pd = void 0;
1431   /*ここまで追加*/
1432 };
1433
1434 /*_ceventプロパティはcreateEventメソッドで軽量化のために使う。*/
1435 Document.prototype._cevent = {
1436     "MutationEvents" : MutationEvent,
1437     "MouseEvents" : MouseEvent,
1438     "UIEvents" : UIEvent
1439 };
1440
1441
1442 // _EVENTS_IDL_
1443 
1444 /*
1445 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1446
1447 #ifndef _STYLESHEETS_IDL_
1448 #define _STYLESHEETS_IDL_
1449
1450 #include "dom.idl"
1451
1452 #pragma prefix "dom.w3c.org"
1453 module stylesheets
1454 {
1455
1456   typedef dom::DOMString DOMString;
1457   typedef dom::Node Node;
1458 */
1459
1460 /*StyleSheet
1461  *スタイルシート文書を示す。削除不可。
1462  */
1463 function StyleSheet() {
1464  this.type = "text/css";
1465  this.disabled = false;
1466  /*Node*/ this.ownerNode = null;
1467  /*StyleSheet*/ this.parentStyleSheet = null;
1468  this.href = null;
1469  this.title = "";
1470  /*MediaList*/ this.media = new MediaList();
1471  return this;
1472 };
1473
1474 /*StyleSheetList
1475  *このインターフェースはArrayで代用する
1476 function StyleSheetList() {
1477     readonly attribute unsigned long    length;
1478     StyleSheet         item(in unsigned long index);
1479   };
1480 */
1481
1482 function MediaList() {
1483  this.mediaText = "";
1484  this.length = 0;
1485  return this;
1486 };
1487 MediaList.prototype = {
1488 /*string*/ item : function(/*long*/ index) {
1489     return (this[index]);
1490   },
1491 /*void*/   deleteMedium : function(/*string*/ oldMedium) {
1492     for (var i=0,tli=this.length;i<tli;++i) {
1493       if (this[i] === oldMedium) {
1494         delete this[i];
1495         --this.length;
1496         return;
1497       }
1498     }
1499     throw (new DOMException(DOMException.NOT_FOUND_ERR));
1500   },
1501 /*void*/   appendMedium : function(/*string*/ newMedium) {
1502     this[this.length] = newMedium;
1503     ++this.length;
1504   }
1505 };
1506
1507 function LinkStyle() {
1508  /*StyleSheet*/ this.sheet = new StyleSheet();
1509  return this;
1510 };
1511
1512 function DocumentStyle() {
1513  /*StyleSheetList*/ this.styleSheets = [];
1514  return this;
1515 };
1516 /*
1517 #endif // _STYLESHEETS_IDL_
1518 */
1519 /*
1520 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1521
1522 #ifndef _CSS_IDL_
1523 #define _CSS_IDL_
1524
1525 #include "dom.idl"
1526 #include "stylesheets.idl"
1527 #include "views.idl"
1528
1529 #pragma prefix "dom.w3c.org"
1530 module css
1531 {
1532
1533   typedef dom::DOMString DOMString;
1534   typedef dom::Element Element;
1535   typedef dom::DOMImplementation DOMImplementation;
1536
1537   interface CSSRule;
1538   interface CSSStyleSheet;
1539   interface CSSStyleDeclaration;
1540   interface CSSValue;
1541   interface Counter;
1542   interface Rect;
1543   interface RGBColor;
1544 */
1545 /*CSSRuleList
1546  *Arrayで代用
1547 function CSSRuleList {
1548     readonly attribute unsigned long    length;
1549     CSSRule            item(in unsigned long index);
1550   };
1551 */
1552 /*CSSRule
1553  *CSSのルールを表現する。基底クラスなので削除不可。
1554  */
1555 function CSSRule() {
1556   this.cssText = "";
1557 /*CSSStyleSheet*/ this.parentStyleSheet;
1558 /*CSSRule*/       this.parentRule = null;
1559   return this;
1560 };
1561 // RuleType
1562 CSSRule.UNKNOWN_RULE                   = 0;
1563 CSSRule.STYLE_RULE                     = 1;
1564 CSSRule.CHARSET_RULE                   = 2;
1565 CSSRule.IMPORT_RULE                    = 3;
1566 CSSRule.MEDIA_RULE                     = 4;
1567 CSSRule.FONT_FACE_RULE                 = 5;
1568 CSSRule.PAGE_RULE                      = 6;
1569
1570 function CSSStyleRule() {
1571   CSSRule.call(this, arguments);
1572   this.type = CSSRule.STYLE_RULE;
1573   this.selectorText = "";
1574 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1575   this.style.parentRule = null;
1576   return this;
1577 };
1578 CSSStyleRule.prototype = new CSSRule();
1579 CSSStyleRule.constructor = CSSRule;
1580
1581 function CSSMediaRule() {
1582   CSSRule.call(this, arguments);
1583   this.type = CSSRule.MEDIA_RULE;
1584 /*stylesheets::MediaList*/ this.media = new MediaList();
1585 /*CSSRuleList*/ this.cssRules = [];
1586   return this;
1587 };
1588 CSSMediaRule.prototype = new CSSRule();
1589 CSSMediaRule.constructor = CSSRule;
1590 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1591   this.cssRules.splice(index,rule,1);
1592   this.media.appendMedium(rule);
1593   return this;
1594 };
1595 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1596 };
1597
1598 function CSSFontFaceRule() {
1599   CSSRule.call(this, arguments);
1600   this.type = CSSRule.FONT_FACE_RULE;
1601 /*CSSStyleDeclaration*/ this.style;
1602   return this;
1603 };
1604 CSSFontFaceRule.prototype = new CSSRule();
1605 CSSFontFaceRule.constructor = CSSRule;
1606
1607 function CSSPageRule() {
1608   CSSRule.call(this, arguments);
1609   this.type = CSSRule.PAGE_RULE;
1610   this.selectorText = "";
1611 /*CSSStyleDeclaration*/ this.style;
1612   return this;
1613 };
1614 CSSPageRule.prototype = new CSSRule();
1615 CSSPageRule.constructor = CSSRule;
1616
1617 function CSSImportRule() {
1618   CSSRule.call(this, arguments);
1619   this.type = CSSRule.IMPORT_RULE;
1620   this.href = "";
1621 /*stylesheets::MediaList*/ this.media = new MediaList();
1622 /*CSSStyleSheet*/ this.styleSheet = null;
1623   return this;
1624 };
1625 CSSImportRule.prototype = new CSSRule();
1626 CSSImportRule.constructor = CSSRule;
1627
1628 function CSSCharsetRule() {
1629   CSSRule.call(this, arguments);
1630   this.type = CSSRule.CHARSET_RULE;
1631   this.encoding = "";
1632   return this;
1633 };
1634 CSSCharsetRule.prototype = new CSSRule();
1635 CSSCharsetRule.constructor = CSSRule;
1636
1637 function CSSUnknownRule() {
1638   CSSRule.call(this, arguments);
1639   this.type = CSSRule.UNKNOWN_RULE;
1640   return this;
1641 };
1642 CSSUnknownRule.prototype = new CSSRule();
1643 CSSUnknownRule.constructor = CSSRule;
1644
1645 /*CSSStyleDeclaration
1646  *CSSの宣言ブロックを表現。削除不可。
1647  */
1648 function CSSStyleDeclaration() {
1649   this._list = []; //内部のリスト
1650   this._list._fontSize = this._list._opacity = null;
1651   return this;
1652 };
1653 CSSStyleDeclaration.prototype = {
1654   cssText : "",
1655   /*long*/ length : 0,
1656   /*CSSRule*/ parentRule : null,
1657   _urlreg : /url\(#([^)]+)/,
1658   /*getPropertyValueメソッド
1659    *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1660    */
1661 /*string*/   getPropertyValue : function( /*string*/ propertyName) {
1662     var tg = this.getPropertyCSSValue(propertyName);
1663     if (tg) {                             //見つかった場合
1664       var tc = tg.cssText;
1665       return (tc.slice(tc.indexOf(":")+1));
1666     } else {
1667       return "";
1668     }
1669   },
1670   /*getPropertyCSSValueメソッド
1671    *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1672    */
1673 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1674     var prop = propertyName,
1675         ti, tc;
1676     propertyName += ":";
1677     if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1678       return null;
1679     }
1680     for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1681       ti = tl[i];
1682       tc = ti.cssText;
1683       if (tc.indexOf(propertyName) > -1) {  //プロパティ名に合致するCSSValueオブジェクトが見つかった場合 
1684         ti._empercents = tl._fontSize;
1685         i = tl = tli = tc = prop = propertyName = void 0;
1686         return ti;
1687       }
1688     }
1689     i = tl = tli = prop = propertyName = void 0;
1690     return null;
1691   },
1692   /*removePropertyメソッド
1693    *プロパティを宣言内から除去
1694    */
1695 /*string*/   removeProperty : function( /*string*/ propertyName) {
1696     var tg = this.getPropertyCSSValue(propertyName);
1697     if (tg) {                        //見つかった場合
1698       this._list.splice(tg._num,1);  //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1699       --this.length;
1700     }
1701   },
1702   /*getPropertyPriorityメソッド
1703    *importantなどのpriorityを取得する
1704    */
1705 /*string*/   getPropertyPriority : function( /*string*/ propertyName) {
1706     var tg = this.getPropertyCSSValue(propertyName);
1707     if (tg) {                        //見つかった場合
1708       return (tg._priority);
1709     } else {
1710       return "";
1711     }
1712   },
1713   _isFillStroke : {
1714     "fill" : 1,
1715     "stroke" : 1
1716   },
1717   _isColor : {
1718     "color" : 1
1719   },
1720   _isStop : {
1721     "stop-color" : 1
1722   },
1723   _isRS : {
1724     "r" : 1,
1725     "#" : 1
1726   },
1727   /*setPropertyメソッド
1728    *プロパティを宣言内で、明示的に設定。継承は無視する
1729    */
1730 /*void*/     setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1731     var cssText = propertyName,
1732         tg = null,
1733         ti, paintType, v1,
1734         uri = null,
1735         color = null,
1736         fill, stroke, stop;
1737     if (!!this[propertyName]) {
1738       tg = this.getPropertyCSSValue(propertyName);
1739     }
1740     cssText += ":";
1741     cssText += value;
1742     if (this._isFillStroke[propertyName]) {
1743       /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1744        *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1745        */
1746       if (tg) {  //見つかった場合
1747         ti = tg;
1748       } else {
1749         ti = new SVGPaint();
1750       }
1751       paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1752       v1 = value.charAt(0);
1753       if (this._isRS[v1] || ti._keywords[value]) {
1754         paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1755         color = value;
1756       } else if (value === "none") {
1757         paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1758       } else if (this._urlreg.test(value)) {                   //fill属性の値がurl(#id)ならば
1759         paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1760         uri = RegExp.$1;
1761       } else if (value === "currentColor") {
1762         paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1763       }
1764       ti.setPaint(paintType, uri, color, null);
1765       paintType = v1 = uri = color = void 0;
1766     } else if (this._isStop[propertyName]) {
1767       if (tg) {  //見つかった場合
1768         ti = tg;
1769       } else {
1770         ti = new SVGColor();
1771       }
1772       if (value === "currentColor") {
1773         ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1774       } else {
1775         ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1776       }
1777       ti.setRGBColor(value);
1778     } else {
1779       if (tg) {  //見つかった場合
1780         ti = tg;
1781       } else {
1782         ti = new CSSPrimitiveValue();
1783       }
1784     }
1785     ti._priority = priority;
1786     ti.cssText = cssText;
1787     if (!tg) {
1788       //_numプロパティはremovePropertyメソッドで利用する
1789       ti._num = this._list.length;
1790       this._list[ti._num] = ti;
1791       this[propertyName] = 1;
1792       ++this.length;
1793     }
1794     if (value === "inherit") {
1795       ti.cssValueType = CSSValue.CSS_INHERIT;
1796     } else if (propertyName === "opacity") {
1797       this._list._opacity = +value;
1798     } else if (propertyName === "font-size") {
1799       if (/(%|em|ex)/.test(value)) {
1800         tg = "_" +RegExP.$1
1801         ti[tg] = parseFloat(value);
1802       } else {
1803         this._em = this._ex = this["_%"] = null;
1804         this._list._fontSize = parseFloat(value);
1805       }
1806     }
1807     cssText = void 0;
1808   },
1809   /*itemメソッド
1810    *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1811    */
1812 /*string*/   item : function( /*long*/ index) {
1813     if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1814       var s = "";
1815     } else {
1816       var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1817     }
1818     return s;
1819   }
1820 };
1821
1822 function CSSValue() {
1823   return this;
1824 };
1825     // UnitTypes
1826 CSSValue.CSS_INHERIT                    = 0;
1827 CSSValue.CSS_PRIMITIVE_VALUE            = 1;
1828 CSSValue.CSS_VALUE_LIST                 = 2;
1829 CSSValue.CSS_CUSTOM                     = 3;
1830 CSSValue.prototype = {
1831   cssText : "",
1832   cssValueType : CSSValue.CSS_CUSTOM,
1833   _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1834 };
1835
1836 function CSSPrimitiveValue() {
1837   return this;
1838 };
1839
1840 (function(t) {
1841 t.CSS_UNKNOWN                    = 0;
1842 t.CSS_NUMBER                     = 1;
1843 t.CSS_PERCENTAGE                 = 2;
1844 t.CSS_EMS                        = 3;
1845 t.CSS_EXS                        = 4;
1846 t.CSS_PX                         = 5;
1847 t.CSS_CM                         = 6;
1848 t.CSS_MM                         = 7;
1849 t.CSS_IN                         = 8;
1850 t.CSS_PT                         = 9;
1851 t.CSS_PC                         = 10;
1852 t.CSS_DEG                        = 11;
1853 t.CSS_RAD                        = 12;
1854 t.CSS_GRAD                       = 13;
1855 t.CSS_MS                         = 14;
1856 t.CSS_S                          = 15;
1857 t.CSS_HZ                         = 16;
1858 t.CSS_KHZ                        = 17;
1859 t.CSS_DIMENSION                  = 18;
1860 t.CSS_STRING                     = 19;
1861 t.CSS_URI                        = 20;
1862 t.CSS_IDENT                      = 21;
1863 t.CSS_ATTR                       = 22;
1864 t.CSS_COUNTER                    = 23;
1865 t.CSS_RECT                       = 24;
1866 t.CSS_RGBCOLOR                   = 25;
1867 t.prototype = new CSSValue();
1868 t.constructor = CSSValue;
1869 })(CSSPrimitiveValue);
1870
1871 (function(){
1872   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に統一)
1873   this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1874   this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1875   this._value = null;
1876   this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1877   this._empercent = 0;
1878   this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1879   /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1880     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1881       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1882     }
1883     this.primitiveType = unitType;
1884     this._value = floatValue * this._n[unitType-1];  //値はあらかじめ、利用しやすいように変換しておく
1885   };
1886   /*getFloatValueメソッド
1887    *別の単位に変換可能。
1888    */
1889   this._regd = /[\d\.]+/;
1890   /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1891     if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1892       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1893     }
1894     if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1895       return (this._value / this._n[unitType-1]);
1896     } else {
1897       var tc = this.cssText,
1898           n = tc.slice(-1),
1899           type = 0,
1900           s = +(tc.match(this._regd));
1901       s = isNaN(s) ? 0 : s;
1902       if (n >= "0" && n <= "9") {
1903         type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1904         if (unitType === 1) {
1905           unitType = tc = n = type = void 0;
1906           return s;
1907         }
1908       } else if (n === "%") {
1909         s *= this._percent;
1910         type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1911       } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1912         s *= this._empercent;
1913         type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1914       } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1915         type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1916       } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1917         type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1918       } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1919         type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1920       } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1921         type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1922       } else if (n === "n") {
1923         type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1924       } else if (n === "t") {
1925         type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1926       } else if (n === "c") {
1927         type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1928       }
1929       s = s * this._n[type-1] / this._n[unitType-1];
1930       tc = n = type = unitType = void 0;
1931       return s;
1932     }
1933   };
1934   /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1935     if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1936       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1937     }
1938     this._value = stringValue;
1939   };
1940   /*string*/ this.getStringValue = function(/*short*/ stringType) {
1941     if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1942       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1943     }
1944     return (this._value);
1945   };
1946   /*Counter*/ this.getCounterValue = function() {
1947     if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1948       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1949     }
1950     return (new Counter());
1951   };
1952   /*Rect*/ this.getRectValue = function() {
1953     if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1954       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1955     }
1956     return (new Rect());
1957   };
1958   /*RGBColor*/ this.getRGBColorValue = function() {
1959     if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1960       throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1961     }
1962     var s = new RGBColor();
1963     var rgbColor = this.cssText;
1964     var tkr = SVGColor.prototype._keywords[rgbColor];
1965     if (tkr !== void 0) {
1966       rgbColor = tkr;
1967     }
1968     if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
1969       rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1970         return Math.round((2.55 * parseFloat(t)));
1971       });
1972     } else if (rgbColor.indexOf("#") > -1) {  //#を含む場合
1973       rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1974         return parseInt(s, 16);
1975       });
1976     }
1977     var n = rgbColor.match(/\d+/g);
1978     s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1979     s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1980     s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1981     n = rgbColor = void 0;
1982     return (s);
1983   };
1984 }).apply(CSSPrimitiveValue.prototype);
1985 /*CSSValueList
1986  *Arrayで代用する
1987  */
1988 function CSSValueList() {
1989   this.cssValueType = CSSValue.CSS_VALUE_LIST;
1990   this.length = 0;
1991   return this;
1992 };
1993 CSSValueList.prototype = new CSSValue();
1994 CSSValueList.constructor = CSSValue;
1995 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
1996   return (this[index]);
1997 };
1998
1999 function RGBColor() {
2000   var cs = CSSPrimitiveValue;
2001   this.red = new cs();
2002   this.green = new cs();
2003   this.blue = new cs();
2004   cs = void 0;
2005   this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2006   return this;
2007 };
2008
2009 function Rect() {
2010   var cs = CSSPrimitiveValue;
2011   this.top = new cs();
2012   this.right = new cs();
2013   this.bottom = new cs();
2014   this.left = new cs();
2015   cs = void 0; 
2016   return this;
2017 };
2018
2019 function Counter() {
2020   this.identifier = this.listStyle = this.separator = "";
2021   return this;
2022 };
2023
2024 function ElementCSSInlineStyle() {
2025   var cs = CSSStyleDeclaration;
2026   this.style = new cs();
2027   this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2028   cs = void 0;
2029   return this;
2030 };
2031
2032 /*CSS2Properties
2033  *削除不可
2034  *さらにSVG CSSを付け加えている
2035  */
2036 var n = "none",
2037     m = "normal",
2038     a = "auto",
2039     CSS2Properties = {
2040   fill : "black",
2041   stroke : n,
2042   cursor : a,
2043   visibility : "visible",
2044   display : "inline-block",
2045   opacity : "1",
2046   fillOpacity : "1",
2047   strokeWidth : "1",
2048   strokeDasharray : n,
2049   strokeDashoffset : "0",
2050   strokeLinecap : "butt",
2051   strokeLinejoin : "miter",
2052   strokeMiterlimit : "4",
2053   strokeOpacity : "1",
2054   writingMode : "lr-tb",
2055   fontFamily : "serif",
2056   fontSize : "12",
2057   color : "black",
2058   fontSizeAdjust : n,
2059   fontStretch : m,
2060   fontStyle : m,
2061   fontVariant : m,
2062   fontWeight : m,
2063   font : "inline",
2064
2065 //# Gradient properties:
2066
2067   stopColor : "black",
2068   stopOpacity : "1",
2069   textAnchor : "start",
2070   azimuth : "center",
2071                                         // raises(dom::DOMException) on setting
2072   //簡略プロパティに関しては、初期値を再考せよ
2073   clip : a,
2074   direction : "ltr",
2075   letterSpacing : m,
2076   lineHeight : m,
2077   overflow : "visible",
2078   textAlign : "left",
2079   textDecoration : n,
2080   textIndent : "0",
2081   textShadow : n,
2082   textTransform : n,
2083   unicodeBidi : m,
2084   verticalAlign : "baseline",
2085   whiteSpace : m,
2086   wordSpacing : m,
2087   zIndex : a,
2088 //  #
2089
2090   mask : n,
2091
2092 //# Filter Effects properties:
2093
2094   enableBackground : "accumulate",
2095   filter : n,
2096   floodColor : "black",
2097   floodOpacity : "1",
2098   lightingColor : "white",
2099
2100 //# Interactivity properties:
2101
2102   pointerEvents : "visiblePainted",
2103
2104 //# Color and Painting properties:
2105
2106   colorInterpolation : "sRGB",
2107   colorInterpolationFilters : "linearRGB",
2108   colorProfile : a,
2109   colorRendering : a,
2110   imageRendering : a,
2111   marker : "",
2112   markerEnd : n,
2113   markerMid : n,
2114   markerStart : n,
2115   shapeRendering : a,
2116   textRendering : a,
2117
2118 //# Text properties:
2119
2120   alignmentBaseline : "",
2121   baselineShift : "baseline",
2122   dominantBaseline : a,
2123   glyphOrientationHorizontal : "0deg",
2124   glyphOrientationVertical : a,
2125   kerning : a,
2126   fillRule : "nonzero"
2127 };
2128 n = m = a = void 0;
2129 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2130
2131 function CSSStyleSheet() {
2132 /*CSSRule*/      this.ownerRule = null;
2133 /*CSSRuleList*/  this.cssRules = [];
2134   return this;
2135 };
2136 CSSStyleSheet.prototype = new StyleSheet();
2137 CSSStyleSheet.constructor = StyleSheet;
2138 /*long*/  CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2139   var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2140   s.parentStyleSheet = this;
2141   style.cssText = rule;
2142   //style値の解析;
2143   sc = sc.replace(/^[^a-z\-]+/, "")
2144          .replace(/\:\s+/g, ":")
2145          .replace(/\s*;[^a-z\-]*/g, ";");
2146   a = sc.split(";");
2147   for (var i=0, ali=a.length;i<ali;++i) {
2148       ai = a[i],
2149       m = ai.split(":");
2150       if (ai !== "") {
2151         style.setProperty(m[0], m[1]);
2152       }
2153       ai = m = void 0;
2154     }
2155   a = sc = style = void 0;
2156   this.cssRules.splice(index,s,1);
2157 };
2158 /*void*/  CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2159   this.cssRules.splice(index, 1);
2160 };
2161
2162
2163 /*getComputedStyle関数
2164  *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2165  */
2166 /*interface ViewCSS : views::AbstractView {*/
2167 Document.prototype.defaultView = new ViewCSS();
2168 function ViewCSS(){
2169   return this;
2170 };
2171 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2172   var s = new CSSStyleDeclaration(),
2173       el, es,
2174       eso = 1;
2175   //クロージャを利用して、カスケーディングを実現する
2176   s.getPropertyCSSValue = (function(elt, td, s){
2177     return function( /*string*/ propertyName) {
2178       var el = elt,
2179           css = null,
2180           n;
2181       while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2182         if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2183           css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2184         } else if (el.style && el.style[propertyName]) {
2185           css = el.style.getPropertyCSSValue(propertyName);
2186         } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2187           //プレゼンテーション属性を探す
2188           css = el._attributeStyle.getPropertyCSSValue(propertyName);
2189         } else if (el._rules) {
2190           //スタイルシートのルールを探す
2191           for (var i=0,eli=el._rules.length;i<eli;++i) {
2192             el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2193           }
2194         }
2195         el = el.parentNode;
2196       }
2197       if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2198         //デフォルト値を探す
2199         td && (css = td[propertyName]);
2200       }
2201       if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2202         css.setRGBColor(s.getPropertyValue("color"));
2203       } else if (css && (css._em || css._ex || css["_%"])) {
2204         el = elt;
2205         n = 1;
2206         while (el) {
2207           if (el.style._list._fontSize) {
2208             n = el.style._list._fontSize;
2209             break;
2210           }
2211           el = el.parentNode;
2212         }
2213         if (css._em) {
2214           n *= css._em;
2215         } else if (css._ex) {
2216           n *= css._ex * 0.5;
2217         } else if (css["_%"]) {
2218           n *= css["_%"] / 100; 
2219         }
2220         css.cssText = "font-size:" +n+ "px";
2221       }
2222       el = void 0;
2223       return css;
2224     };
2225    })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2226   el = elt;
2227   while (el) {
2228     if (el.style) {
2229       es = el.style._list._opacity || el._attributeStyle._list._opacity;
2230       eso *= es || 1;
2231     }
2232     el = el.parentNode;
2233   }
2234   s._list._opacity = eso;
2235   el = pelt = eso = es = void 0;
2236   s._document = elt.ownerDocument;
2237   return s;
2238 };
2239
2240 /*getOverrideStyleメソッド
2241  *指定した要素の上書きスタイルシートを取得。
2242  */
2243 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2244 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2245   var tar = elt;
2246   if (!!tar._runtimeStyle) {
2247     return (tar._runtimeStyle);
2248   } else {
2249     var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2250     tar._runtimeStyle = s;
2251   }
2252   s.setProperty = (function(setProp, s){
2253     return function(propertyName, value, priority) {
2254       setProp.call(s, propertyName, value, priority);
2255       var tar = elt, el = tar._tar, isFill = isStroke = false;
2256       if ((tar.localName === "g") || (tar.localName === "a")) {
2257         var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2258         if (sl) {
2259           for (var i=0,sli=sl.length;i<sli;++i) {
2260             var di = sl[i];
2261             NAIBU._setPaint(di, di.getScreenCTM());
2262             di = void 0;
2263           }
2264           sl = void 0;
2265         }
2266         el = null;
2267       }
2268       if (!el) {
2269         return;
2270       }
2271       NAIBU._setPaint(tar, tar.getScreenCTM());
2272       el = tar = value = void 0;
2273     };
2274   })(setProp, s);
2275   return s;
2276 };
2277 /*createCSSStyleSheetメソッド
2278  *文書のスタイルシートを作成
2279  */
2280 /*interface DOMImplementationCSS : DOMImplementation {*/
2281 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2282   var s = new CSSStyleSheet();
2283   s.title = title;
2284   var nm = new MediaList();
2285   nm.mediaText = media;
2286   if (media && (media !== "")) {
2287     var mes = media.split(",");  //文字列をコンマで区切って配列に
2288     for (var i=0,mli=mes.length;i<mli;++i) {
2289       nm.appendMedium(mes[i]);   //メディアリストに値を加えていく
2290     }
2291   }
2292   s.media = nm;
2293   return s;
2294 };
2295 /*
2296 #endif // _CSS_IDL_
2297 */
2298 // File: smil.idl
2299 /*
2300 #ifndef _SMIL_IDL_
2301 #define _SMIL_IDL_
2302
2303 #include "dom.idl"
2304
2305 #pragma prefix "dom.w3c.org"
2306 module smil
2307 {
2308   typedef dom::DOMString DOMString;
2309 */
2310 /*ElementTimeControlはSVGAnimationElementに統合させる。
2311  *というのは、多重継承が難しいため
2312  */
2313 function ElementTimeControl(ele) {
2314   this._tar = ele;
2315   /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
2316    *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
2317    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2318    */
2319   this._begin = 0;
2320   this._end = null;
2321   return this;
2322 };
2323 ElementTimeControl.prototype = {
2324   /*void*/  beginElement : function() {
2325     var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2326     evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2327     this.dispatchEvent(evt);
2328   },
2329   /*void*/  endElement : function() {
2330     var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2331     evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2332     this.dispatchEvent(evt);
2333   },
2334   /*void*/  beginElementAt : function(/*float*/ offset) {
2335     var ntc = this.ownerDocument.documentElement.getCurrentTime();
2336     this._begin = offset + ntc;
2337   },
2338   /*void*/  endElementAt : function(/*float*/ offset) {
2339     var ntc = this.ownerDocument.documentElement.getCurrentTime();
2340     this._end = offset + ntc;
2341   }
2342 };
2343
2344 function TimeEvent() {
2345   Event.apply(this);
2346   /*readonly attribute views::AbstractView*/  this.view;
2347   /*readonly attribute long*/             this.detail;
2348   return this;
2349 };
2350 TimeEvent.counstructor = Event;
2351 TimeEvent.prototype = new Event();
2352 /*void*/  TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg, 
2353                                      /*views::AbstractView*/ viewArg, 
2354                                      /*long*/ detailArg) {
2355   this.type = typeArg;
2356   this.view = viewArg;
2357   this.detail = detailArg;
2358 };
2359 //#endif // _SMIL_IDL_
2360
2361
2362 //これを頭に付けたら、内部処理用
2363 var  NAIBU = {};
2364
2365 /*
2366 // File: svg.idl
2367 #ifndef _SVG_IDL_
2368 #define _SVG_IDL_
2369 // For access to DOM2 core
2370 #include "dom.idl"
2371 // For access to DOM2 events
2372 #include "events.idl"
2373 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2374 #include "css.idl"
2375 // For access to those parts from DOM2 Views OM used by SVG DOM.
2376 #include "views.idl"
2377 // For access to the SMIL OM used by SVG DOM.
2378 #include "smil.idl"
2379 #pragma prefix "dom.w3c.org"
2380 #pragma javaPackage "org.w3c.dom"
2381 module svg
2382 {
2383   typedef dom::DOMString DOMString;
2384   typedef dom::DOMException DOMException;
2385   typedef dom::Element Element;
2386   typedef dom::Document Document;
2387   typedef dom::NodeList NodeList;
2388   // Predeclarations
2389   interface SVGElement;
2390   interface SVGLangSpace;
2391   interface SVGExternalResourcesRequired;
2392   interface SVGTests;
2393   interface SVGFitToViewBox;
2394   interface SVGZoomAndPan;
2395   interface SVGViewSpec;
2396   interface SVGURIReference;
2397   interface SVGPoint;
2398   interface SVGMatrix;
2399   interface SVGPreserveAspectRatio;
2400   interface SVGAnimatedPreserveAspectRatio;
2401   interface SVGTransformList;
2402   interface SVGAnimatedTransformList;
2403   interface SVGTransform;
2404   interface SVGICCColor;
2405   interface SVGColor;
2406   interface SVGPaint;
2407   interface SVGTransformable;
2408   interface SVGDocument;
2409   interface SVGSVGElement;
2410   interface SVGElementInstance;
2411   interface SVGElementInstanceList;
2412 */
2413 function SVGException(code) {
2414   /*unsigned short*/  this.code = code;
2415   if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2416     this.message = "SVG Wrong Type Error";
2417   } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2418     this.message = "SVG Invalid Value Error";
2419   } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2420     this.message = "SVG Matrix Not Invertable";
2421   }
2422   return this;
2423 };
2424 SVGException.constructor = Error;
2425 SVGException.prototype = new Error();
2426 // SVGExceptionCode
2427 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR           = 0;
2428 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR        = 1;
2429 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE    = 2;
2430
2431 /*SVGElement
2432  *すべてのSVG関連要素の雛形となるオブジェクト
2433  */
2434 function SVGElement() {
2435   Element.call(this);
2436   SVGStylable.call(this);             //ElementCSSInlineStyleのインタフェースを継承
2437   /*interface SVGTransformable : SVGLocatable
2438    *TransformListはtransform属性を行列で表現したあとのリスト構造
2439    */
2440   /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2441   //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2442   this.addEventListener("DOMAttrModified", function(evt){
2443     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2444       return;
2445     }
2446     var name = evt.attrName,
2447         tar = evt.target;
2448     if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2449       tar._attributeStyle.setProperty(name, evt.newValue, "");
2450     }
2451     if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2452       tar.id = evt.newValue;
2453     } else if ((name === "transform") && !!tar.transform) {
2454       var tft = evt.newValue,
2455           degR = tar._degReg,
2456           coma = tft.match(tar._comaReg),   //コマンド文字にマッチ translate
2457           list = tft.match(tar._strReg),    //カッコ内のリストにマッチ (10 20 30...)
2458           a,b,c,d,e,f,
2459           lis,
2460           com,
2461           deg,
2462           rad,
2463           degli,
2464           s,
2465           cm,
2466           degz,
2467           etod = evt.target.ownerDocument.documentElement,
2468           ttb = tar.transform.baseVal;
2469       //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2470       for (var j=0,cli=coma.length;j<cli;j++) {
2471         s = etod.createSVGTransform();
2472         lis = list[j],
2473         com = coma[j];
2474         deg = lis.match(degR);
2475         degli = deg.length;
2476         if (degli === 6) {
2477           cm = s.matrix;
2478           cm.a = +(deg[0]);
2479           cm.b = +(deg[1]);
2480           cm.c = +(deg[2]);
2481           cm.d = +(deg[3]);
2482           cm.e = +(deg[4]);
2483           cm.f = +(deg[5]);
2484         } else {
2485           if (degli === 3) {
2486             degz = +(deg[0]);
2487             s.setRotate(degz, +(deg[1]), +(deg[2]))
2488           } else if (degli <= 2) {
2489             degz = +(deg[0]);
2490             if (com === "translate") {
2491               s.setTranslate(degz, +(deg[1] || 0));
2492             } else if (com === "scale") {
2493               s.setScale(degz, +(deg[1] || deg[0]));
2494             } else if (com === "rotate") {
2495               s.setRotate(degz, 0, 0);
2496             } else if (com === "skewX") {
2497               s.setSkewX(degz);
2498             } else if (com === "skewY") {
2499               s.setSkewY(degz);
2500             }
2501           }
2502         }
2503         ttb.appendItem(s);
2504       }
2505       tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2506     } else if (name === "style") {
2507       var sc = evt.newValue,
2508           style = tar.style,
2509           a,
2510           ai,
2511           m;
2512       style.cssText = sc;
2513       if (sc !== "") {
2514         //style属性値の解析
2515         sc = sc.replace(tar._shouReg, "")
2516                .replace(tar._conReg, ":")
2517                .replace(tar._bouReg, ";");
2518         a = sc.split(";");
2519         for (var i=0, ali=a.length;i<ali;++i) {
2520           ai = a[i],
2521           m = ai.split(":");
2522           if (ai !== "") {
2523             style.setProperty(m[0], m[1]);
2524           }
2525           ai = m = void 0;
2526         }
2527       }
2528       a = sc = style = void 0;
2529     } else if (name === "class") {
2530       tar.className = evt.newValue;
2531     } else if (name.indexOf("on") === 0) {           //event属性ならば
2532       /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2533        *ところが、IEでは、undefinedの値を返してしまう。
2534        *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2535        */
2536       eval("document._s = (function(evt){" +evt.newValue+ "})");
2537       var v = name.slice(2);
2538       if (v === "load") {
2539         v = "SVGLoad";
2540       } else if (v === "unload") {
2541         v = "SVGUnload";
2542       } else if (v === "abort") {
2543         v = "SVGAbort";
2544       } else if (v === "error") {
2545         v = "SVGError";
2546       } else if (v === "resize") {
2547         v = "SVGResize";
2548       } else if (v === "scroll") {
2549         v = "SVGScroll";
2550       } else if (v === "zoom") {
2551         v = "SVGZoom";
2552       } else if (v === "begin") {
2553         v = "beginEvent";
2554       } else if (v === "end") {
2555         v = "endEvent";
2556       } else if (v === "repeat") {
2557         v = "repeatEvent";
2558       }
2559       tar.addEventListener(v, document._s, false);
2560     } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2561       tar.xmlbase = evt.newValue;
2562     } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2563       var tea = tar[name],
2564           tod = tar.ownerDocument.documentElement,
2565           tvw = tod.viewport.width,
2566           tvh = tod.viewport.height,
2567           s,
2568           n = evt.newValue.slice(-2),
2569           m = n.charAt(1),
2570           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2571           _parseFloat = parseFloat;
2572       if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
2573       } else if (m === "%") {
2574         if (tar._x1width[name]) {
2575           tea.baseVal._percent = tvw * 0.01;
2576         } else if (tar._y1height[name]) {
2577           tea.baseVal._percent = tvh * 0.01;
2578         } else {
2579           tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2580         }
2581         type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2582       } else if (n === "em") {
2583         type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2584       } else if (n === "ex") {
2585         type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2586       } else if (n === "px") {
2587         type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2588       } else if (n === "cm") {
2589         type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2590       } else if (n === "mm") {
2591         type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2592       } else if (n === "in") {
2593         type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2594       } else if (n === "pt") {
2595         type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2596       } else if (n === "pc") {
2597         type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2598       }
2599       s = _parseFloat(evt.newValue);
2600       s = isNaN(s) ? 0 : s;
2601       tea.baseVal.newValueSpecifiedUnits(type, s);
2602       tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2603     }
2604     evt = _parseFloat = name = tar = null;
2605   }, false);
2606   return this;
2607 };
2608 SVGElement.constructor = Element;
2609 SVGElement.prototype = new Element();
2610
2611 (function(){
2612   /*以下の正規表現は属性のパーサの際に用いる*/
2613   this._degReg = /[\-\d\.e]+/g;
2614   this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2615   this._strReg =  /\([^\)]+\)/g;
2616   this._syouReg = /^[^a-z\-]+/;
2617   this._conReg = /\:\s+/g;
2618   this._bouReg = /\s*;[^a-z\-]*/g;
2619   /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2620    *getCTMメソッドで使う
2621    */
2622   this._cacheMatrix = null;
2623   /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2624   this._x1width = {
2625       "x" : 1,
2626       "x1" : 1,
2627       "x2" : 1,
2628       "width" : 1,
2629       "cx" : 1
2630   };
2631   this._y1height = {
2632       "y" : 1,
2633       "y1" : 1,
2634       "y2" : 1,
2635       "height" : 1,
2636       "cy" : 1      
2637   };
2638   /*String*/              this.id      = null;        //id属性の値
2639   /*String*/              this.xmlbase = null;   //xml:base属性の値
2640   /*SVGSVGElement*/       this.ownerSVGElement;  //ルート要素であるsvg要素
2641   /*readonly SVGElement*/ this.viewportElement;  //ビューポートを形成する要素(多くはsvg要素)
2642   /*readonly attribute SVGElement*/ this.nearestViewportElement  = null;
2643   /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2644   
2645   /*interface SVGLocatable*/
2646   /*SVGRect*/     this.getBBox = function(){
2647     var s = new SVGRect(),
2648         data = this._tar.path.value,
2649         vi = this.ownerDocument.documentElement.viewport,
2650         el = vi.width,
2651         et = vi.height,
2652         er = 0,
2653         eb = 0,
2654         degis = data.match(/[0-9\-]+/g),
2655         nx,
2656         ny;
2657     /*要素の境界領域を求める(四隅の座標を求める)
2658      *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2659      *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2660      */
2661     for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2662       nx = +(degis[i]),
2663       ny = +(degis[i+1]);
2664       el = el > nx ? nx : el;
2665       et = et > ny ? ny : et;
2666       er = er > nx ? er : nx;
2667       eb = eb > ny ? eb : ny;
2668     }
2669     s.x      = el;
2670     s.y      = et;
2671     s.width  = er - el;
2672     s.height = eb - et;
2673     nx = ny = data = degis =el = et = er = eb = vi = void 0;
2674     return s;
2675   };
2676
2677   /*getCTMメソッド
2678    *CTMとは現在の利用座標系に対する変換行列
2679    *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2680    *1.2ではgetCTMが言及されていない
2681    *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2682    */
2683   /*SVGMatrix*/   this.getCTM = function() {
2684     var s, m;
2685     if (!!this._cacheMatrix) { //キャッシュがあれば
2686       s = this._cacheMatrix;
2687     } else {
2688       m = this.transform.baseVal.consolidate();
2689       if (m) {
2690         m = m.matrix;
2691       } else {
2692         m = this.ownerDocument.documentElement.createSVGMatrix();
2693       }
2694       if (this.parentNode && !!this.parentNode.getCTM) {
2695         s = this.parentNode.getCTM().multiply(m);
2696       } else {
2697         s = m;
2698       }
2699       m = void 0;
2700       this._cacheMatrix = s; //キャッシュをためて次回で使う
2701     }
2702     return s;
2703   };
2704
2705   /*SVGMatrix*/   this.getScreenCTM = function(){
2706     if (!this.parentNode) {
2707       return null;
2708     }
2709     var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2710     var s = view.getScreenCTM().multiply(this.getCTM());
2711     view = null;
2712     return s;
2713   };
2714
2715   /*getTransformToElementメソッド
2716    *これは、あるelementへの変換行列を計算して返す
2717    *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2718    */
2719   /*SVGMatrix*/   this.getTransformToElement = function(/*SVGElement*/ element ){
2720     var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2721     return s;
2722   };
2723 }).apply(SVGElement.prototype);
2724
2725 function SVGAnimatedBoolean() {
2726   /*boolean*/  this.animVal = this.baseVal = true;
2727   return this;
2728 };
2729
2730 function SVGAnimatedString() {
2731   /*String*/ this.animVal = this.baseVal = "";
2732   return this;
2733 };
2734
2735 function SVGStringList() {
2736   return this;
2737 };
2738 SVGStringList.prototype = new Array();
2739 (function(){
2740   /*readonly unsigned long*/ this.numberOfItems = 0;
2741   /*void*/   this.clear = function(){
2742     for (var i=0, tli=this.length;i<tli;++i) {
2743       delete this[i];
2744     }
2745     this.numberOfItems = 0;
2746   };
2747   /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2748     this.clear();
2749     this[0] = newItem;
2750     this.numberOfItems = 1;
2751     return newItem;
2752   };
2753   /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2754     if (index >= this.numberOfItems || index < 0) {
2755       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2756     } else {
2757       return (this[index]);
2758     }
2759   };
2760   /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2761     if (index >= this.numberOfItems) {
2762       this.appendItem(newItem);
2763     } else {
2764       this.splice(index, 1, newItem, this.getItem[index]);
2765       ++this.numberOfItems;
2766     }
2767     return newItem;
2768   };
2769   /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2770     if (index >= this.numberOfItems || index < 0) {
2771       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2772     } else {
2773       this.splice(index, 1, newItem);
2774     }
2775     return newItem;
2776   };
2777                   //raises( DOMException, SVGException );
2778   /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2779     if (index >= this.numberOfItems || index < 0) {
2780       throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2781     } else {
2782       this.splice(index, 1);
2783       --this.numberOfItems;
2784     }
2785     return newItem;
2786   };
2787   /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2788     this[this.numberOfItems] = newItem;
2789     ++this.numberOfItems;
2790   };
2791 }).apply(SVGStringList.prototype);
2792
2793 function SVGAnimatedEnumeration() {
2794   /*unsigned short*/ this.baseVal = 0;
2795                          // raises DOMException on setting
2796   /*readonly unsigned short*/ this.animVal = 0;
2797   return this;
2798 };
2799 function SVGAnimatedInteger() {
2800   /*long*/ this.baseVal = 0;
2801                          // raises DOMException on setting
2802   /*readonly long*/ this.animVal = 0;
2803   return this;
2804 };
2805 function SVGNumber() {
2806   /*float*/ this.value = 0;
2807                          // raises DOMException on setting
2808   return this;
2809 };
2810 function SVGAnimatedNumber() {
2811   /*float*/ this.baseVal = this.animVal = 0;
2812   return this;
2813 };
2814
2815 function SVGNumberList() {
2816   return this;
2817 };
2818 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2819   SVGNumberList.prototype[prop] = SVGStringList.prototype[prop];
2820 }
2821 function SVGAnimatedNumberList() {
2822   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2823   return this;
2824 };
2825 /*SVGLengthクラス
2826  *長さを設定する(単位pxに統一する方便として使う)
2827  *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2828  */
2829 function SVGLength() {
2830   return this;
2831 };
2832 (function(t) {
2833     // Length Unit Types
2834   /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN    = 0;
2835   /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER     = 1;
2836   /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2837   /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS        = 3;
2838   /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS        = 4;
2839   /*const unsigned short*/ t.SVG_LENGTHTYPE_PX         = 5;
2840   /*const unsigned short*/ t.SVG_LENGTHTYPE_CM         = 6;
2841   /*const unsigned short*/ t.SVG_LENGTHTYPE_MM         = 7;
2842   /*const unsigned short*/ t.SVG_LENGTHTYPE_IN         = 8;
2843   /*const unsigned short*/ t.SVG_LENGTHTYPE_PT         = 9;
2844   /*const unsigned short*/ t.SVG_LENGTHTYPE_PC         = 10;
2845 })(SVGLength);
2846
2847 SVGLength.prototype = {
2848   /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2849   /*attribute float*/          value : 0,                  //利用単位における値
2850   /*attribute float*/          valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN,  //unitTypeにおける値
2851   /*attribute DOMString*/      valueAsString : "0",
2852   _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2853   _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2854 /*newValueSpedifiedUnitsメソッド
2855  *新しくunitTypeにおける値を設定する
2856  *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2857  */
2858   newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2859     var n = 1,
2860        _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2861     if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2862     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2863       _s = "px";
2864     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2865       n = this._percent;
2866       _s = "%"
2867     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2868       n = this._fontSize;
2869       _s = "em";
2870     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2871       n = this._fontSize * 0.5;
2872       _s = "ex";
2873     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2874       n = 35.43307;
2875       _s = "cm";
2876     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2877       n = 3.543307;
2878       _s = "mm";
2879     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2880       n = 90;
2881       _s = "in";
2882     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2883       n = 1.25;
2884       _s = "pt";
2885     } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2886       n = 15;
2887       _s = "pc";
2888     } else {
2889       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2890     }
2891     this.unitType = unitType;
2892     this.value = valueInSpecifiedUnits * n;
2893     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2894     this.valueAsString = valueInSpecifiedUnits + _s;
2895     valueInSpecifiedUnits = unitType = n = _s = void 0;
2896   },
2897 /*convertToSpecifiedUnitsメソッド
2898  *valueプロパティを書き換えずに、単位だけを変換する
2899  *例:2cmをmmに変換したい場合
2900  * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2901  * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2902  * alert(x.valueAsString); //20mm
2903  */
2904   convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2905     if (this.value === 0) {
2906       this.newValueSpecifiedUnits(unitType, 0);
2907       return;
2908     }
2909     var v = this.value;
2910     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2911     v = v / this.value * this.valueInSpecifiedUnits;
2912     this.newValueSpecifiedUnits(unitType, v); 
2913   },
2914   /*_emToUnitメソッド
2915    *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2916    *単位が%の場合は、新しいvalueへと変換させておく
2917    */
2918   _emToUnit : function (/*float*/ fontSize) {
2919     if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2920       this._fontSize = fontSize;
2921       this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2922     }
2923   }
2924 };
2925 function SVGAnimatedLength() {
2926   /*readonly SVGLength*/ this.animVal;
2927   this.baseVal = new SVGLength();
2928   this.baseVal.unitType = 1;
2929   return this;
2930 };
2931 function SVGLengthList() {
2932   return this;
2933 };
2934 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2935   SVGLengthList.prototype[prop] = SVGStringList.prototype[prop];
2936 }
2937 function SVGAnimatedLengthList() {
2938   /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2939   return this;
2940 };
2941 function SVGAngle() { 
2942   return this;
2943 };
2944 SVGAngle.prototype = {
2945   /*readonly attribute unsigned short*/ unitType : 0,
2946   /*attribute float*/     value : 0,
2947                          // raises DOMException on setting
2948   /*attribute float*/     valueInSpecifiedUnits : 0,
2949                          // raises DOMException on setting
2950   /*attribute DOMString*/ valueAsString : "0",
2951                          // raises DOMException on setting
2952   /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2953     var n = 1,
2954         _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2955     if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2956     } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2957       _s = "deg"
2958     } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2959       n =  Math.PI / 180;
2960       _s = "rad";
2961     } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2962       n = 9 / 10;
2963       _s = "grad";
2964     } else {
2965       throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2966     }
2967     this.unitType = unitType;
2968     this.value = valueInSpecifiedUnits * n;
2969     this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2970     this.valueAsString = valueInSpecifiedUnits + _s;
2971     n = _s = void 0;
2972     //raises( DOMException );
2973   },
2974   /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2975     if (this.value === 0) {
2976       this.newValueSpecifiedUnits(unitType, 0);
2977       return;
2978     }
2979     var v = this.value;
2980     this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2981     v = v / this.value * this.valueInSpecifiedUnits;
2982     this.newValueSpecifiedUnits(unitType, v); 
2983     //raises( DOMException );
2984   }
2985 };
2986 // Angle Unit Types
2987 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN     = 0;
2988 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
2989 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG         = 2;
2990 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD         = 3;
2991 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD        = 4;
2992 function SVGAnimatedAngle() { 
2993   /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
2994   /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
2995   return this;
2996 };
2997 function SVGColor() {
2998   CSSValue.apply(this);
2999   /*readonly css::RGBColor*/  this.rgbColor  = new RGBColor();
3000   return this;
3001 };
3002
3003   // Color Types
3004 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN           = 0;
3005 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR          = 1;
3006 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3007 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR      = 3;
3008 SVGColor.prototype = new CSSValue();  //ノードのプロトタイプチェーンを作って、継承
3009 SVGColor.constructor = CSSValue;
3010
3011 (function(){
3012   /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3013   /*readonly SVGICCColor*/    this.iccColor = null;
3014   this._regD = /\d+/g;
3015   this._regDP = /[\d.]+%/g;
3016   /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3017   var s,
3018       _parseInt,
3019       r, g, b,
3020       c;
3021   if (!rgbColor || (typeof rgbColor !== "string")) {
3022     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3023   }
3024   rgbColor = this._keywords[rgbColor] || rgbColor;
3025   if (rgbColor.indexOf("%", 5) > 0) {      // %を含むrgb形式の場合
3026     rgbColor = rgbColor.replace(this._regDP, function(s) {
3027       return Math.round((2.55 * parseFloat(s)));
3028     });
3029     s = rgbColor.match(this._regD);
3030   } else if (rgbColor.indexOf("#") === 0) {  //#を含む場合
3031     s = [];
3032     _parseInt = parseInt;
3033     r = rgbColor.charAt(1);
3034     g = rgbColor.charAt(2);
3035     b = rgbColor.charAt(3)
3036     if (rgbColor.length < 5) {
3037       c = "#" + r + r + g + g + b + b;
3038       rgbColor = c;
3039       c = void 0;
3040     }
3041     s[0] = _parseInt(r+rgbColor.charAt(2), 16)+ "";
3042     s[1] = _parseInt(rgbColor.charAt(3)+rgbColor.charAt(4), 16)+ "";
3043     s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ "";
3044     r = g = b = void 0;
3045   } else {
3046     s = rgbColor.match(this._regD);
3047     if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3048       rgbColor = void 0;
3049       throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3050     }
3051   }
3052   this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3053   this.rgbColor.green.setFloatValue(1, s[1]);
3054   this.rgbColor.blue.setFloatValue(1, s[2]);
3055   rgbColor = s = _parseInt = void 0;
3056 };
3057
3058 //                    raises( SVGException );
3059 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3060   this.colorType = colorType;
3061   if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3062     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3063   } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3064     this.setRGBColor(rgbColor);
3065   } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3066     this.setRGBColor(rgbColor);
3067   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3068     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3069   } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3070     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3071   }
3072   colorType = rgbColor = void 0;
3073 }
3074 //                    raises( SVGException );
3075 //色キーワード
3076 this._keywords = {
3077     aliceblue:    "rgb(240,248,255)",
3078     antiquewhite: "rgb(250,235,215)",
3079     aqua:         "rgb(0,255,255)",
3080     aquamarine:   "rgb(127,255,212)",
3081     azure:        "rgb(240,255,255)",
3082     beige:        "rgb(245,245,220)",
3083     bisque:       "rgb(255,228,196)",
3084     black:        "rgb(0,0,0)",
3085     blanchedalmond:"rgb(255,235,205)",
3086     blue:         "rgb(0,0,255)",
3087     blueviolet:   "rgb(138,43,226)",
3088     brown:        "rgb(165,42,42)",
3089     burlywood:    "rgb(222,184,135)",
3090     cadetblue:    "rgb(95,158,160)",
3091     chartreuse:   "rgb(127,255,0)",
3092     chocolate:    "rgb(210,105,30)",
3093     coral:        "rgb(255,127,80)",
3094     cornflowerblue:"rgb(100,149,237)",
3095     cornsilk:     "rgb(255,248,220)",
3096     crimson:      "rgb(220,20,60)",
3097     cyan:         "rgb(0,255,255)",
3098     darkblue:     "rgb(0,0,139)",
3099     darkcyan:     "rgb(0,139,139)",
3100     darkgoldenrod:"rgb(184,134,11)",
3101     darkgray:     "rgb(169,169,169)",
3102     darkgreen:    "rgb(0,100,0)",
3103     darkgrey:     "rgb(169,169,169)",
3104     darkkhaki:    "rgb(189,183,107)",
3105     darkmagenta:  "rgb(139,0,139)",
3106     darkolivegreen:"rgb(85,107,47)",
3107     darkorange:    "rgb(255,140,0)",
3108     darkorchid:   "rgb(153,50,204)",
3109     darkred:      "rgb(139,0,0)",
3110     darksalmon:   "rgb(233,150,122)",
3111     darkseagreen: "rgb(143,188,143)",
3112     darkslateblue:"rgb(72,61,139)",
3113     darkslategray:"rgb(47,79,79)",
3114     darkslategrey:"rgb(47,79,79)",
3115     darkturquoise:"rgb(0,206,209)",
3116     darkviolet:   "rgb(148,0,211)",
3117     deeppink:     "rgb(255,20,147)",
3118     deepskyblue:  "rgb(0,191,255)",
3119     dimgray:      "rgb(105,105,105)",
3120     dimgrey:      "rgb(105,105,105)",
3121     dodgerblue:   "rgb(30,144,255)",
3122     firebrick:    "rgb(178,34,34)",
3123     floralwhite:  "rgb(255,250,240)",
3124     forestgreen:  "rgb(34,139,34)",
3125     fuchsia:      "rgb(255,0,255)",
3126     gainsboro:    "rgb(220,220,220)",
3127     ghostwhite:   "rgb(248,248,255)",
3128     gold:         "rgb(255,215,0)",
3129     goldenrod:    "rgb(218,165,32)",
3130     gray:         "rgb(128,128,128)",
3131     grey:         "rgb(128,128,128)",
3132     green:        "rgb(0,128,0)",
3133     greenyellow:  "rgb(173,255,47)",
3134     honeydew:     "rgb(240,255,240)",
3135     hotpink:      "rgb(255,105,180)",
3136     indianred:    "rgb(205,92,92)",
3137     indigo:       "rgb(75,0,130)",
3138     ivory:        "rgb(255,255,240)",
3139     khaki:        "rgb(240,230,140)",
3140     lavender:     "rgb(230,230,250)",
3141     lavenderblush:"rgb(255,240,245)",
3142     lawngreen:    "rgb(124,252,0)",
3143     lemonchiffon: "rgb(255,250,205)",
3144     lightblue:    "rgb(173,216,230)",
3145     lightcoral:   "rgb(240,128,128)",
3146     lightcyan:    "rgb(224,255,255)",
3147     lightgoldenrodyellow:"rgb(250,250,210)",
3148     lightgray:    "rgb(211,211,211)",
3149     lightgreen:   "rgb(144,238,144)",
3150     lightgrey:    "rgb(211,211,211)",
3151     lightpink:    "rgb(255,182,193)",
3152     lightsalmon:  "rgb(255,160,122)",
3153     lightseagree: "rgb(32,178,170)",
3154     lightskyblue: "rgb(135,206,250)",
3155     lightslategray:"rgb(119,136,153)",
3156     lightslategrey:"rgb(119,136,153)",
3157     lightsteelblue:"rgb(176,196,222)",
3158     lightyellow:  "rgb(255,255,224)",
3159     lime:         "rgb(0,255,0)",
3160     limegreen:    "rgb(50,205,50)",
3161     linen:        "rgb(250,240,230)",
3162     magenta:      "rgb(255,0,255)",
3163     maroon:       "rgb(128,0,0)",
3164     mediumaquamarine:"rgb(102,205,170)",
3165     mediumblue:    "rgb(0,0,205)",
3166     mediumorchid:  "rgb(186,85,211)",
3167     mediumpurple:  "rgb(147,112,219)",
3168     mediumseagreen:"rgb(60,179,113)",
3169     mediumslateblue:"rgb(123,104,238)",
3170     mediumspringgreen:"rgb(0,250,154)",
3171     mediumturquoise:"rgb(72,209,204)",
3172     mediumvioletred:"rgb(199,21,133)",
3173     midnightblue:  "rgb(25,25,112)",
3174     mintcream:     "rgb(245,255,250)",
3175     mistyrose:     "rgb(255,228,225)",
3176     moccasin:      "rgb(255,228,181)",
3177     navajowhite:   "rgb(255,222,173)",
3178     navy:          "rgb(0,0,128)",
3179     oldlace:       "rgb(253,245,230)",
3180     olive:         "rgb(128,128,0)",
3181     olivedrab:     "rgb(107,142,35)",
3182     orange:        "rgb(255,165,0)",
3183     orangered:     "rgb(255,69,0)",
3184     orchid:        "rgb(218,112,214)",
3185     palegoldenrod: "rgb(238,232,170)",
3186     palegreen:     "rgb(152,251,152)",
3187     paleturquoise: "rgb(175,238,238)",
3188     palevioletred: "rgb(219,112,147)",
3189     papayawhip:    "rgb(255,239,213)",
3190     peachpuff:     "rgb(255,218,185)",
3191     peru:          "rgb(205,133,63)",
3192     pink:          "rgb(255,192,203)",
3193     plum:          "rgb(221,160,221)",
3194     powderblue:    "rgb(176,224,230)",
3195     purple:        "rgb(128,0,128)",
3196     red:           "rgb(255,0,0)",
3197     rosybrown:     "rgb(188,143,143)",
3198     royalblue:     "rgb(65,105,225)",
3199     saddlebrown:   "rgb(139,69,19)",
3200     salmon:        "rgb(250,128,114)",
3201     sandybrown:    "rgb(244,164,96)",
3202     seagreen:      "rgb(46,139,87)",
3203     seashell:      "rgb(255,245,238)",
3204     sienna:        "rgb(160,82,45)",
3205     silver:        "rgb(192,192,192)",
3206     skyblue:       "rgb(135,206,235)",
3207     slateblue:     "rgb(106,90,205)",
3208     slategray:     "rgb(112,128,144)",
3209     slategrey:     "rgb(112,128,144)",
3210     snow:          "rgb(255,250,250)",
3211     springgreen:   "rgb(0,255,127)",
3212     steelblue:     "rgb(70,130,180)",
3213     tan:           "rgb(210,180,140)",
3214     teal:          "rgb(0,128,128)",
3215     thistle:       "rgb(216,191,216)",
3216     tomato:        "rgb(255,99,71)",
3217     turquoise:     "rgb(64,224,208)",
3218     violet:        "rgb(238,130,238)",
3219     wheat:         "rgb(245,222,179)",
3220     white:         "rgb(255,255,255)",
3221     whitesmoke:    "rgb(245,245,245)",
3222     yellow:        "rgb(255,255,0)",
3223     yellowgreen:   "rgb(154,205,50)"
3224 };
3225 }).apply(SVGColor.prototype);
3226
3227 function SVGRect() { 
3228   /*float*/ this.x      = 0;
3229                          // raises DOMException on setting
3230   /*float*/ this.y      = 0;
3231                          // raises DOMException on setting
3232   /*float*/ this.width  = 0;
3233                          // raises DOMException on setting
3234   /*float*/ this.height = 0;
3235                          // raises DOMException on setting
3236   return this;
3237 };
3238
3239 function SVGAnimatedRect() { 
3240   /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3241   return this;
3242 };
3243
3244 SVGUnitTypes = { 
3245   // Unit Types
3246   /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN           : 0,
3247   /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE    : 1,
3248   /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3249 };
3250 function SVGStylable() {
3251   /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3252   /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3253   this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3254   //styleのcssTextプロパティを解析するリスナーを登録しておく
3255 };
3256 /*getPresentationAttributeメソッド
3257  *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3258  */
3259 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3260   var s = this._attributeStyle.getPropertyCSSValue(name);
3261   if (s) {
3262     return s;
3263   } else {
3264     return null;
3265   }
3266 };
3267
3268 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3269  *SIEでは、もっぱらXLink言語の処理を行う
3270  */
3271 function SVGURIReference() {
3272   /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3273   this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3274   this._text = "";
3275   this.addEventListener("DOMAttrModified", function(evt){
3276     if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3277       evt.target.href.baseVal = evt.newValue;
3278       /*_svgload_limitedを+1とすることで、
3279        *SVGLoadイベントは発火されなくなる。1を引く必要がある
3280        */
3281       evt.target.ownerDocument.documentElement._svgload_limited++;
3282     }
3283     evt = void 0;
3284   }, false);
3285   this.addEventListener("DOMNodeInserted", function(evt){
3286     var tar = evt.target;
3287     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3288       return; //強制終了させる
3289     }
3290     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3291       var tar = evt.target,
3292           base,
3293           href = tar.href.baseVal,
3294           show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3295       /*xlink:href属性とxml:base属性を手がかりに、
3296        *ハイパーリンクのURIを決定する処理を行う
3297        */
3298       if (href !== "") { //xlink:href属性が指定されたとき
3299         egbase = tar.xmlbase;
3300         if (!egbase) {
3301           ep = tar.parentNode;
3302           b = null;
3303           while (!b && ep) {
3304             b = ep.xmlbase;
3305             ep = ep.parentNode;
3306           }
3307           base = b;
3308           if (!b) {                        //xml:baseの指定がなければ
3309             if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3310               lh = location.href;
3311               base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3312             } else {
3313               base = location.href;
3314             }
3315           }
3316         } else {
3317           base = egbase;
3318         }
3319         if (href.indexOf(":") !== -1) { //絶対URIの場合
3320           base =  "";
3321         }
3322         uri = base + href;
3323         show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3324         if (href.indexOf(".") === 0) {  //相対URIの場合
3325           uri = href;
3326         }
3327         if (show === "replace") {
3328           tar._tar.setAttribute("href", uri);
3329         } else if (show === "new") {
3330           tar._tar.setAttribute("target", "_blank");
3331           tar._tar.setAttribute("href", uri);
3332         } else if (show === "embed") {
3333           xmlhttp = NAIBU.xmlhttp;
3334           ui = uri.indexOf("#");
3335           if (ui > -1) {
3336             id = uri.slice(ui+1);
3337             uri = uri.replace(/#.+$/, "");
3338           } else {
3339             id = null;
3340           }
3341           if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3342             doc = tar.ownerDocument;
3343             ele = doc.getElementById(id);
3344             tar._instance = ele;
3345             ev = doc.createEvent("SVGEvents");
3346             ev.initEvent("S_Load", false, false);
3347             tar.dispatchEvent(ev);
3348             tar = xmlhttp = void 0;
3349           } else if (uri.indexOf("data:") > -1) {
3350             tar._tar.src = uri;
3351             tar = xmlhttp = void 0;
3352           } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3353             if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3354               tar._tar.src = uri;
3355             } else {
3356               /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3357               tar.ownerDocument.documentElement._svgload_limited++;
3358               xmlhttp.open("GET", uri, false);
3359               xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3360               xmlhttp.onreadystatechange = function() {
3361                 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3362                   var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3363                       doc, str, ele, ev;
3364                   if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3365                     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3366                      *ここでは、responseTextを用いる
3367                      */
3368                     /*script要素とstyle要素は、
3369                      *_textプロパティに読み込んだテキストを格納しておく
3370                      *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3371                      */
3372                     if (tar.localName !== "script" && tar.localName !== "style") {
3373                       doc = new ActiveXObject("MSXML2.DomDocument");
3374                       str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3375                       NAIBU.doc.async = false;
3376                       NAIBU.doc.validateOnParse = false;
3377                       NAIBU.doc.resolveExternals = false;
3378                       NAIBU.doc.preserveWhiteSpace = false;
3379                       doc.loadXML(str);
3380                       ele = doc.documentElement;
3381                       tar._instance = tar.ownerDocument.importNode(ele, true);
3382                       if (id) {
3383                         tar._instance = tar._instance.ownerDocument.getElementById(id);
3384                       }
3385                     } else {
3386                       tar._text = xmlhttp.responseText;
3387                     }
3388                   } else if (!!tar._tar) {
3389                     tar._tar.src = uri;
3390                   }
3391                   /*S_LoadイベントとはSIE独自のイベント。
3392                    *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3393                    */
3394                   ev = tar.ownerDocument.createEvent("SVGEvents");
3395                   ev.initEvent("S_Load", false, false);
3396                   tar.dispatchEvent(ev);
3397                   tar.ownerDocument.documentElement._svgload_limited--;
3398                   /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3399                   if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3400                     ev = tar.ownerDocument.createEvent("SVGEvents");
3401                     ev.initEvent("SVGLoad", false, false);
3402                     tar.ownerDocument.documentElement.dispatchEvent(ev);
3403                   }
3404                   tar = type = doc = str = ev = void 0;
3405                   /*IEのメモリリーク対策として、空関数を入力*/
3406                   xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3407                   xmlhttp = void 0;
3408                 }
3409               };
3410               xmlhttp.send(null);
3411             }
3412           }
3413         }
3414         tar.ownerDocument.documentElement._svgload_limited--;
3415       }
3416       evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3417     }, false);
3418     tar = evt = void 0;
3419   }, false);
3420   return this;
3421 };
3422 function SVGCSSRule() { 
3423   CSSRule.apply(this, arguments);
3424   // Additional CSS RuleType to support ICC color specifications
3425   /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3426   return this;
3427 };
3428 SVGCSSRule.constructor = CSSRule;
3429 SVGCSSRule.prototype = new CSSRule();  //ノードのプロトタイプチェーンを作って、継承
3430
3431 /*SVGDocument
3432  *SVGの文書オブジェクト
3433  */
3434 function SVGDocument(){
3435   Document.apply(this);
3436   DocumentStyle.apply(this);
3437   /*readonly DOMString*/     this.title    = "";
3438   /*readonly DOMString*/     this.referrer = document.referrer;
3439   /*readonly DOMString*/     this.domain   = document.domain;
3440   /*readonly DOMString*/     this.URL      = document.location;
3441   /*readonly SVGSVGElement*/ this.rootElement;
3442   return this;
3443 };
3444 SVGDocument.constructor = Document;
3445 SVGDocument.prototype = new Document();  //ノードのプロトタイプチェーンを作って、継承
3446
3447 /*SVGSVGElement
3448  *svg要素をあらわすオブジェクト
3449  */
3450 function SVGSVGElement(_doc) {
3451   SVGElement.apply(this, arguments);
3452   this._tar = _doc.createElement("v:group");
3453   _doc = void 0;
3454   /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3455    * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3456   this._svgload_limited = 0;
3457 /*                SVGElement,
3458                 SVGTests,
3459                 SVGLangSpace,
3460                 SVGExternalResourcesRequired,
3461                 SVGStylable,
3462                 SVGLocatable,
3463                 SVGFitToViewBox,
3464                 SVGZoomAndPan,
3465                 events::EventTarget,
3466                 events::DocumentEvent,
3467                 css::ViewCSS,
3468                 css::DocumentCSS {*/
3469   /*以下のx,y,width,heightプロパティは
3470    *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3471    *1000というのは、W3Cで触れていないため、独自の初期値を採用
3472    */
3473   var slen = SVGAnimatedLength;
3474   /*readonly SVGAnimatedLength*/ this.x      = new slen();
3475   /*readonly SVGAnimatedLength*/ this.y      = new slen();
3476   /*readonly SVGAnimatedLength*/ this.width  = new slen();
3477   /*readonly SVGAnimatedLength*/ this.height = new slen();
3478   slen = void 0;
3479   /*DOMString*/                  this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3480   /*DOMString*/                  this.contentStyleType  = "text/css";
3481   /*readonly SVGRect*/           this.viewport          = this.createSVGRect();
3482   /*useCurrentViewプロパティ
3483    * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3484    */
3485   /*boolean*/                    this.useCurrentView    = false;
3486   /*currentViewプロパティ
3487    * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3488    */
3489   /*readonly SVGViewSpec*/       this.currentView       = new SVGViewSpec(this);
3490   /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3491    *以下のプロパティを使って次の行列で示すことができる
3492    *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y] 
3493    */
3494   /*float*/                      this.currentScale     = 1;
3495   /*readonly SVGPoint*/          this.currentTranslate = this.createSVGPoint();
3496   /*以下は、SVGFitToViewBoxのインターフェースを用いる
3497    *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3498    */
3499   /*readonly SVGAnimatedRect*/   this.viewBox = this.currentView.viewBox;
3500   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3501   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3502   this._tx = 0;
3503   this._ty = 0;
3504   /*int*/                       this._currentTime = 0;
3505   /*DOMAttrModifiedイベントを利用して、
3506    *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3507    */
3508   this.addEventListener("DOMAttrModified", function(evt){
3509     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3510       return; //強制終了させる
3511     }
3512     var tar = evt.target,
3513         name = evt.attrName,
3514         tv, ovb, par, tp, sa, mos;
3515     if (name === "viewBox") {
3516       tar._cacheScreenCTM = null;
3517       tv = tar.viewBox.baseVal;
3518       ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3519       tv.x = parseFloat(ovb[0]);
3520       tv.y = parseFloat(ovb[1]);
3521       tv.width = parseFloat(ovb[2]);
3522       tv.height = parseFloat(ovb[3]);
3523       tar.viewBox.baseVal._isUsed = 1;
3524     } else if (name === "preserveAspectRatio") {
3525       tar._cacheScreenCTM = null;
3526       par = evt.newValue;
3527       tp = tar.preserveAspectRatio.baseVal;
3528       sa = 1;
3529       mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3530       if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3531         switch (RegExp.$1) {
3532           case "Min":
3533             sa += 1;
3534           break;
3535           case "Mid":
3536             sa += 2;
3537           break;
3538           case "Max":
3539             sa += 3;
3540           break;
3541         }
3542         switch (RegExp.$2) {
3543           case "Min":
3544           break;
3545           case "Mid":
3546             sa += 3;
3547           break;
3548           case "Max":
3549             sa += 6;
3550           break;
3551         }
3552         if (RegExp.$3 === "slice") {
3553           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3554         } else {
3555           mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3556         }
3557       }
3558       tp.align = sa;
3559       tp.meetOrSlice = mos;
3560     } else if (name === "width") {
3561       /*viewportを更新する*/
3562       tar.viewport.width = tar.width.baseVal.value;
3563     } else if (name === "height") {
3564       tar.viewport.height = tar.height.baseVal.value;
3565     }
3566     evt = name = tv = ovb = par = tp = sa = mos = void 0;
3567   }, false);
3568   this.addEventListener("SVGLoad", function(evt){
3569     /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3570      *処理を書いたもの。属性が書き換わるたびに、再描画される
3571      */
3572     evt.target.addEventListener("DOMAttrModified", function(evt){
3573       var tar,
3574           evtt, tce, slist;
3575       if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3576         tar = evt.target;
3577         if (tar.parentNode) {
3578           evtt = tar.ownerDocument.createEvent("MutationEvents");
3579           evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3580           evtt.target = tar;
3581           evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3582           tce = tar._capter; //tceは登録しておいたリスナーのリスト
3583           for (var j=0,tcli=tce.length;j<tcli;++j){
3584             if (tce[j]) {
3585               tce[j].handleEvent(evtt);
3586             }
3587           }
3588           if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3589             tar._cacheMatrix = void 0; //キャッシュを消去
3590             if (tar.firstChild) {
3591               slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3592               for (var i=0,sli=slist.length;i<sli;++i) {
3593                 tar = slist[i];
3594                 tar._cacheMatrix = void 0;
3595                 evtt = tar.ownerDocument.createEvent("MutationEvents");
3596                 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3597                 evtt.target = tar;
3598                 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3599                 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3600                 for (var j=0,tcli=tce.length;j<tcli;++j){
3601                   if (tce[j]) {
3602                     tce[j].handleEvent(evtt);
3603                   }
3604                 }
3605               }
3606             }
3607           }
3608         }
3609       }
3610       evtt = tar = evt = tce = slist = void 0;
3611     }, false);
3612     evt = void 0;
3613   }, false);
3614   return this;
3615 };
3616 SVGSVGElement.constructor = SVGElement;
3617 SVGSVGElement.prototype = new SVGElement();
3618 /*void*/          SVGSVGElement.prototype.forceRedraw = function() {
3619 };
3620 /*float*/         SVGSVGElement.prototype.getCurrentTime = function(){
3621   return (this._currentTime);
3622 };
3623 /*void*/          SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3624   this._currentTime = seconds;
3625 };
3626 /*SVGNumber*/     SVGSVGElement.prototype.createSVGNumber = function(){
3627   var s = new SVGNumber();
3628   s.value = 0;
3629   return s;
3630 };
3631 /*SVGAngle*/     SVGSVGElement.prototype.createSVGAngle = function(){
3632   var s = new SVGAngle();
3633   s.value = 0;
3634   s.unitType = 1;
3635   return s;
3636 };
3637 /*SVGLength*/     SVGSVGElement.prototype.createSVGLength = function(){
3638   var s = new SVGLength();
3639   s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3640   return s;
3641 };
3642 /*SVGPoint*/      SVGSVGElement.prototype.createSVGPoint = function(){
3643   return new SVGPoint();
3644 };
3645 /*SVGMatrix*/     SVGSVGElement.prototype.createSVGMatrix = function(){
3646   //単位行列を作成
3647   return new SVGMatrix();
3648 };
3649 /*SVGRect*/       SVGSVGElement.prototype.createSVGRect = function(){
3650   return new SVGRect();
3651 };
3652 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransform = function(){
3653   var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3654   return s;
3655 };
3656 /*SVGTransform*/  SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3657   var s = new SVGTransform();
3658   s.setMatrix(matrix);
3659   return s;
3660 };
3661 /*getScreenCTM
3662  *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3663  */
3664 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3665   if (!!this._cacheScreenCTM) { //キャッシュがあれば
3666     return (this._cacheScreenCTM);
3667   }
3668   var vw = this.viewport.width,
3669       vh = this.viewport.height,
3670       vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3671   if (!this.useCurrentView) {
3672     vB = this.viewBox.baseVal;
3673     par = this.preserveAspectRatio.baseVal;    
3674   } else {
3675     vB = this.currentView.viewBox.baseVal;
3676     par = this.currentView.preserveAspectRatio.baseVal;
3677   }
3678   if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3679     this._tx = this._ty = 0;
3680     m = this.createSVGMatrix();
3681     this._cacheScreenCTM = m; //キャッシュを作っておく
3682     return m;
3683   } else {
3684     vbx = vB.x;
3685     vby = vB.y;
3686     vbw = vB.width;
3687     vbh = vB.height;
3688     rw = vw / vbw;
3689     rh = vh / vbh;
3690     xr = 1;
3691     yr = 1;
3692     tx = 0;
3693     ty = 0;
3694     if (par.align === 1) { //none
3695       xr = rw;
3696       yr = rh;
3697       tx = -vbx * xr;
3698       ty = -vby * yr;
3699     } else {
3700       var ax = (par.align + 1) % 3 + 1;
3701       var ay = Math.round(par.align / 3);
3702       switch (par.meetOrSlice) {
3703         case 1: //meet
3704           xr = yr = Math.min(rw, rh);
3705         break;
3706         case 2: //slice
3707           xr = yr = Math.max(rw, rh);
3708         break;
3709       }
3710       tx = -vbx * xr;
3711       ty = -vby * yr;
3712       switch (ax) {
3713         case 1: //xMin
3714         break;
3715         case 2: //xMid
3716           tx += (vw - vbw * xr) / 2;
3717         break;
3718         case 3: //xMax
3719           tx += vw - vbw * xr;
3720         break;
3721       }
3722       switch (ay) {
3723         case 1: //YMin
3724         break;
3725         case 2: //YMid
3726           ty += (vh - vbh * yr) / 2;
3727         break;
3728         case 3: //YMax
3729           ty += vh - vbh * yr;
3730         break;
3731       }
3732     }
3733   }
3734   //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3735   this._tx = tx;
3736   this._ty = ty;
3737   ttps =  this._tar.style;
3738   ttps.marginLeft = tx+ "px";
3739   ttps.marginTop = ty+ "px";
3740   m = this.createSVGMatrix();
3741   m.a = xr;
3742   m.d = yr;
3743   this._cacheScreenCTM = m; //キャッシュを作っておく
3744   vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3745   return m;
3746 };
3747
3748   /*interface SVGZoomAndPan*/
3749   // Zoom and Pan Types
3750 SVGZoomAndPan = {
3751   /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3752   /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3753   /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3754 };
3755
3756 function SVGFitToViewBox() {
3757   /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3758   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3759   return this;
3760 };
3761 function SVGViewSpec(ele) {
3762   SVGFitToViewBox.apply(this, arguments);
3763   /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3764   /*readonly SVGElement*/       this.viewTarget = ele;
3765   /*readonly DOMString*/        this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3766   return this;
3767 };
3768 SVGViewSpec.constructor = SVGFitToViewBox;
3769 SVGViewSpec.prototype = new SVGFitToViewBox();
3770
3771 function SVGGElement(_doc) {
3772   SVGElement.apply(this);
3773   this._tar = _doc.createElement("v:group");
3774   _doc = void 0;
3775   /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3776    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3777    */
3778   this.addEventListener("DOMNodeInserted", function(evt){
3779     var tar = evt.target;
3780     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3781       return; //強制終了させる
3782     }
3783     var tnext = tar.nextSibling,
3784         tpart = tar.parentNode._tar,
3785         isLast = true;
3786     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3787       tpart.insertBefore(tar._tar, tnext._tar);
3788     } else if (tnext && !tnext._tar && tpart) {
3789       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3790        *use要素や実体参照などは_tarプロパティがないことに注意
3791        */
3792       while (tnext) {
3793         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3794           tpart.insertBefore(tar._tar, tnext._tar);
3795           isLast = false;
3796         } 
3797         tnext = tnext.nextSibling;
3798       }
3799       if (isLast) {
3800         tpart.appendChild(tar._tar);
3801       }
3802     } else if (!tnext && tpart) {
3803       tpart.appendChild(tar._tar);      
3804     }
3805     tnext = tpart = isLast = evt = tar = void 0;
3806   }, false);
3807   return this;
3808 };
3809 SVGGElement.constructor = SVGElement;
3810 SVGGElement.prototype = new SVGElement();
3811
3812 function SVGDefsElement() {
3813   SVGElement.apply(this, arguments);
3814   this.style.setProperty("display", "none");
3815   return this;
3816 };
3817 SVGDefsElement.constructor = SVGElement;
3818 SVGDefsElement.prototype = new SVGElement();
3819
3820 function SVGDescElement() {
3821   SVGElement.apply(this, arguments);
3822   return this;
3823 }
3824 SVGDescElement.constructor = SVGElement;
3825 SVGDescElement.prototype = new SVGElement();
3826
3827 function SVGTitleElement() {
3828   SVGElement.apply(this, arguments);
3829   this.addEventListener("DOMCharacterDataModified", function(evt){
3830     evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3831   }, false);
3832   return this;
3833 }
3834 SVGTitleElement.constructor = SVGElement;
3835 SVGTitleElement.prototype = new SVGElement();
3836
3837 function SVGSymbolElement() {
3838   SVGElement.apply(this, arguments);
3839   SVGURIReference.apply(this);
3840   return this;
3841 }
3842 SVGDefsElement.constructor = SVGElement;
3843 SVGDefsElement.prototype = new SVGElement();
3844
3845 function SVGUseElement() {
3846   SVGGElement.apply(this, arguments);
3847   var slen = SVGAnimatedLength;
3848   /*readonly SVGAnimatedLength*/   this.x = new slen();           //use要素のx属性に対応(以下、同様)
3849   /*readonly SVGAnimatedLength*/   this.y = new slen();
3850   /*readonly SVGAnimatedLength*/   this.width = new slen();
3851   /*readonly SVGAnimatedLength*/   this.height = new slen();
3852   slen = void 0;
3853   /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3854   /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3855   this.addEventListener("DOMNodeInserted", function(evt){
3856     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3857       return; //強制終了させる
3858     }
3859     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3860   }, false);
3861   this.addEventListener("S_Load", function(evt){
3862     var tar = evt.target,
3863         style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3864         fontSize = parseFloat(style.getPropertyValue("font-size")),
3865         tgtb = tar.transform.baseVal,
3866         trans = tar.ownerDocument.documentElement.createSVGTransform();
3867     tar.x.baseVal._emToUnit(fontSize);
3868     tar.y.baseVal._emToUnit(fontSize);
3869     tar.width.baseVal._emToUnit(fontSize);
3870     tar.height.baseVal._emToUnit(fontSize);
3871     tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true);
3872     trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3873     tgtb.appendItem(trans);
3874     tar.appendChild(tar.instanceRoot);
3875     evt = trans = tar = evtt = tgtb = style = fontSize = void 0;
3876   }, false);
3877   SVGURIReference.apply(this);
3878   return this;
3879 };
3880 SVGUseElement.constructor = SVGElement;
3881 SVGUseElement.prototype = new SVGElement();
3882
3883 function SVGElementInstance() {
3884   /*EventTargetの代用として
3885    *Nodeオブジェクトを継承させる
3886    */
3887   Node.apply(this, arguments);
3888   /*readonly SVGElement*/ this.correspondingElement;       //use要素で使われる参照先の要素
3889   /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3890   /*readonly SVGElementInstance*/ this.parentNode;
3891   /*readonly SVGElementInstanceList*/ this.childNodes;
3892   /*readonly SVGElementInstance*/ this.firstChild;
3893   /*readonly SVGElementInstance*/ this.lastChild;
3894   /*readonly SVGElementInstance*/ this.previousSibling;
3895   /*readonly SVGElementInstance*/ this.nextSibling;
3896   return this;
3897 };
3898 SVGElementInstance.prototype = new Node();
3899 /*SVGElementInstanceList
3900  */
3901 function SVGElementInstanceList() { 
3902   /*readonly unsigned long*/ this.length = 0;
3903   return this;
3904 };
3905 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3906   return (this[index]);
3907 }
3908 function SVGImageElement(_doc) {
3909   SVGElement.apply(this, arguments);
3910   this._tar = _doc.createElement("v:image");
3911   //以下は、与えられた属性の値に対応する
3912   var slen = SVGAnimatedLength;
3913   /*readonly SVGAnimatedLength*/ this.x = new slen();
3914   /*readonly SVGAnimatedLength*/ this.y = new slen();
3915   /*readonly SVGAnimatedLength*/ this.width = new slen();
3916   /*readonly SVGAnimatedLength*/ this.height = new slen();
3917   _doc = slen = void 0;
3918   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3919   this.addEventListener("DOMNodeInserted", function(evt){
3920     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3921       return; //強制終了させる
3922     }
3923     var tar = evt.target;
3924     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3925     if (tar.nextSibling) {
3926       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3927         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3928       }
3929     } else if (!!tar.parentNode._tar){
3930       tar.parentNode._tar.appendChild(tar._tar);
3931     }
3932     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3933       var tar = evt.target,
3934           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3935           fontSize = parseFloat(style.getPropertyValue("font-size")),
3936           ts = tar._tar.style,
3937           ctm = tar.getScreenCTM(),
3938           po = tar.ownerDocument.documentElement.createSVGPoint(),
3939           fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3940           ttfia;
3941       tar.x.baseVal._emToUnit(fontSize);
3942       tar.y.baseVal._emToUnit(fontSize);
3943       tar.width.baseVal._emToUnit(fontSize);
3944       tar.height.baseVal._emToUnit(fontSize);
3945       ts.position = "absolute";
3946       po.x = tar.x.baseVal.value;
3947       po.y = tar.y.baseVal.value;
3948       po = po.matrixTransform(ctm);
3949       ts.left = po.x + "px";
3950       ts.top = po.y + "px";
3951       ts.width = tar.width.baseVal.value * ctm.a + "px";
3952       ts.height = tar.height.baseVal.value * ctm.d + "px";
3953       if (fillOpacity !== 1) {
3954         ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3955         ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3956         ttfia.Style = 0;
3957         ttfia.Opacity = fillOpacity * 100;
3958         ttfia = void 0;
3959       }
3960       evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
3961     }, false);
3962     evt = tar = void 0;
3963   }, false);
3964   SVGURIReference.apply(this);
3965   return this;
3966 };
3967 SVGImageElement.constructor = SVGElement;
3968 SVGImageElement.prototype = new SVGElement();
3969
3970 function SVGSwitchElement() {
3971   SVGElement.apply(this, arguments);
3972   return this;
3973 };
3974 SVGSwitchElement.constructor = SVGElement;
3975 SVGSwitchElement.prototype = new SVGElement();
3976
3977 //bookmarkletから呼び出されたらtrue
3978 var sieb_s;
3979 function GetSVGDocument(ele) {
3980   this._tar = ele;
3981   this._next = null;
3982   return this;
3983 }
3984 function _ca_() {
3985   if ((NAIBU._that.xmlhttp.readyState === 4)  &&  (NAIBU._that.xmlhttp.status === 200)) {
3986     NAIBU._that._ca();
3987   }
3988 };
3989  GetSVGDocument.prototype = {
3990   /*_initメソッド
3991    *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
3992    */
3993   _init : function() {
3994     /*objeiはobject要素かembed要素*/
3995     var xmlhttp = NAIBU.xmlhttp,
3996         objei = this._tar,
3997         data;
3998     if (this._tar.nodeName === "OBJECT") {
3999       data = "data";
4000     } else {
4001       data = "src";
4002     }
4003     xmlhttp.open("GET", objei.getAttribute(data), true);
4004     objei.style.display = "none";
4005     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4006     this.xmlhttp = xmlhttp;
4007     /*クロージャを利用しないことで、軽量化を計る*/
4008     NAIBU._that = this;
4009     xmlhttp.onreadystatechange = _ca_;
4010     xmlhttp.send(null);
4011     xmlhttp = objei = data = void 0;
4012   },
4013   /*コール関数。全処理を担う*/
4014   _ca : function() {
4015     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4016      *ここでは、responseTextを用いる
4017      */
4018     var ifr = this._tar.previousSibling,
4019         ifcw = ifr.contentWindow,
4020         _doc;
4021     if (ifcw) {
4022       ifr.contentWindow.screen.updateInterval = 999;
4023       _doc = ifr.contentWindow.document;
4024       _doc.write("");
4025       _doc.close(); // これがないと document.body は null になる
4026     } else {        //インラインSVGの場合
4027       _doc = document;
4028     }
4029     if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4030       _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4031       _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4032       var st = _doc.createStyleSheet(),
4033           vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4034       st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4035         + "dn\\:defs{display:none}"
4036         + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4037         + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4038       st = vmlUrl = void 0;
4039     }
4040     DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4041     var str = this.xmlhttp.responseText,
4042         objei = this._tar,
4043         s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4044         tar = s.documentElement,
4045         tview = tar.viewport,
4046         objw, objh, fi, n, attr, att, w, h,
4047         sdt = tar._tar,
4048         sp = _doc.createElement("div"),
4049         dcp = _doc.createElement("v:group"),
4050         backr = _doc.createElement("v:rect"),
4051         style, fontSize, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, backdown, backright,
4052         bfl, bft, bl, text,
4053         _parseFloat = parseFloat,
4054         ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4055           oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4056     if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4057       this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4058       return;
4059     }
4060     s._iframe = ifr;                     //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4061     oba.setAttribute("id","_NAIBU_outline");
4062     _doc.body.appendChild(oba);
4063     sp.style.margin = "-1px,0px,0px,-1px"
4064     if (ifcw) {
4065        _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4066     }
4067     ndoc.async = false;
4068     /*下記のプロパティについては、Microsoftのサイトを参照
4069      *ResolveExternals Property [Second-level DOM]
4070      * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4071      *ValidateOnParse Property [Second-level DOM]
4072      * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4073      */
4074     ndoc.validateOnParse = false;
4075     ndoc.resolveExternals = false;
4076     ndoc.preserveWhiteSpace = true;
4077     ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4078     /*IE6-8のみで使えるupdateIntervalは、
4079      *描画間隔の調整が可能。デフォルトは0。
4080      *スクロール時にバグが起きるので、0に戻してやる必要がある。
4081      */
4082     screen.updateInterval = 999;
4083     if (/&[^;]+;/.test(str)) {
4084       /*以下の処理は、実体参照を使ったとき
4085        *代替の処理を用いて、実体参照を処理するもの
4086        */
4087       var tmp = str;
4088       var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4089       for (var i=0; i<enti.length; i++) {
4090       var map = enti.item(i);
4091       var regex = new RegExp("&"+map.nodeName+";", "g");
4092       tmp = tmp.replace(regex, map.firstChild.xml);
4093       }
4094       ndoc.loadXML(tmp);
4095       tmp = void 0;
4096     }
4097     tview.top = 0;
4098     tview.left = 0;
4099     tview.width = objei.clientWidth;
4100     tview.height = objei.clientHeight;
4101     if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4102       tview.height = screen.availHeight;
4103     }
4104     if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4105       tar.viewport.height = screen.width;
4106     }
4107     objw = objei.getAttribute("width");
4108     objh = objei.getAttribute("height");
4109     if (objw) {
4110       tar.setAttributeNS(null, "width", objw);
4111     }
4112     if (objh) {
4113       tar.setAttributeNS(null, "height", objh);
4114     }
4115     fi = ndoc.documentElement.firstChild;
4116     attr = ndoc.documentElement.attributes;
4117     /*ルート要素のNamedNodeMapを検索する*/
4118     for (var i=0,atli=attr.length;i<atli;++i) {
4119       att = s.importNode(attr[i], false);
4120       tar.setAttributeNodeNS(att);
4121     }
4122     str = attr = void 0;
4123     dcp.style.width = tview.width+ "px";
4124     dcp.style.height = tview.height+ "px";
4125     dcp.coordsize = tview.width+ " " +tview.height;
4126     sp.appendChild(dcp);
4127     if (ifcw) {
4128       _doc.body.appendChild(sp);
4129     } else {
4130       this._tar.parentNode.insertBefore(sp, this._tar);
4131     }
4132     dcp.appendChild(sdt);
4133     while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4134       n = s.importNode(fi, true);
4135       tar.appendChild(n);
4136       fi = fi.nextSibling;
4137     }
4138     fi = void 0;
4139     /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4140      *ドキュメントにそのオブジェクトを結び付けておく
4141      */
4142     s._window = ifcw;
4143     /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4144      *作り出す作業を行う。これは必須
4145      */
4146     style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4147     fontSize = _parseFloat(style.getPropertyValue("font-size"));
4148     tar.x.baseVal._emToUnit(fontSize);
4149     tar.y.baseVal._emToUnit(fontSize);
4150     tar.width.baseVal._emToUnit(fontSize);
4151     tar.height.baseVal._emToUnit(fontSize);
4152     sw = tar.width.baseVal.value;
4153     sh = tar.height.baseVal.value;
4154     backr.style.position = "absolute";
4155     w = tview.width;
4156     h = tview.height;
4157     backr.style.width = w+ "px";
4158     backr.style.height = h+ "px";
4159     backr.style.zIndex = -1;
4160     backr.stroked = "false";
4161     backr.filled = "false";
4162     tar._tar.appendChild(backr);
4163     trstyle = tar._tar.style;
4164     tpstyle = objei.style;
4165     trstyle.visibility = "visible";
4166     trstyle.position = "absolute";
4167     /*以下、画像を切り取り*/
4168     trstyle.overflow = "hidden";
4169     /*ウィンドウ枠の長さを決定する*/
4170     viewWidth = w > sw ? sw : w;
4171     viewHeight = h > sh ? sh : h;
4172     backrs = backr.currentStyle;
4173     bfl = _parseFloat(backrs.left);
4174     bft = _parseFloat(backrs.top);
4175     bl = -tar._tx;                  //blやbtは、ずれを調整するのに使う
4176     bt = -tar._ty;
4177     if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4178       bl = bfl;
4179       dcp.style.left = -bl+ "px";
4180     }
4181     if (bft !== 0 && !isNaN(bfl)) {
4182       bt = bft;
4183       dcp.style.top = -bt+ "px";
4184     }
4185     backright = bl + viewWidth + 1;
4186     backdown = bt + viewHeight + 1;
4187     trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4188     this._document = s;
4189     if ("_svgload_limited" in s.documentElement) {
4190       /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4191        *xlink:href属性が指定されるたびに+1となる。
4192        *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4193        *
4194        *目的:
4195        * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4196        */
4197       s.documentElement._svgload_limited--;
4198       if (s.documentElement._svgload_limited < 0) {
4199         var evt = s.createEvent("SVGEvents");
4200         evt.initEvent("SVGLoad", false, false);
4201         s.documentElement.dispatchEvent(evt);
4202       }
4203     }
4204     //以下、テキストの位置を修正
4205     text = s.documentElement._tar.getElementsByTagName("div");
4206     for (var i=0, texti;text[i];++i) {
4207       texti = text[i];
4208       if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4209         var tis = texti.style;
4210         tis.left = _parseFloat(tis.left) + bl + "px";
4211         tis.top = _parseFloat(tis.top) + bt + "px";
4212         tis = void 0;
4213       }
4214     }
4215     //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4216     ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4217     s._isLoaded = 1;  //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4218     s.defaultView._cache = s.defaultView._cache_ele = null;
4219     oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4220     trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4221     /*IEのメモリリーク対策として、空関数を入力*/
4222     this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4223     if (this._next) {
4224       ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4225       ifr = ifcw = s = void 0;
4226       this._next._init();
4227     } else {
4228       /*全要素の読み込みが終了した場合*/
4229       if (s.implementation._buffer_) {
4230         screen.updateInterval = 0;
4231         /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4232         NAIBU._buff_num = 0;
4233         NAIBU._buff = setInterval(function(){
4234           var n = NAIBU._buff_num,
4235               dbuf = DOMImplementation._buffer_,
4236               dbufli = dbuf.length,
4237               s, evt;
4238           if (dbufli === 0) {
4239             clearInterval(NAIBU._buff);              
4240           } else {
4241             for (var i=0;i<50;++i) {
4242               s = dbuf[n];
4243               evt = dbuf[n+1];
4244               s.dispatchEvent(evt);
4245               n += 2;
4246               s = evt = void 0;
4247               if (n >= dbufli) {
4248                 clearInterval(NAIBU._buff);
4249                 DOMImplementation._buffer_ = null;
4250                 NAIBU.Time.start();
4251                 dbuf = n = dbufli = void 0;
4252                 return;
4253               }
4254             }
4255             NAIBU._buff_num = n;
4256           }
4257           dbuf = n = dbufli = void 0;
4258         }, 1);
4259         ifr = ifcw = s = void 0;
4260       } else {
4261         ifr = ifcw = s = void 0;
4262         NAIBU.Time.start();
4263       }
4264       delete NAIBU.doc;
4265     }
4266   },
4267   /*SVGDocument*/  getSVGDocument : function() {
4268     return (this._document);
4269   }
4270 };
4271 /*空関数(IEのメモリリーク対策)*/
4272 NAIBU.emptyFunction = function() {};
4273
4274 /*SVGStyleElement
4275  *style要素をあらわすオブジェクト
4276  */
4277 function SVGStyleElement(_doc) {
4278   SVGElement.apply(this);
4279   LinkStyle.apply(this);
4280   /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4281    *CSS2 1. Document Object Model Style Sheets
4282    * 1.3. Document Extensions
4283    *   Interface LinkStyle (introduced in DOM Level 2)
4284    * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4285    */
4286   /*以下はそれぞれ、属性の値に対応している*/
4287   /*DOMString*/ this.xmlspace;
4288   /*DOMString*/ this.type = "text/css";
4289   /*DOMString*/ this.media;
4290   /*DOMString*/ this.title;
4291   SVGURIReference.apply(this);
4292   this.addEventListener("DOMAttrModified", function(evt){
4293     if (evt.attrName === "type") {
4294       evt.target.type = evt.newValue;
4295     } else if (evt.attrName === "title") {
4296       evt.target.title = evt.newValue;
4297     }
4298     evt = void 0;
4299   }, false);
4300   this.addEventListener("S_Load", function(evt){
4301     var tar = evt.target,
4302         sheet = tar.sheet,
4303         styleText = tar._text,
4304         tod = tar.ownerDocument,
4305         style = _doc.createElement("style"),
4306         ri, rsc, scri, rsi;
4307     NAIBU._temp_doc = tod;
4308     sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4309     sheet.ownerNode = tar;
4310     /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4311     _doc.documentElement.firstChild.appendChild(style);
4312     style.styleSheet.cssText = styleText;
4313     for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4314       ri = rules[i];
4315       scri = new CSSStyleRule();
4316       scri.selectorText = ri.selectorText;
4317       scri.style.cssText = ri.style.cssText;
4318       rsc = scri.style.cssText.split(";");
4319       for (var j=0, rsli=rsc.length;j<rsli;++j) {
4320         rsi = rsc[j].split(": ");
4321         scri.style.setProperty(rsi[0], rsi[1]);
4322       }
4323       sheet.cssRules[sheet.cssRules.length] = scri;
4324     }
4325     tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4326       var tar = evt.target,
4327           doc = tar.ownerDocument,
4328           rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4329           selector, ru, tcb = tar.className.baseVal || ".,.";
4330       for (var i=0, rli=rules.length;i<rli;++i) {
4331         selector = rules[i].selectorText;
4332         /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4333         ru = tar._rules || [];
4334         if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4335             || (tar.nodeName === selector)) {
4336           ru[ru.length] = rules[i];
4337         }
4338         tar._rules = ru;
4339       }
4340       tar = doc = rules = void 0;
4341     }, true);
4342     tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4343   }, false);
4344   this.addEventListener("DOMNodeInserted", function(evt){
4345     var tar = evt.target;
4346     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4347       if (tar.nodeName === "#cdata-section") {
4348         evt.currentTarget._text = tar.data;
4349       }
4350       return;
4351     }
4352     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4353       var tar = evt.target;
4354       if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4355         var evtt = tar.ownerDocument.createEvent("SVGEvents");
4356         evtt.initEvent("S_Load", false, false);
4357         evt.currentTarget.dispatchEvent(evtt);
4358       }
4359       tar = evt = void 0;
4360     }, false);
4361   }, false);
4362   return this;
4363 };
4364 SVGStyleElement.constructor = SVGElement;
4365 SVGStyleElement.prototype = new SVGElement();
4366
4367 /*SVGPoint
4368  *2次元座標の点(x,y)を表すオブジェクト
4369  */
4370 function SVGPoint() { 
4371   return this;
4372 };
4373 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4374 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4375   /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
4376   var s = new SVGPoint();
4377   s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
4378   s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
4379   return s;
4380 };
4381
4382 function SVGPointList() { 
4383   return this;
4384 };
4385 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4386   SVGPointList.prototype[prop] = SVGStringList.prototype[prop];
4387 }
4388
4389 /*SVGMatrix
4390  *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4391  *[a c e]
4392  *[b d f]
4393  *[0 0 1]
4394  */
4395 function SVGMatrix() { 
4396   return this;
4397 };
4398 SVGMatrix.prototype = {
4399   /*float*/ a : 1,
4400   /*float*/ b : 0,
4401   /*float*/ c : 0,
4402   /*float*/ d : 1,
4403   /*float*/ e : 0,
4404   /*float*/ f : 0,
4405   /*multiplyメソッド
4406    *行列の積を求めて返す
4407    */
4408   /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4409     var s = new SVGMatrix(), m = secondMatrix;
4410     if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
4411       throw (new Error("引数の値がNumber型ではありません"));
4412     }
4413     s.a = this.a * m.a + this.c * m.b;
4414     s.b = this.b * m.a + this.d * m.b;
4415     s.c = this.a * m.c + this.c * m.d;
4416     s.d = this.b * m.c + this.d * m.d;
4417     s.e = this.a * m.e + this.c * m.f + this.e;
4418     s.f = this.b * m.e + this.d * m.f + this.f;
4419     m = secondMatrix = void 0;
4420     return s;
4421   },
4422   /*inverseメソッド
4423    *逆行列を返す
4424    */
4425   /*SVGMatrix*/ inverse : function() {
4426     var s = new SVGMatrix(), n = this._determinant();
4427     if (n !== 0) {
4428       s.a = this.d / n;
4429       s.b = -this.b / n;
4430       s.c = -this.c / n;
4431       s.d = this.a / n;
4432       s.e = (this.c * this.f - this.d * this.e) / n;
4433       s.f = (this.b * this.e - this.a * this.f) / n;
4434       return s;
4435     } else {
4436       throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4437     }
4438   },
4439   /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4440     var m = new SVGMatrix();
4441     m.e = x;
4442     m.f = y;
4443     var s =  this.multiply(m);
4444     m = void 0;
4445     return s;
4446   },
4447   /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4448     var m = new SVGMatrix();
4449     m.a = scaleFactor;
4450     m.d = scaleFactor;
4451     var s =  this.multiply(m);
4452     m = void 0;
4453     return s;
4454   },
4455   /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4456     var m = new SVGMatrix();
4457     m.a = scaleFactorX;
4458     m.d = scaleFactorY;
4459     var s =  this.multiply(m);
4460     m = void 0;
4461     return s;
4462   },
4463   /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4464     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4465     m.a = Math.cos(rad);
4466     m.b = Math.sin(rad);
4467     m.c = -m.b;
4468     m.d = m.a;
4469     var s =  this.multiply(m);
4470     m = rad = void 0;
4471     return s;
4472   },
4473   //座標(x, y)と原点の角度の分だけ、回転する
4474   /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4475     if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4476       throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4477     }
4478     var m = new SVGMatrix(), rad = Math.atan2(y, x);
4479     m.a = Math.cos(rad);
4480     m.b = Math.sin(rad);
4481     m.c = -m.b;
4482     m.d = m.a;
4483     var s =  this.multiply(m);
4484     m = rad = void 0;
4485     return s;
4486   },
4487   /*SVGMatrix*/ flipX : function() {
4488     var m = new SVGMatrix();
4489     m.a = -m.a;
4490     var s =  this.multiply(m);
4491     m = void 0;
4492     return s;
4493   },
4494   /*SVGMatrix*/ flipY : function() {
4495     var m = new SVGMatrix();
4496     m.d = -m.d;
4497     var s =  this.multiply(m);
4498     m = void 0;
4499     return s;
4500   },
4501   /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4502     var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4503     m.c = Math.tan(rad);
4504     var s =  this.multiply(m);
4505     m = void 0;
4506     return s;
4507   },
4508   /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4509     var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4510     m.b = Math.tan(rad);
4511     var s =  this.multiply(m);
4512     m = void 0;
4513     return s;
4514   },
4515   //行列式
4516   /*float*/ _determinant : function() {
4517     return (this.a * this.d - this.b * this.c);
4518   }
4519 };
4520
4521 function SVGTransform() { 
4522   /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4523   return this;
4524 };
4525     // Transform Types
4526   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN   = 0;
4527   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX    = 1;
4528   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4529   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE     = 3;
4530   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE    = 4;
4531   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX     = 5;
4532   /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY     = 6;
4533 SVGTransform.prototype = {
4534   /*ダミーの単位行列。各メソッドで使う*/
4535   _matrix : (new SVGMatrix()),
4536   /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4537   /*readonly float*/ angle : 0,
4538   /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4539     this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4540     this.matrix = this._matrix.multiply(matrix);
4541   },
4542   /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4543     this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4544     this.matrix = this._matrix.translate(tx, ty);
4545   },
4546   /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4547     this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4548     this.matrix = this._matrix.scaleNonUniform(sx, sy);
4549   },
4550   /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4551     this.angle = angle;
4552     this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4553     this.matrix = this._matrix.rotate(angle);
4554     this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4555     this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4556   },
4557   /*void*/ setSkewX : function(/*float*/ angle ) {
4558     this.angle = angle;
4559     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4560     this.matrix = this._matrix.skewX(angle);
4561   },
4562   /*void*/ setSkewY : function(/*float*/ angle ) {
4563     this.angle = angle;
4564     this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4565     this.matrix = this._matrix.skewY(angle);
4566   }
4567 };
4568
4569 function SVGTransformList() { 
4570   return this;
4571 };
4572 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4573   SVGTransformList.prototype[prop] = SVGStringList.prototype[prop];
4574 }
4575 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4576   var t = new SVGTransform();
4577   t.setMatrix(matrix);
4578   return t;
4579 }
4580 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4581   if(this.numberOfItems === 0) {
4582     return null;
4583   } else {
4584     var s = this.getItem(0), m = s.matrix;
4585     for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4586       m = m.multiply(this.getItem(i).matrix);
4587     }
4588     s.setMatrix(m);
4589     this.initialize(s);
4590     return s;
4591   }
4592 }
4593
4594 function SVGAnimatedTransformList() { 
4595   /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4596   return this;
4597 };
4598 function SVGPreserveAspectRatio() { 
4599   /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4600   /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4601   return this;
4602 };
4603 (function(t) {
4604     // Alignment Types
4605   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN  = 0;
4606   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE     = 1;
4607   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4608   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4609   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4610   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4611   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4612   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4613   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4614   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4615   /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4616     // Meet-or-slice Types
4617   /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN   = 0;
4618   /*unsigned short*/ t.SVG_MEETORSLICE_MEET  = 1;
4619   /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4620 })(SVGPreserveAspectRatio);
4621
4622 function SVGAnimatedPreserveAspectRatio() { 
4623   /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4624   return this;
4625 };
4626
4627 function SVGPathSeg() { 
4628   /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4629   /*readonly DOMString*/      this.pathSegTypeAsLetter = null;
4630   return this;
4631 };
4632
4633 (function(t) {
4634     // Path Segment Types
4635   /*unsigned short*/ t.PATHSEG_UNKNOWN                      = 0;
4636   /*unsigned short*/ t.PATHSEG_CLOSEPATH                    = 1;
4637   /*unsigned short*/ t.PATHSEG_MOVETO_ABS                   = 2;
4638   /*unsigned short*/ t.PATHSEG_MOVETO_REL                   = 3;
4639   /*unsigned short*/ t.PATHSEG_LINETO_ABS                   = 4;
4640   /*unsigned short*/ t.PATHSEG_LINETO_REL                   = 5;
4641   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS            = 6;
4642   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL            = 7;
4643   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS        = 8;
4644   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL        = 9;
4645   /*unsigned short*/ t.PATHSEG_ARC_ABS                      = 10;
4646   /*unsigned short*/ t.PATHSEG_ARC_REL                      = 11;
4647   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS        = 12;
4648   /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL        = 13;
4649   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS          = 14;
4650   /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL          = 15;
4651   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS     = 16;
4652   /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL     = 17;
4653   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4654   /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4655 })(SVGPathSeg);
4656 /*SVGPathSegxx
4657  *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4658  */
4659 function SVGPathSegClosePath() {
4660   return this;
4661 };
4662 SVGPathSegClosePath.prototype = {
4663   pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4664   pathSegTypeAsLetter : "z"
4665 };
4666 function SVGPathSegMovetoAbs() { 
4667   /*float* this.x;
4668   /*float* this.y;*/
4669   return this;
4670 };
4671 SVGPathSegMovetoAbs.prototype = {
4672   pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4673   pathSegTypeAsLetter : "M"
4674 };
4675 function SVGPathSegMovetoRel() { 
4676   /*float*/ this.x;
4677   /*float*/ this.y;
4678   return this;
4679 };
4680 SVGPathSegMovetoRel.prototype = {
4681   pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4682   pathSegTypeAsLetter : "m"
4683 };
4684 function SVGPathSegLinetoAbs() { 
4685   /*float* this.x;
4686   /*float* this.y;*/
4687   return this;
4688 };
4689 SVGPathSegLinetoAbs.prototype = {
4690   pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4691   pathSegTypeAsLetter : "L"
4692 };
4693 function SVGPathSegLinetoRel() { 
4694   /*float*/ this.x;
4695   /*float*/ this.y;
4696   return this;
4697 };
4698 SVGPathSegLinetoRel.prototype = {
4699   pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4700   pathSegTypeAsLetter : "l"
4701 };
4702 function SVGPathSegCurvetoCubicAbs() { 
4703   /*float* this.x;
4704   /*float* this.y;
4705   /*float* this.x1;
4706   /*float* this.y1;
4707   /*float* this.x2;
4708   /*float* this.y2;*/
4709   return this;
4710 };
4711 SVGPathSegCurvetoCubicAbs.prototype = {
4712   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4713   pathSegTypeAsLetter : "C"
4714 };
4715 function SVGPathSegCurvetoCubicRel() { 
4716   /*float* this.x;
4717   /*float* this.y;
4718   /*float* this.x1;
4719   /*float* this.y1;
4720   /*float* this.x2;
4721   /*float* this.y2;*/
4722   return this;
4723 };
4724 SVGPathSegCurvetoCubicRel.prototype = {
4725   pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4726   pathSegTypeAsLetter : "c"
4727 };
4728 function SVGPathSegCurvetoQuadraticAbs() { 
4729   /*float*/ this.x;
4730   /*float*/ this.y;
4731   /*float*/ this.x1;
4732   /*float*/ this.y1;
4733   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4734   this.pathSegTypeAsLetter = "Q";
4735   return this;
4736 };
4737 function SVGPathSegCurvetoQuadraticRel() { 
4738   /*float*/ this.x;
4739   /*float*/ this.y;
4740   /*float*/ this.x1;
4741   /*float*/ this.y1;
4742   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4743   this.pathSegTypeAsLetter = "q";
4744   return this;
4745 };
4746
4747 function SVGPathSegArcAbs() { 
4748   /*float*/ this.x;
4749   /*float*/ this.y;
4750   /*float*/ this.r1;
4751   /*float*/ this.r2;
4752   /*float*/ this.angle;
4753   return this;
4754 };
4755 SVGPathSegArcAbs.prototype = {
4756   /*boolean*/ largeArcFlag : true,
4757   /*boolean*/ sweepFlag : true,
4758   pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4759   pathSegTypeAsLetter : "A"
4760 };
4761 function SVGPathSegArcRel() { 
4762   /*float*/ this.x;
4763   /*float*/ this.y;
4764   /*float*/ this.r1;
4765   /*float*/ this.r2;
4766   /*float*/ this.angle;
4767   return this;
4768 };
4769 SVGPathSegArcRel.prototype = {
4770   /*boolean*/ largeArcFlag : true,
4771   /*boolean*/ sweepFlag : true,
4772   pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4773   pathSegTypeAsLetter : "a"
4774 };
4775 function SVGPathSegLinetoHorizontalAbs() { 
4776   /*float*/ this.x;
4777   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4778   this.pathSegTypeAsLetter = "H";
4779   return this;
4780 };
4781 function SVGPathSegLinetoHorizontalRel() { 
4782   /*float*/ this.x;
4783   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4784   this.pathSegTypeAsLetter = "h";
4785   return this;
4786 };
4787 function SVGPathSegLinetoVerticalAbs() { 
4788   /*float*/ this.y;
4789   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4790   this.pathSegTypeAsLetter = "V";
4791   return this;
4792 };
4793 function SVGPathSegLinetoVerticalRel() { 
4794   /*float*/ this.y;
4795   this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4796   this.pathSegTypeAsLetter = "v";
4797   return this;
4798 };
4799 function SVGPathSegCurvetoCubicSmoothAbs() { 
4800   /*float*/ this.x;
4801   /*float*/ this.y;
4802   /*float*/ this.x2;
4803   /*float*/ this.y2;
4804   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4805   this.pathSegTypeAsLetter = "S";
4806   return this;
4807 };
4808 function SVGPathSegCurvetoCubicSmoothRel() {
4809   /*float*/ this.x;
4810   /*float*/ this.y;
4811   /*float*/ this.x2;
4812   /*float*/ this.y2;
4813   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4814   this.pathSegTypeAsLetter = "s";
4815   return this;
4816 };
4817 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4818   /*float*/ this.x;
4819   /*float*/ this.y;
4820   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4821   this.pathSegTypeAsLetter = "T";
4822   return this;
4823 };
4824 function SVGPathSegCurvetoQuadraticSmoothRel() {
4825   /*float*/ this.x;
4826   /*float*/ this.y;
4827   this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4828   this.pathSegTypeAsLetter = "t";
4829   return this;
4830 };
4831 function SVGPathSegList() {
4832   return this;
4833 };
4834 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4835   SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4836 };
4837
4838 /*documentは引数の変数として登録しておく*/
4839 (function(_doc, _math) {
4840 //freeArg関数はunloadで使う解放処理
4841 NAIBU.freeArg = function() {
4842   SVGPathElement = _doc = _math = void 0;
4843 };
4844 //仮のfill属性とstroke属性の処理
4845 NAIBU._setPaint = function(tar, matrix) {
4846   /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4847    *処理を行う。SVGPaintインターフェースをも用いる
4848    */
4849   var tod = tar.ownerDocument,
4850       _doc = tod._document_,
4851       el = tar._tar,
4852       style = tod.defaultView.getComputedStyle(tar, ""),
4853       fill = style.getPropertyCSSValue("fill"),
4854       stroke = style.getPropertyCSSValue("stroke"),
4855       fp = fill.paintType,
4856       sp = stroke.paintType,
4857       fillElement, fc,
4858       num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4859       t, evtt, fillOpacity, strs, cursor, vis, disp,
4860       strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4861   if (!el) {
4862     return;
4863   }
4864   /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4865   while (el.firstChild) {
4866     el.removeChild(el.firstChild);
4867   }
4868   if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4869     if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4870       /*再度、設定。css.jsのsetPropertyを参照*/
4871       style.setProperty("color", style.getPropertyValue("color"));
4872     }
4873     fillElement = _doc.createElement("v:fill");
4874     fc = fill.rgbColor;
4875     num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4876     fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4877     fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4878     if (fillOpacity < 1) {
4879       fillElement.setAttribute("opacity", fillOpacity+"");
4880     }
4881     el.appendChild(fillElement);
4882     fillElement = fc = fillOpacity = void 0;
4883   } else if (fill.uri) {
4884     /*以下では、Gradation関連の要素に、イベントを渡すことで、
4885      *この要素の、グラデーション描画を行う
4886      */
4887     t = tod.getElementById(fill.uri);
4888     if (t) {
4889       evtt = tod.createEvent("MutationEvents");
4890       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
4891       evtt._tar = _doc.createElement("v:fill");
4892       evtt._style = style;
4893       evtt._ttar = tar;
4894       t.dispatchEvent(evtt);
4895       if (t.localName !== "radialGradient") {
4896         el.appendChild(evtt._tar);
4897       }
4898       t = evtt = void 0;
4899     }
4900   } else {
4901     el.filled = "false";
4902   }
4903   if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4904     if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4905       /*再度、設定。css.jsのsetPropertyを参照*/
4906       style.setProperty("color", style.getPropertyValue("color"));
4907     }
4908     strokeElement = _doc.createElement("v:stroke");
4909     sgsw = style.getPropertyCSSValue("stroke-width");
4910     w = tod.documentElement.viewport.width;
4911     h = tod.documentElement.viewport.height;
4912     sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4913     swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4914     strokeElement.setAttribute("weight", swx + "px");
4915     sgsw = w = h = void 0;
4916     if (!stroke.uri) {
4917       fc = stroke.rgbColor;
4918       strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4919       strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4920       if (swx < 1) {
4921         strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4922       }
4923       if (strokeOpacity < 1) {
4924         strokeElement.setAttribute("opacity", strokeOpacity+"");
4925       }
4926       fc = strokeOpacity = void 0;
4927     }
4928     strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4929     strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4930     if (style.getPropertyValue("stroke-linecap") === "butt") {
4931       strokeElement.setAttribute("endcap", "flat");
4932     } else {
4933       strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4934     }
4935     tsd = style.getPropertyValue("stroke-dasharray");
4936     if (tsd !== "none") {
4937       if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4938         strs = tsd.split(",");
4939         for (var i = 0, sli = strs.length; i < sli; ++i) {
4940           strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4941         }
4942         strokedasharray = strs.join(" ");
4943         if (strs.length % 2 === 1) {
4944           strokedasharray += " " + strokedasharray;
4945         }
4946       }
4947       strokeElement.setAttribute("dashstyle", strokedasharray);
4948       tsd = strs = void 0;
4949     }
4950     el.appendChild(strokeElement);
4951     strokeElement = tsd = void 0;
4952   } else {
4953     el.stroked = "false";
4954   }
4955   cursor = style.getPropertyCSSValue("cursor");
4956   if (cursor && !cursor._isDefault) { //初期値でないならば
4957     el.style.cursor = cursor.cssText.split(":")[1];
4958   }
4959   vis = style.getPropertyCSSValue("visibility");
4960   if (vis && !vis._isDefault) {
4961     el.style.visibility = vis.cssText.split(":")[1];
4962   }
4963   disp = style.getPropertyCSSValue("display");
4964   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4965     el.style.display = "none";
4966    } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
4967     el.style.display = "inline-block";
4968   }
4969   tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
4970 };
4971
4972 function SVGPathElement(_doc) {
4973   SVGElement.apply(this);
4974   this._tar = _doc.createElement("v:shape");
4975   //interface SVGAnimatedPathData
4976   var sp = SVGPathSegList;
4977   /*readonly SVGPathSegList*/ this.pathSegList = new sp();
4978   this.animatedPathSegList = this.pathSegList;
4979   /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
4980   sp = _doc = void 0;
4981   this.animatedNormalizedPathSegList = this.normalizedPathSegList;
4982   /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
4983   //以下は、d属性に変更があった場合の処理
4984   this.addEventListener("DOMAttrModified", this._attrModi, false);
4985   /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
4986    *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
4987    */
4988   this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
4989   return this;
4990 };
4991 SVGPathElement.constructor = SVGElement;
4992 SVGPathElement.prototype = new SVGElement();
4993 (function(_sproto) {
4994 _sproto._attrModi = function(evt){
4995   var tar = evt.target;
4996   if (evt.attrName === "d" && evt.newValue !== ""){
4997     /* d属性の値が空の場合は、描画を行わないようにする
4998      * 
4999      *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5000      */
5001     var tnl = tar.normalizedPathSegList,
5002         tlist = tar.pathSegList;
5003     if (tnl.numberOfItems > 0) {
5004       tnl.clear();
5005       tlist.clear();
5006     }
5007     /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5008      *JSONにおける表現は以下のとおり
5009      *D = [["M", 20, 30], ["L", 20 40]]
5010      */
5011     var taco = tar._com,
5012         sgs = taco.isSp,
5013         dd = evt.newValue
5014     .replace(taco.isRa, " -")
5015     .replace(taco.isRb, " ")
5016     .replace(taco.isRc, ",$1 ")
5017     .replace(taco.isRd, ",$1 1")
5018     .replace(taco.isRe, "")
5019     .split(","),
5020         dli=dd.length,
5021         isZ = taco._isZ,
5022         isM = taco._isM,
5023         isC = taco._isC,
5024         isL = taco._isL,
5025         tcc = tar.createSVGPathSegCurvetoCubicAbs,
5026         tcll = tar.createSVGPathSegLinetoAbs;
5027     for (var i=0;i<dli;++i) {
5028       var di = dd[i].match(sgs),
5029           s;
5030       for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5031         if (isC[dii]) {
5032           s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5033           j += 5;
5034         } else if (isL[dii]) {
5035           s = tcll(+di[j], +di[j+1]);
5036           ++j;
5037         } else if (isM[dii]) {
5038           s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5039           ++j;
5040         } else if (isZ[dii]) {
5041           s = tar.createSVGPathSegClosePath();
5042         } else if (dii === "A") {
5043           s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5044           j += 6;
5045         } else if (dii === "m") {
5046           s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5047           ++j;
5048         } else if (dii === "l") {
5049           s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5050           ++j;
5051         } else if (dii === "c") {
5052           s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5053           j += 5;
5054         } else if (dii === "Q") {
5055           s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5056           j += 3;
5057         } else if (dii === "q") {
5058           s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5059           j += 3;
5060         } else if (dii === "a") {
5061           s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5062           j += 6;
5063         } else if (dii === "S") {
5064           s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5065           j += 3;
5066         } else if (dii === "s") {
5067           s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5068           j += 3;
5069         } else if (dii === "T") {
5070           s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5071           ++j;
5072         } else if (dii === "t") {
5073           s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5074           ++j;
5075         } else if (dii === "H") {
5076           s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5077         } else if (dii === "h") {
5078           s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5079         } else if (dii === "V") {
5080           s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5081         } else if (dii === "v") {
5082           s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5083         } else {
5084           s = new SVGPathSeg();
5085         }
5086         tlist.appendItem(s);
5087       }
5088     }
5089     di = s = sgs = dd = void 0;
5090     /*以下の処理は、pathSegListからnormalizedPathSegListへの
5091      *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5092      */
5093     var cx = 0, cy = 0,         //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5094         xn = 0, yn = 0,         //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5095         startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5096     for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5097       var ti = tlist.getItem(j),
5098           ts = ti.pathSegType,
5099           dii = ti.pathSegTypeAsLetter;
5100       if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5101       } else {
5102         var rx = cx, ry = cy;   //rx, ryは前のセグメントの終了点
5103         if (ts % 2 === 1) {     //相対座標ならば
5104           cx += ti.x;
5105           cy += ti.y;
5106         } else {
5107           cx = ti.x;
5108           cy = ti.y;
5109         }
5110         if (isC[dii]) {
5111           tnl.appendItem(ti);
5112         } else if (isL[dii]) {
5113           tnl.appendItem(ti);
5114         } else if (isM[dii]) {
5115           if (j !== 0) {
5116             /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5117              *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5118              *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5119              */
5120             var tg = tlist.getItem(j-1);
5121             if (tg.pathSegTypeAsLetter === "M") {
5122               tnl.appendItem(tcll(cx, cy));
5123               continue;
5124             }
5125           }
5126           startx = cx;
5127           starty = cy;
5128           tnl.appendItem(ti);
5129         } else if (dii === "m") {
5130           if (j !== 0) {
5131             var tg = tlist.getItem(j-1);
5132             if (tg.pathSegTypeAsLetter === "m") {
5133               tnl.appendItem(tcll(cx, cy));
5134               continue;
5135             }
5136           }
5137           startx = cx;
5138           starty = cy;
5139           tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5140         } else if (dii === "l") {
5141           tnl.appendItem(tcll(cx, cy));
5142         } else if (dii === "c") {
5143           tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5144         } else if (isZ[dii]) {
5145           cx = startx;
5146           cy = starty;
5147           tnl.appendItem(ti);
5148         } else if (dii === "Q") {
5149           xn = 2*cx - ti.x1;
5150           yn = 2*cy - ti.y1;
5151           //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5152           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));
5153         } else if (dii === "q") {
5154           var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5155           xn = 2*cx - x1;
5156           yn = 2*cy - y1;
5157           tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5158           x1 = y1 = void 0;
5159         } else if (dii === "A" || dii === "a") {
5160           (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5161             /*以下は、Arctoを複数のCuvetoに変換する処理
5162              *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5163              *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5164              */
5165             if (ti.r1 === 0 || ti.r2 === 0) {
5166               return;
5167             }
5168             var fS = ti.sweepFlag,
5169                 psai = ti.angle,
5170                 r1 = _math.abs(ti.r1),
5171                 r2 = _math.abs(ti.r2),
5172                 ctx = (rx - cx) / 2,  cty = (ry - cy) / 2,
5173                 cpsi = _math.cos(psai * _math.PI / 180),
5174                 spsi = _math.sin(psai * _math.PI / 180),
5175                 rxd = cpsi*ctx + spsi*cty,
5176                 ryd = -1*spsi*ctx + cpsi*cty,
5177                 rxdd = rxd * rxd, rydd = ryd * ryd,
5178                 r1x = r1 * r1,
5179                 r2y = r2 * r2,
5180                 lamda = rxdd/r1x + rydd/r2y,
5181                 sds;
5182             if (lamda > 1) {
5183               r1 = _math.sqrt(lamda) * r1;
5184               r2 = _math.sqrt(lamda) * r2;
5185               sds = 0;
5186             }  else{
5187               var seif = 1;
5188               if (ti.largeArcFlag === fS) {
5189                 seif = -1;
5190               }
5191               sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5192             }
5193             var txd = sds*r1*ryd / r2,
5194                 tyd = -1 * sds*r2*rxd / r1,
5195                 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5196                 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5197                 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5198                 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5199                 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5200                 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5201             if (!fS  &&  dr > 0) {
5202               dr -=   2*_math.PI;
5203             } else if (fS  &&  dr < 0) {
5204               dr += 2*_math.PI;
5205             }
5206             var sse = dr * 2 / _math.PI,
5207                 seg = _math.ceil(sse<0 ? -1*sse  :  sse),
5208                 segr = dr / seg,
5209                 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5210                 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5211                 spsir1 = spsi * r1, spsir2 = spsi * r2,
5212                 mc = _math.cos(s1),
5213                 ms = _math.sin(s1),
5214                 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5215                 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5216             for (var n = 0; n < seg; ++n) {
5217               s1 += segr;
5218               mc = _math.cos(s1);
5219               ms = _math.sin(s1);
5220               var x3 = cpsir1*mc - spsir2*ms + tx,
5221                   y3 = spsir1*mc + cpsir2*ms + ty,
5222                   dx = -t * (cpsir1*ms + spsir2*mc),
5223                   dy = -t * (spsir1*ms - cpsir2*mc);
5224               tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5225               x2 = x3 + dx;
5226               y2 = y3 + dy;
5227             }
5228             ti= cx= cy= rx= ry= tar= tnl = void 0;
5229           })(ti, cx, cy, rx, ry, tar, tnl);
5230         } else if (dii === "S") {
5231           if (j !== 0) {
5232             var tg = tnl.getItem(tnl.numberOfItems-1);
5233             if (tg.pathSegTypeAsLetter === "C") {
5234               var x1 = 2*tg.x - tg.x2,
5235                   y1 = 2*tg.y - tg.y2;
5236             } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5237               var x1 = rx,
5238                   y1 = ry;
5239             }
5240           } else {
5241             var x1 = rx,
5242                 y1 = ry;
5243           }
5244           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5245           x1 = y1 = void 0;
5246         } else if (dii === "s") {
5247           if (j !== 0) {
5248             var tg = tnl.getItem(tnl.numberOfItems-1);
5249             if (tg.pathSegTypeAsLetter === "C") {
5250               var x1 = 2*tg.x - tg.x2,
5251                   y1 = 2*tg.y - tg.y2;
5252             } else {
5253               var x1 = rx,
5254                   y1 = ry;
5255             }
5256           } else {
5257             var x1 = rx,
5258                 y1 = ry;
5259           }
5260           tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5261           x1 = y1 = void 0;
5262         } else if (dii === "T" || dii === "t") {
5263           if (j !== 0) {
5264             var tg = tlist.getItem(j-1);
5265             if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5266              } else {
5267               xn = rx, yn = ry;
5268             }
5269           } else {
5270             xn = rx, yn = ry;
5271           }
5272           tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5273           xn = 2*cx - xn;
5274           yn = 2*cy - yn;
5275           xx1 = yy1 = void 0;
5276         } else if (dii === "H" || dii === "h") {
5277           tnl.appendItem(tcll(cx, ry));
5278           cy = ry; //勝手にti.yが0としているため
5279         } else if (dii === "V" || dii === "v") {
5280           tnl.appendItem(tcll(rx, cy));
5281           cx = rx;
5282         }
5283       }
5284     }
5285   }
5286   evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5287 };
5288 _sproto._nodeInsert = function(evt){
5289   var tar = evt.target;
5290   if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5291     return; //強制終了させる
5292   }
5293   var tnext = tar.nextSibling,
5294       tpart = tar.parentNode._tar,
5295       isLast = true;
5296   if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5297     tpart.insertBefore(tar._tar, tnext._tar);
5298   } else if (tnext && !tnext._tar && tpart) {
5299     /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5300      *use要素や実体参照などは_tarプロパティがないことに注意
5301      */
5302     while (tnext) {
5303       if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5304         tpart.insertBefore(tar._tar, tnext._tar);
5305         isLast = false;
5306       } 
5307       tnext = tnext.nextSibling;
5308     }
5309     if (isLast) {
5310       tpart.appendChild(tar._tar);
5311     }
5312   } else if (!tnext && tpart) {
5313     tpart.appendChild(tar._tar);      
5314   }
5315   tnext = tpart = isLast = void 0;
5316   tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5317   evt = tar = void 0;
5318 };
5319 _sproto._nodeInsertInto = function(evt){
5320   /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5321    *SVGのd属性をVMLに変換していく処理である。
5322    */
5323   var tar = evt.target,
5324       matrix = tar.getScreenCTM(),
5325       tlist = tar.normalizedPathSegList,
5326       dat = [],
5327       ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5328       cname = tar._com._nameCom,
5329       isZ = tar._com._isZ, isC = tar._com._isC,
5330       mr = _math.round;
5331   for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5332     var ti = tlist[i],
5333         tx = ti.x,
5334         ty = ti.y,
5335         tps = ti.pathSegTypeAsLetter,
5336         t = cname[tps];
5337     if (isC[tps]) {
5338       /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5339        *[ma mc me]   [x]
5340        *[mb md mf] * [y]
5341        *[0  0  1 ]   [1]
5342        */
5343       t += [mr(ma*ti.x1 + mc*ti.y1 + me),
5344              mr(mb*ti.x1 + md*ti.y1 + mf),
5345              mr(ma*ti.x2 + mc*ti.y2 + me),
5346              mr(mb*ti.x2 + md*ti.y2 + mf),
5347              mr(ma*tx + mc*ty + me),
5348              mr(mb*tx + md*ty + mf)].join(" ");
5349     } else if (!isZ[tps]) {
5350       t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
5351     }
5352     dat[i] = t;
5353   }
5354   var vi = tar.ownerDocument.documentElement,
5355       tt = tar._tar;
5356   dat.push(" e");
5357   tt.path = dat.join(" ");
5358   tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5359   NAIBU._setPaint(tar, matrix);
5360   delete tar._cacheMatrix;
5361   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;
5362 };
5363 _sproto._com = {
5364   _nameCom : {
5365     z : " x ",
5366     Z : " x ",
5367     C : "c",
5368     L : "l",
5369     M : "m"
5370   },
5371   _isZ : {
5372     z : 1,
5373     Z : 1
5374   },
5375   _isC : {
5376     C : 1
5377   },
5378   _isL : {
5379     L : 1
5380   },
5381   _isM : {
5382     M : 1
5383   },
5384   isRa : /\-/g,
5385   isRb : /,/g,
5386   isRc : /([a-yA-Y])/g,
5387   isRd : /([zZ])/g,
5388   isRe : /,/,
5389   isSp : /\S+/g
5390 };
5391   /*float*/         _sproto.getTotalLength = function() {
5392     var s = 0,
5393         nl = this.normalizedPathSegList;
5394     for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5395       var seg = nl.getItem(i);
5396       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5397         var ps = nl.getItem(i-1);
5398         s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5399       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5400         var ps = nl.getItem(i-1), dd = 0;
5401         /*2点のハンドルを結んだ線分の3辺と、
5402          *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5403          *
5404          *注意
5405          *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5406          *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5407          */
5408         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5409         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5410         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5411         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5412         s += dd / 2;
5413       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5414         var ps = nl.getItem(i-1), ms = nl.getItem(0);
5415         s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5416       }
5417
5418     }
5419     this.pathLength.baseVal = s;
5420     return s;
5421   };
5422   /*SVGPoint*/      _sproto.getPointAtLength = function(/*float*/ distance ) {
5423     var segn = this.getPathSegAtLength(distance),
5424         x = 0,
5425         y = 0,
5426         nl = this.normalizedPathSegList,
5427         seg = nl.getItem(segn),
5428         s = this.ownerDocument.documentElement.createSVGPoint();
5429     if ((segn-1) <= 0) {
5430       s.x = seg.x;
5431       s.y = seg.y;
5432       return s;
5433     }
5434     var ps = nl.getItem(segn-1);
5435     if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5436       var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5437       var t = (segl + this._dis) / segl;
5438       s.x = ps.x + t * (seg.x-ps.x);
5439       s.y = ps.y + t * (seg.y-ps.y);
5440     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5441       var dd = 0;
5442       dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5443       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5444       dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5445       dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5446       var segl = dd / 2;
5447       var t = (segl + this._dis) / segl;
5448       /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5449        *使って、ポイントの座標を演算する
5450        */
5451       s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5452            +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5453            +3*(seg.x1 - ps.x) * t
5454            +ps.x;
5455       s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5456            +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5457            +3*(seg.y1 - ps.y) * t
5458            +ps.y;
5459     } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5460       s.x = seg.x;
5461       s.y = seg.y;
5462     } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5463       var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5464       var t = (segl + this._dis) / segl;
5465       s.x = ms.x + t * (seg.x-ms.x);
5466       s.y = ms.y + t * (seg.y-ms.y);
5467     }
5468     return s;
5469   };
5470   /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5471     var nl = this.normalizedPathSegList; //仕様ではpathSegList
5472     for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5473       var seg = nl.getItem(i);
5474       if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5475         var ps = nl.getItem(i-1);
5476         distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5477       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5478         var ps = nl.getItem(i-1), dd = 0;
5479         dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5480         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5481         dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5482         dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5483         distance -= dd / 2;
5484         dd = void 0;
5485       } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5486         var ps = nl.getItem(i-1), ms = nl.getItem(0);
5487         distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5488       }
5489       if (distance <= 0) {
5490         /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5491         this._dis = distance;
5492         distance = void 0;
5493         return i;
5494       }
5495     }
5496     /*もし、distanceがパスの距離よりも長い場合、
5497      *最後のセグメントの番号を返す
5498      *なお、これはSVG1.1の仕様の想定外のこと
5499      */
5500     return (nl.numberOfItems - 1);
5501   };
5502   /*SVGPathSegClosePath*/    _sproto.createSVGPathSegClosePath = function() {
5503     var _SVGPathSegClosePath = SVGPathSegClosePath;
5504     return (new _SVGPathSegClosePath());
5505   };
5506   /*SVGPathSegMovetoAbs*/    _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5507     var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5508     s.x = x;
5509     s.y = y;
5510     return s;
5511   };
5512   /*SVGPathSegMovetoRel*/    _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5513     var s = new SVGPathSegMovetoRel();
5514     s.x = x;
5515     s.y = y;
5516     return s;
5517   };
5518   /*SVGPathSegLinetoAbs*/    _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5519     var s = new SVGPathSegLinetoAbs();
5520     s.x = x;
5521     s.y = y;
5522     return s;
5523   };
5524   /*SVGPathSegLinetoRel*/    _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5525     var s = new SVGPathSegLinetoRel();
5526     s.x = x;
5527     s.y = y;
5528     return s;
5529   };
5530   /*SVGPathSegCurvetoCubicAbs*/    _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5531     var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5532     s.x = x;
5533     s.y = y;
5534     s.x1 = x1;
5535     s.y1 = y1;
5536     s.x2 = x2;
5537     s.y2 = y2;
5538     return s;
5539   };
5540   /*SVGPathSegCurvetoCubicRel*/    _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5541     var s = new SVGPathSegCurvetoCubicRel();
5542     s.x = x;
5543     s.y = y;
5544     s.x1 = x1;
5545     s.y1 = y1;
5546     s.x2 = x2;
5547     s.y2 = y2;
5548     return s;
5549   };
5550   /*SVGPathSegCurvetoQuadraticAbs*/    _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5551     var s = new SVGPathSegCurvetoQuadraticAbs();
5552     s.x = x;
5553     s.y = y;
5554     s.x1 = x1;
5555     s.y1 = y1;
5556     return s;
5557   };
5558   /*SVGPathSegCurvetoQuadraticRel*/    _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5559     var s = new SVGPathSegCurvetoQuadraticRel();
5560     s.x = x;
5561     s.y = y;
5562     s.x1 = x1;
5563     s.y1 = y1;
5564     return s;
5565   };
5566   /*SVGPathSegArcAbs*/    _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5567     var s = new SVGPathSegArcAbs();
5568     s.x = x;
5569     s.y = y;
5570     s.r1 = r1;
5571     s.r2 = r2;
5572     s.angle = angle;
5573     s.largeArcFlag = largeArcFlag;
5574     s.sweepFlag = sweepFlag;
5575     return s;
5576   };
5577   /*SVGPathSegArcRel*/    _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5578     var s = new SVGPathSegArcRel();
5579     s.x = x;
5580     s.y = y;
5581     s.r1 = r1;
5582     s.r2 = r2;
5583     s.angle = angle;
5584     s.largeArcFlag = largeArcFlag;
5585     s.sweepFlag = sweepFlag;
5586     return s;
5587   };
5588   /*SVGPathSegLinetoHorizontalAbs*/    _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5589     var s = new SVGPathSegLinetoHorizontalAbs();
5590     s.x = x;
5591     s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5592     return s;
5593   };
5594   /*SVGPathSegLinetoHorizontalRel*/    _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5595     var s = new SVGPathSegLinetoHorizontalRel();
5596     s.x = x;
5597     s.y = 0;
5598     return s;
5599   };
5600   /*SVGPathSegLinetoVerticalAbs*/    _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5601     var s = new SVGPathSegLinetoVerticalAbs();
5602     s.x = 0;
5603     s.y = y;
5604     return s;
5605   };
5606   /*SVGPathSegLinetoVerticalRel*/    _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5607     var s = new SVGPathSegLinetoVerticalRel();
5608     s.x = 0;
5609     s.y = y;
5610     return s;
5611   };
5612   /*SVGPathSegCurvetoCubicSmoothAbs*/    _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5613     var s = new SVGPathSegCurvetoCubicSmoothAbs();
5614     s.x = x;
5615     s.y = y;
5616     s.x2 = x2;
5617     s.y2 = y2;
5618     return s;
5619   };
5620   /*SVGPathSegCurvetoCubicSmoothRel*/    _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5621     var s = new SVGPathSegCurvetoCubicSmoothRel();
5622     s.x = x;
5623     s.y = y;
5624     s.x2 = x2;
5625     s.y2 = y2;
5626     return s;
5627   };
5628   /*SVGPathSegCurvetoQuadraticSmoothAbs*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5629     var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5630     s.x = x;
5631     s.y = y;
5632     return s;
5633   };
5634   /*SVGPathSegCurvetoQuadraticSmoothRel*/    _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5635     var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5636     s.x = x;
5637     s.y = y;
5638     return s;
5639   };
5640 })(SVGPathElement.prototype)
5641   NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5642 })(document, Math);
5643
5644 function SVGRectElement(_doc) {
5645   SVGElement.apply(this);
5646   this._tar = _doc.createElement("v:shape");
5647   var slen = SVGAnimatedLength;
5648   /*readonly SVGAnimatedLength*/ this.x = new slen();
5649   /*readonly SVGAnimatedLength*/ this.y = new slen();
5650   /*readonly SVGAnimatedLength*/ this.width = new slen();
5651   /*readonly SVGAnimatedLength*/ this.height = new slen();
5652   /*readonly SVGAnimatedLength*/ this.rx = new slen();
5653   /*readonly SVGAnimatedLength*/ this.ry = new slen();
5654   _doc = slen = void 0;
5655   this.addEventListener("DOMNodeInserted", function(evt){
5656     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5657       return; //強制終了させる
5658     }
5659     var tar = evt.target,
5660         tnext = tar.nextSibling,
5661         tpart = tar.parentNode._tar,
5662         isLast = true;
5663     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5664       tpart.insertBefore(tar._tar, tnext._tar);
5665     } else if (tnext && !tnext._tar && tpart) {
5666       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5667        *use要素や実体参照などは_tarプロパティがないことに注意
5668        */
5669       while (tnext) {
5670         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5671           tpart.insertBefore(tar._tar, tnext._tar);
5672           isLast = false;
5673         } 
5674         tnext = tnext.nextSibling;
5675       }
5676       if (isLast) {
5677         tpart.appendChild(tar._tar);
5678       }
5679     } else if (!tnext && tpart) {
5680       tpart.appendChild(tar._tar);      
5681     }
5682     tnext = tpart = isLast = void 0;
5683     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5684       var tar = evt.target,
5685           style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5686           fontSize = parseFloat(style.getPropertyValue("font-size"));
5687       tar.x.baseVal._emToUnit(fontSize);
5688       tar.y.baseVal._emToUnit(fontSize);
5689       tar.width.baseVal._emToUnit(fontSize);
5690       tar.height.baseVal._emToUnit(fontSize);
5691       var rx = tar.getAttributeNS(null, "rx"),
5692           ry = tar.getAttributeNS(null, "ry"),
5693           x = tar.x.baseVal.value,
5694           y = tar.y.baseVal.value,
5695           xw = x + tar.width.baseVal.value,
5696           yh = y + tar.height.baseVal.value,
5697           list;
5698       if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5699         tar.rx.baseVal._emToUnit(fontSize);
5700         tar.ry.baseVal._emToUnit(fontSize);
5701         var thrx = tar.rx.baseVal,
5702             thry = tar.ry.baseVal,
5703             twidth = tar.width.baseVal.value,
5704             theight = tar.height.baseVal.value;
5705         thrx.value = rx ? thrx.value : thry.value;
5706         thry.value = ry ? thry.value : thrx.value;
5707         //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5708         if (thrx.value > twidth / 2) {
5709           thrx.value = twidth / 2;
5710         }
5711         if (thry.value > theight / 2) {
5712           thry.value = theight / 2;
5713         }
5714         var rxv = thrx.value,
5715             ryv = thry.value,
5716             rrx = rxv * 0.55228,
5717             rry = ryv * 0.55228,
5718             a = xw - rxv,
5719             b = x + rxv,
5720             c = y + ryv,
5721             d = yh - ryv;
5722         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];
5723       } else {
5724         list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5725       }
5726       //以下は、配列listそのものをCTMで座標変換していく処理
5727       var par = tar.ownerDocument.documentElement,
5728           ctm = tar.getScreenCTM(),
5729           dat, p, pmt,
5730           ele = tar._tar,
5731           vi = tar.ownerDocument.documentElement,
5732           w = vi.width.baseVal.value,
5733           h = vi.height.baseVal.value,
5734           mr = Math.round;
5735       for (var i=0, lili=list.length;i<lili;) {
5736         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5737           ++i;
5738           continue;
5739         }
5740         p = par.createSVGPoint();
5741         p.x = list[i];
5742         p.y = list[i+1];
5743         pmt = p.matrixTransform(ctm);
5744         list[i] = mr(pmt.x);
5745         ++i;
5746         list[i] = mr(pmt.y);
5747         ++i;
5748         p = pmt = void 0;
5749       }
5750       dat = list.join(" ");
5751       //VMLに結び付けていく
5752       ele.path = dat;
5753       ele.coordsize = w + " " + h;
5754       NAIBU._setPaint(tar, ctm);
5755       delete tar._cacheMatrix;
5756       evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
5757     }, false);
5758     evt = tar = void 0;
5759   }, false);
5760   return this;
5761 };
5762 SVGRectElement.constructor = SVGElement;
5763 SVGRectElement.prototype = new SVGElement();
5764
5765 function SVGCircleElement(_doc) { 
5766   SVGElement.apply(this);
5767   this._tar = _doc.createElement("v:shape");
5768   var sl = SVGAnimatedLength;
5769   /*readonly SVGAnimatedLength*/ this.cx = new sl();
5770   /*readonly SVGAnimatedLength*/ this.cy = new sl();
5771   /*readonly SVGAnimatedLength*/ this.r = new sl();
5772   _doc = sl = void 0;
5773   this.addEventListener("DOMNodeInserted", function(evt){
5774     var tar = evt.target;
5775     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5776       return; //強制終了させる
5777     }
5778     var tnext = tar.nextSibling,
5779         tpart = tar.parentNode._tar,
5780         isLast = true;
5781     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5782       tpart.insertBefore(tar._tar, tnext._tar);
5783     } else if (tnext && !tnext._tar && tpart) {
5784       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5785        *use要素や実体参照などは_tarプロパティがないことに注意
5786        */
5787       while (tnext) {
5788         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5789           tpart.insertBefore(tar._tar, tnext._tar);
5790           isLast = false;
5791         } 
5792         tnext = tnext.nextSibling;
5793       }
5794       if (isLast) {
5795         tpart.appendChild(tar._tar);
5796       }
5797     } else if (!tnext && tpart) {
5798       tpart.appendChild(tar._tar);      
5799     }
5800     tnext = tpart = isLast = void 0;
5801     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5802       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5803       var fontSize = parseFloat(style.getPropertyValue("font-size"));
5804       tar.cx.baseVal._emToUnit(fontSize);
5805       tar.cy.baseVal._emToUnit(fontSize);
5806       tar.r.baseVal._emToUnit(fontSize);
5807       var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value;
5808       var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5809         var rrx = rx * 0.55228, rry = ry * 0.55228;
5810         var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
5811         //以下は、配列listそのものをCTMで座標変換していく処理
5812         var par = tar.ownerDocument.documentElement,
5813             ctm = tar.getScreenCTM(),
5814             mr = Math.round;
5815         for (var i=0, lili=list.length;i<lili;) {
5816           if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5817             ++i;
5818             continue;
5819           }
5820           var p = par.createSVGPoint();
5821           p.x = list[i];
5822           p.y = list[i+1];
5823           var pmt = p.matrixTransform(ctm);
5824           list[i] = mr(pmt.x);
5825           ++i;
5826           list[i] = mr(pmt.y);
5827           ++i;
5828           p = pmt = void 0;
5829         }
5830         var dat = list.join(" ");
5831         //VMLに結び付けていく
5832         var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5833         var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5834         ele.path = dat;
5835         ele.coordsize = w + " " + h;
5836         NAIBU._setPaint(tar, ctm);
5837         delete tar._cacheMatrix;
5838         evt = tar = list = mr = style = fontSize = dat = ele = void 0;
5839     }, false);
5840     evt = tar = void 0;
5841   }, false);
5842   return this;
5843 };
5844 SVGCircleElement.constructor = SVGElement;
5845 SVGCircleElement.prototype = new SVGElement();
5846
5847 function SVGEllipseElement(_doc) { 
5848   SVGElement.apply(this);
5849   this._tar = _doc.createElement("v:shape");
5850   var sl = SVGAnimatedLength;
5851   /*readonly SVGAnimatedLength*/ this.cx = new sl();
5852   /*readonly SVGAnimatedLength*/ this.cy = new sl();
5853   /*readonly SVGAnimatedLength*/ this.rx = new sl();
5854   /*readonly SVGAnimatedLength*/ this.ry = new sl();
5855   _doc = sl = void 0;
5856   this.addEventListener("DOMNodeInserted", function(evt){
5857     var tar = evt.target;
5858     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5859       return; //強制終了させる
5860     }
5861     var tnext = tar.nextSibling,
5862     tpart = tar.parentNode._tar,
5863     isLast = true;
5864     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5865       tpart.insertBefore(tar._tar, tnext._tar);
5866     } else if (tnext && !tnext._tar && tpart) {
5867       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5868        *use要素や実体参照などは_tarプロパティがないことに注意
5869        */
5870       while (tnext) {
5871         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5872           tpart.insertBefore(tar._tar, tnext._tar);
5873           isLast = false;
5874         } 
5875         tnext = tnext.nextSibling;
5876       }
5877       if (isLast) {
5878         tpart.appendChild(tar._tar);
5879       }
5880     } else if (!tnext && tpart) {
5881       tpart.appendChild(tar._tar);      
5882     }
5883     tnext = tpart = isLast = void 0;
5884     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5885       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5886       var fontSize = parseFloat(style.getPropertyValue("font-size"));
5887       tar.cx.baseVal._emToUnit(fontSize);
5888       tar.cy.baseVal._emToUnit(fontSize);
5889       tar.rx.baseVal._emToUnit(fontSize);
5890       tar.ry.baseVal._emToUnit(fontSize);
5891       var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value;
5892       var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5893       var rrx = rx * 0.55228, rry = ry * 0.55228;
5894       var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
5895       //以下は、配列listそのものをCTMで座標変換していく処理
5896       var par = tar.ownerDocument.documentElement,
5897           ctm = tar.getScreenCTM(),
5898           mr = Math.round;
5899       for (var i=0, lili=list.length;i<lili;) {
5900         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5901           ++i;
5902           continue;
5903         }
5904         var p = par.createSVGPoint();
5905         p.x = list[i];
5906         p.y = list[i+1];
5907         var pmt = p.matrixTransform(ctm);
5908         list[i] = mr(pmt.x);
5909         ++i;
5910         list[i] = mr(pmt.y);
5911         ++i;
5912         p = pmt = void 0;
5913       }
5914       var dat = list.join(" ");
5915       //VMLに結び付けていく
5916       var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5917       var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5918       ele.path = dat;
5919       ele.coordsize = w + " " + h;
5920       NAIBU._setPaint(tar, ctm);
5921       delete tar._cacheMatrix;
5922       evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
5923     }, false);
5924     evt = tar = void 0;
5925   }, false);
5926   return this;
5927 };
5928 SVGEllipseElement.constructor = SVGElement;
5929 SVGEllipseElement.prototype = new SVGElement();
5930
5931 function SVGLineElement(_doc) { 
5932   SVGElement.apply(this);
5933   this._tar = _doc.createElement("v:shape");
5934   var sl = SVGAnimatedLength;
5935   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5936   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5937   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5938   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5939   _doc = sl = void 0;
5940   this.addEventListener("DOMNodeInserted", function(evt){
5941     var tar = evt.target;
5942     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5943       return; //強制終了させる
5944     }
5945     var tnext = tar.nextSibling,
5946         tpart = tar.parentNode._tar,
5947         isLast = true;
5948     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5949       tpart.insertBefore(tar._tar, tnext._tar);
5950     } else if (tnext && !tnext._tar && tpart) {
5951       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5952        *use要素や実体参照などは_tarプロパティがないことに注意
5953        */
5954       while (tnext) {
5955         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5956           tpart.insertBefore(tar._tar, tnext._tar);
5957           isLast = false;
5958         } 
5959         tnext = tnext.nextSibling;
5960       }
5961       if (isLast) {
5962         tpart.appendChild(tar._tar);
5963       }
5964     } else if (!tnext && tpart) {
5965       tpart.appendChild(tar._tar);      
5966     }
5967     tnext = tpart = isLast = void 0;
5968     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5969       var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5970       var fontSize = parseFloat(style.getPropertyValue("font-size"));
5971       tar.x1.baseVal._emToUnit(fontSize);
5972       tar.y1.baseVal._emToUnit(fontSize);
5973       tar.x2.baseVal._emToUnit(fontSize);
5974       tar.y2.baseVal._emToUnit(fontSize);
5975       //以下は、配列listそのものをCTMで座標変換していく処理
5976       var vi = tar.ownerDocument.documentElement,
5977           ctm = tar.getScreenCTM(),
5978           dat = "m ",
5979           mr = Math.round,
5980           p = vi.createSVGPoint();
5981       p.x = tar.x1.baseVal.value;
5982       p.y = tar.y1.baseVal.value;
5983       var pmt = p.matrixTransform(ctm);
5984       dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
5985       p.x = tar.x2.baseVal.value;
5986       p.y = tar.y2.baseVal.value;
5987       pmt = p.matrixTransform(ctm);
5988       dat += mr(pmt.x)+ " " +mr(pmt.y);
5989       p = pmt = void 0;
5990       //VMLに結び付けていく
5991       var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5992       ele.path = dat;
5993       ele.coordsize = w + " " + h;
5994       NAIBU._setPaint(tar, ctm);
5995       delete tar._cacheMatrix;
5996       evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
5997     }, false);
5998     evt = tar = void 0;
5999   }, false);
6000   return this;
6001 };
6002 SVGLineElement.constructor = SVGElement;
6003 SVGLineElement.prototype = new SVGElement();
6004
6005 /*_GenericSVGPolyElementインターフェース
6006  * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6007  * ファイルサイズを軽量にすることができる
6008  */
6009 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6010   SVGElement.apply(this);
6011   this._tar = _doc.createElement("v:shape");
6012   _doc = void 0;
6013   //interface SVGAnimatedPoints
6014   /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
6015   this.addEventListener("DOMAttrModified", function(evt){
6016     var tar = evt.target;
6017     if (evt.attrName === "points") {
6018       var tp = tar.points, par = tar.ownerDocument.documentElement;
6019       var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6020       for (var i=0, p, lili=list.length;i<lili;i+=2) {
6021         if (isNaN(list[i])) {
6022           --i;
6023           continue;
6024         }
6025         p = par.createSVGPoint();
6026         p.x = parseFloat(list[i]);
6027         p.y = parseFloat(list[i+1]);
6028         tp.appendItem(p);
6029       }
6030     }
6031     evt = tar = list = tp = par = p = void 0;
6032   }, false);
6033   this.addEventListener("DOMNodeInserted", function(evt){
6034     var tar = evt.target;
6035     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6036       return; //強制終了させる
6037     }
6038     var tnext = tar.nextSibling,
6039         tpart = tar.parentNode._tar,
6040         isLast = true;
6041     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6042       tpart.insertBefore(tar._tar, tnext._tar);
6043     } else if (tnext && !tnext._tar && tpart) {
6044       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6045        *use要素や実体参照などは_tarプロパティがないことに注意
6046        */
6047       while (tnext) {
6048         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6049           tpart.insertBefore(tar._tar, tnext._tar);
6050           isLast = false;
6051         } 
6052         tnext = tnext.nextSibling;
6053       }
6054       if (isLast) {
6055         tpart.appendChild(tar._tar);
6056       }
6057     } else if (!tnext && tpart) {
6058       tpart.appendChild(tar._tar);      
6059     }
6060     tnext = tpart = isLast = void 0;
6061     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6062       var tar = evt.target,
6063           tp = tar.points,
6064           ctm = tar.getScreenCTM(),
6065           mr = Math.round;
6066       //以下は、配列listそのものをCTMで座標変換していく処理
6067       for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6068         var p = tp.getItem(i),
6069             pmt = p.matrixTransform(ctm);
6070         list[2*i] = mr(pmt.x);
6071         list[2*i + 1] = mr(pmt.y);
6072         p = pmt = void 0;
6073       }
6074       list.splice(2, 0, "l");
6075       var dat = "m" + list.join(" ") + xclose,
6076           ele = tar._tar,
6077           vi = tar.ownerDocument.documentElement;
6078           w = vi.width.baseVal.value,
6079           h = vi.height.baseVal.value;
6080       //VMLに結び付けていく
6081       ele.path = dat;
6082       ele.coordsize = w + " " + h;
6083       NAIBU._setPaint(tar, ctm);
6084       delete tar._cacheMatrix;
6085       evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
6086     }, false);
6087     evt = tar = void 0;
6088   }, false);
6089   return this;
6090 }
6091 function SVGPolylineElement(_doc) {
6092   NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6093   _doc = void 0;
6094   return this;
6095 };
6096 SVGPolylineElement.constructor = SVGElement;
6097 SVGPolylineElement.prototype = new SVGElement();
6098
6099 function SVGPolygonElement(_doc) {
6100   NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6101   _doc = void 0;
6102   return this;
6103 };
6104 SVGPolygonElement.constructor = SVGElement;
6105 SVGPolygonElement.prototype = new SVGElement();
6106
6107 function SVGTextContentElement(_doc) { 
6108   SVGElement.apply(this);
6109   /*readonly SVGAnimatedLength*/      this.textLength = new SVGAnimatedLength();
6110   /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6111   this.addEventListener("DOMNodeInserted", function(evt){
6112     var tar = evt.target, cur = evt.currentTarget;
6113     /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6114      *あらかじめ、Capturingフェーズで処理しておく
6115      */
6116     if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6117       /*a要素の場合はtarをすりかえておく*/
6118       tar = tar.firstChild;
6119     }
6120     if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
6121       /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6122       tar._tars = [];
6123       var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6124       tar.data = data;
6125       data = data.split('');
6126       for (var i=0, tdli=data.length;i<tdli;++i) {
6127         var d = _doc.createElement("div"),
6128             dstyle = d.style;
6129         dstyle.position = "absolute";
6130         dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = "0px";
6131         dstyle.paddingTop = dstyle.paddingLeft = "0px";
6132         dstyle.whiteSpace = "nowrap";
6133         dstyle.textIndent = "0px";
6134         d.appendChild(_doc.createTextNode(data[i]));
6135         tar._tars[tar._tars.length] = d;
6136       }
6137       data = void 0;
6138       cur._length += tar._tars.length;
6139     } else if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar instanceof SVGTextContentElement) && !!!tar._tars) {
6140       cur._length += tar._length;
6141     }
6142     evt = tar = cur = void 0;
6143   }, true);
6144  return this;
6145 };
6146
6147 (function(t) {
6148 t.constructor = SVGElement;
6149 t.prototype = new SVGElement();
6150     // lengthAdjust Types
6151   /*unsigned short*/ t.LENGTHADJUST_UNKNOWN           = 0;
6152   /*unsigned short*/ t.LENGTHADJUST_SPACING           = 1;
6153   /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS  = 2;
6154   t.prototype._list = null;         //文字の位置を格納しておくリストのキャッシュ
6155   t.prototype._length = 0;          //全文字数
6156   t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6157   t.prototype._chars = 0;           //tspan要素が全体の何文字目から始まっているか
6158   t.prototype._isYokogaki = true;          //横書きかどうか
6159 /*long*/     t.prototype.getNumberOfChars = function() {
6160   return (this._length);
6161 };
6162 /*float*/    t.prototype.getComputedTextLength = function() {
6163   var l = this.textLength.baseVal;
6164   if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6165     /*何も設定されていない場合のみ、初期化を行う*/
6166     l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6167   }
6168   l = void 0;
6169   return (this.textLength.baseVal.value);
6170 };
6171 /*getSubStringLengthメソッド
6172  *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6173  */
6174 /*float*/    t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6175   if (nchars === 0) {
6176     return 0;
6177   }
6178   var tg = this.getNumberOfChars();
6179   if (tg < (nchars+charnum)) {
6180     /*ncharsが文字列の長さよりも長くなってしまったときには、
6181      *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6182      */
6183     nchars = tg - charnum + 1;
6184   }
6185   var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6186   if (this._isYokogaki) {
6187     var s = end.x - st.x;
6188   } else {
6189     var s = end.y - st.y;
6190   }
6191   tg = end = st = void 0;
6192   return s;
6193 }
6194 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6195   if (charnum > this.getNumberOfChars() || charnum < 0) {
6196     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6197   } else {
6198     var tar = this,
6199         ti = tar.firstChild,
6200         tp = tar.parentNode;
6201     if (!!!tar._list) {
6202       tar._list = [];
6203       var chars = tar._chars, //現在、何文字目にあるのか
6204           x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6205           style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6206           isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6207           fontSize = parseFloat(style.getPropertyValue("font-size")),
6208           tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6209       /*親要素の属性も参照しておく*/
6210       if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6211         var ptx = tp.x.baseVal,
6212             pty = tp.y.baseVal,
6213             ptdx = tp.dx.baseVal,
6214             ptdy = tp.dy.baseVal;
6215       } else {
6216         var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6217       }
6218       var kern = "f ijltIr.,:;'-\"()",
6219           akern = "1234567890abcdeghknopquvxyz",
6220           tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6221       if (isYokogaki && (tar.localName === "text")) {
6222         y += fontSize * 0.2;
6223       } else if (tar.localName === "text"){
6224         x -= fontSize * 0.5;
6225       }
6226       while (ti) {
6227         if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6228           tt = ti._tars;
6229           /*tspan要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6230            *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6231            *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6232            *この処理はdx属性やdy、y属性でも同様とする
6233            *参照資料SVG1.1 Text
6234            *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6235            *
6236            *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6237            */
6238           for (var i=0, tli=tt.length;i<tli;++i) {
6239             if (n < ptx.numberOfItems - chars) {
6240               x = ptx.getItem(n).value;
6241               if (!isYokogaki) {
6242                 x -= fontSize * 0.5;
6243               }
6244             } else if (n < tx.numberOfItems) {
6245               x = tx.getItem(n).value;
6246               if (!isYokogaki) {
6247                 x -= fontSize * 0.5;
6248               }
6249             }
6250             if (n < pty.numberOfItems - chars) {
6251               y = pty.getItem(n).value;
6252               if (isYokogaki) {
6253                 y += fontSize * 0.2;
6254               }
6255             } else if (n < ty.numberOfItems) {
6256               y = ty.getItem(n).value;
6257               if (isYokogaki) {
6258                 y += fontSize * 0.2;
6259               }
6260             }
6261             if (n < ptdx.numberOfItems - chars) {
6262               x += ptdx.getItem(n).value;
6263             } else if (n < tdx.numberOfItems) {
6264               x += tdx.getItem(n).value;
6265             }
6266             if (n < ptdy.numberOfItems - chars) {
6267               y += ptdy.getItem(n).value;
6268             } else if (n < tdy.numberOfItems) {
6269               y += tdy.getItem(n).value;
6270             }
6271             alm = 0;
6272             if (isYokogaki) {
6273               //カーニングを求めて、字の幅を文字ごとに調整する
6274               tdc = ti.data.charAt(i);
6275               if (kern.indexOf(tdc) > -1) {
6276                 alm = fontSize * 0.68;
6277               } else if (tdc === "s"){
6278                 alm = fontSize * 0.52;
6279               } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6280                 alm = fontSize * 0.2;
6281               } else if (akern.indexOf(tdc) > -1){
6282                 alm = fontSize * 0.45;
6283               } else {
6284                 alm = fontSize * 0.3;
6285               }
6286               tcca = tdc.charCodeAt(0);
6287               if ((12288 <= tcca) && (tcca <= 65533)) {
6288                 alm = -fontSize * 0.01;
6289                 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6290                   alm += fontSize * 0.2;
6291                 }
6292               }
6293             }
6294             tlist = tar._list;
6295             tlist[tlist.length] = x;
6296             tlist[tlist.length] = y;
6297             tlist[tlist.length] = fontSize - alm;
6298             if (isYokogaki) {
6299               x += fontSize;
6300               x -= alm;
6301             } else {
6302               y += fontSize;
6303             }
6304             ++n;
6305           }
6306           chars += tli;
6307           if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6308             ti = ti.parentNode;
6309           }
6310           ti = ti.nextSibling;
6311         } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6312           /*現在のテキスト位置(x,y)の分だけ、tspan要素をずらしておく。
6313            *さらに、現在のテキスト位置を更新する
6314            */
6315           ti._stx = x;
6316           ti._sty = y;
6317           ti._chars = chars;
6318           p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6319           almx = 0;
6320           almy = 0;
6321           tlist = ti._list;
6322           if (isYokogaki) {
6323             almx = tlist[tlist.length-1];
6324           } else {
6325             almy = tlist[tlist.length-1];
6326           }
6327           x = tlist[tlist.length-3] + almx;
6328           y = tlist[tlist.length-2] + almy;
6329           tar._list = tar._list.concat(tlist);
6330           tg = ti.getNumberOfChars();
6331           n += tg;
6332           chars += tg;
6333           ti = ti.nextSibling;
6334         } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6335           /*a要素のテキストノードも処理する*/
6336           ti = ti.firstChild;
6337         } else {
6338           ti = ti.nextSibling;
6339         }
6340       }
6341       tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6342     }
6343     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;
6344     var s = this.ownerDocument.documentElement.createSVGPoint();
6345     s.x = this._list[charnum*3];
6346     s.y = this._list[charnum*3 + 1];
6347     s = s.matrixTransform(this.getScreenCTM());
6348     return s;
6349   }
6350 };
6351 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6352   if (charnum > this.getNumberOfChars() || charnum < 0) {
6353     throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6354   } else {
6355     var s = this.getStartPositionOfChar(charnum);
6356     //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6357     var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6358     if (this._isYokogaki) {
6359       s.x += n;
6360     } else {
6361       s.y += n;
6362     }
6363     return s;
6364   }
6365 };
6366 /*SVGRect*/  t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6367   
6368 };
6369 /*float*/    t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6370   
6371 };
6372 /*long*/     t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6373   
6374 };
6375 /*void*/     t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6376   
6377 };
6378 })(SVGTextContentElement);
6379
6380 function SVGTextPositioningElement(_doc) { 
6381   SVGTextContentElement.apply(this, arguments);
6382   var sl = SVGAnimatedLengthList;
6383   /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6384   /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6385   /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6386   /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6387   _doc = sl = void 0;
6388   /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6389   this.addEventListener("DOMAttrModified", function(evt){
6390     var tar = evt.target,
6391         name = evt.attrName,
6392         tod = tar.ownerDocument.documentElement,
6393         _parseFloat = parseFloat;
6394     if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6395       var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
6396           teas = tar[name].baseVal;
6397       for (var i=0, tli=enr.length;i<tli;++i) {
6398         var tea = tod.createSVGLength(),
6399             n = enr[i].slice(-1),
6400             type = 0;
6401         if (n >= "0" && n <= "9") {
6402           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6403         } else if (n === "%") {
6404           if ((name === "x") || (name === "dx")) {
6405             tea._percent *= tod.viewport.width;
6406           } else if ((name === "y") || (name === "dy")) {
6407             tea._percent *= tod.viewport.height;
6408           }
6409           type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6410         } else {
6411           n = enr[i].slice(-2);
6412           if (n === "em") {
6413             var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6414             tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6415             style = void 0;
6416             type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6417           } else if (n === "ex") {
6418             type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6419           } else if (n === "px") {
6420             type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6421           } else if (n === "cm") {
6422             type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6423           } else if (n === "mm") {
6424             type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6425           } else if (n === "in") {
6426             type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6427           } else if (n === "pt") {
6428             type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6429           } else if (n === "pc") {
6430             type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6431           }
6432         }
6433         var s = _parseFloat(enr[i]);
6434         s = isNaN(s) ? 0 : s;
6435         tea.newValueSpecifiedUnits(type, s);
6436         teas.appendItem(tea);
6437       }
6438       tar._list = null;
6439     }
6440     evt = tar = void 0;
6441   }, false);
6442   this.addEventListener("DOMNodeInserted", function(evt){
6443     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6444       var tar = evt.target;
6445       if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6446         tar._list = void 0;
6447         evt.currentTarget._list = null;
6448       }
6449       evt = tar = void 0;
6450     }
6451   }, false);
6452   return this;
6453 };
6454 SVGTextPositioningElement.constructor = SVGTextContentElement;
6455 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6456
6457 function SVGTextElement(_doc) {
6458   SVGTextPositioningElement.apply(this, arguments);
6459   this._tar = _doc.createElement("v:group");
6460   this.addEventListener("DOMNodeInserted", function(evt){
6461     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6462       return; //強制終了させる
6463     }
6464     var tar = evt.target,
6465         tnext = tar.nextSibling,
6466         tpart = tar.parentNode._tar,
6467         isLast = true;
6468     if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6469       tpart.insertBefore(tar._tar, tnext._tar);
6470     } else if (tnext && !tnext._tar && tpart) {
6471       /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6472        *use要素や実体参照などは_tarプロパティがないことに注意
6473        */
6474       while (tnext) {
6475         if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6476           tpart.insertBefore(tar._tar, tnext._tar);
6477           isLast = false;
6478         } 
6479         tnext = tnext.nextSibling;
6480       }
6481       if (isLast) {
6482         tpart.appendChild(tar._tar);
6483       }
6484     } else if (!tnext && tpart) {
6485       tpart.appendChild(tar._tar);      
6486     }
6487     tnext = tpart = isLast = void 0;
6488     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6489       var tar = evt.target,
6490           ti = tar.firstChild,
6491           ttp = tar._tar,
6492           style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6493           n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6494           tod = tar.ownerDocument.documentElement,
6495           ttpc = ttp, //ttpcはttpのキャッシュ
6496           tlen = tar.getComputedTextLength(),
6497           anchor = style.getPropertyValue("text-anchor"),
6498           tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6499           ttps = ttp.style,
6500           ae = [];
6501       ttps.fontSize = n + "px";
6502       ttps.fontFamily = style.getPropertyValue("font-family");
6503       ttps.fontStyle = style.getPropertyValue("font-style");
6504       ttps.fontWeight = style.getPropertyValue("font-weight");
6505       /*ここでの変数jは前回ノードまでの総文字数*/
6506       for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6507         if (ti) {
6508           if (!!ti._tars && (ti._tars.length !== 0)) {
6509             var ij = (i > j) ? i - j : j - i
6510             var sty = ti._tars[ij].style,
6511                 p = tar.getStartPositionOfChar(i);
6512             sty.position = "absolute";
6513             if (tar._isYokogaki) {
6514               if (anchor === "middle") {
6515                 p.x -= tlen / 2;
6516               } else if (anchor === "end") {
6517                 p.x -= tlen;
6518               }
6519             } else {
6520               if (anchor === "middle") {
6521                 p.y -= tlen / 2;
6522               } else if (anchor === "end") {
6523                 p.y -= tlen;
6524               }
6525             }
6526             sty.left = p.x + "px";
6527             sty.top = p.y + "px";
6528             sty.width = "0px";
6529             sty.height = "0px";
6530             sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6531             sty.lineHeight = n+10+ "px";
6532             sty.textDecoration = tedeco;
6533             sty.display = "none"
6534             ttp.appendChild(ti._tars[ij]);
6535             sty = p = void 0;
6536           }
6537           if (ti.nodeName === "#text") {
6538             if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6539               j = j + ti.data.length;
6540               if (ti.parentNode.localName === "a") {
6541                 ti =  ti.parentNode;
6542                 ttp = ttpc;
6543               }
6544               ti = ti.nextSibling;
6545             }
6546           } else if (!!ti.getNumberOfChars) {
6547               if ((ti.getNumberOfChars()+j) <= i+1) {
6548                 j = j + ti.getNumberOfChars();
6549                 ti = ti.nextSibling;
6550               }
6551           } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6552             ttp = ti._tar;
6553             ti = ti.firstChild;
6554             ae[ae.length] = ti;
6555             i-=2;
6556           }
6557         }
6558       }
6559       var color = style.getPropertyValue("fill"),
6560           cursor = style.getPropertyCSSValue("cursor"),
6561           vis = style.getPropertyCSSValue("visibility"),
6562           disp = style.getPropertyCSSValue("display"),
6563           tts = tar._tar.style,
6564           tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6565           ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6566           tfti;
6567       if (color === "none"){
6568         tts.color = "transparent";
6569       } else if (color.indexOf("url") === -1) {
6570         tts.color = color;
6571       } else {
6572         tts.color = "black";
6573       }
6574       if (cursor && !cursor._isDefault) { //初期値でないならば
6575         var tc = cursor.cssText;
6576         tts.cursor = tc.split(":")[1];
6577         tc = void 0;
6578       }
6579       if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6580           && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6581         /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6582          *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6583          */
6584         for (var i=1, tli=tft.length;i<tli;++i) {
6585           tfti = tft[i];
6586           ttt += tfti.innerText;
6587           tfti.parentNode.removeChild(tfti);
6588         }
6589         //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6590         if (tft[0] && tft[0].replaceChild) {
6591           tft[0].replaceChild(_doc.createTextNode(ttt), tft[0].firstChild);
6592         }
6593         ttt = void 0;
6594       }
6595       var isRect = true,
6596           di = "block";
6597       if (ttp.lastChild) {
6598         if (ttp.lastChild.nodeName !== "rect") {
6599           isRect = false;
6600         }
6601       } else {
6602         isRect = false;
6603       }
6604       if (!isRect) {
6605         var backr = _doc.createElement("v:rect"),
6606             backrs = backr.style; //ずれを修正するためのもの
6607         backrs.width = backrs.height = "1px";
6608         backrs.left = backrs.top = "0px";
6609         backr.stroked = backr.filled = "false";
6610         ttp.appendChild(backr);
6611       }
6612       if (vis && !vis._isDefault) {
6613         tts.visibility = vis.cssText.split(":")[1];
6614       }
6615       /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6616        *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6617        */
6618       if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6619         di = "none";
6620             } else if (disp && !disp._isDefault) {
6621         di = "block";
6622       }
6623       var jt = tar._tar.firstChild,
6624           j = 0;
6625       while (jt) {
6626         jt.style.display = di;
6627         jt = jt.nextSibling;
6628       }
6629       while (ae[j]) { //要素内部にあるa要素の処理
6630         for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6631           ae[j]._tars[l].style.display = di;
6632         }
6633         l = void 0;
6634         ++j;
6635       }
6636       delete tar._cacheMatrix;
6637       ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
6638     }, false);
6639     evt = tar = void 0;
6640   },false);
6641   return this;
6642 };
6643 SVGTextElement.constructor = SVGTextPositioningElement;
6644 SVGTextElement.prototype = new SVGTextPositioningElement();
6645
6646 function SVGTSpanElement() {
6647   SVGTextElement.apply(this, arguments);
6648   return this;
6649 };
6650 SVGTSpanElement.constructor = SVGTextPositioningElement;
6651 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6652
6653 function SVGTRefElement(_doc) {
6654   SVGTextPositioningElement.apply(this, arguments);
6655   SVGURIReference.apply(this, arguments);
6656   return this;
6657 };
6658 SVGTRefElement.constructor = SVGTextPositioningElement;
6659 SVGTRefElement.prototype = new SVGTextPositioningElement();
6660
6661 function SVGTextPathElement() { 
6662   SVGTextContentElement.apply(this, arguments);
6663   /*readonly SVGAnimatedLength*/      this.startOffset;
6664   /*readonly SVGAnimatedEnumeration*/ this.method;
6665   /*readonly SVGAnimatedEnumeration*/ this.spacing;
6666   SVGURIReference.apply(this, arguments);
6667   return this;
6668 };
6669 SVGTextPathElement.constructor = SVGTextContentElement;
6670 SVGTextPathElement.prototype = new SVGTextContentElement();
6671
6672 (function(t){
6673     // textPath Method Types
6674   /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN   = 0;
6675   /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN     = 1;
6676   /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH     = 2;
6677     // textPath Spacing Types
6678   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN   = 0;
6679   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO     = 1;
6680   /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT     = 2;
6681 })(SVGTextPathElement);
6682
6683 function SVGAltGlyphElement() { 
6684   SVGTextPositioningElement.apply(this, arguments);
6685   /*DOMString*/ this.glyphRef;
6686   /*DOMString*/ this.format;
6687   SVGURIReference.apply(this, arguments);
6688   return this;
6689 };
6690 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6691 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6692
6693 function SVGAltGlyphDefElement() {
6694   SVGElement.apply(this, arguments);
6695   return this;
6696 };
6697 SVGAltGlyphDefElement.constructor = SVGElement;
6698 SVGAltGlyphDefElement.prototype = new SVGElement();
6699
6700 function SVGAltGlyphItemElement() {
6701   SVGElement.apply(this, arguments);
6702   return this;
6703 };
6704 SVGAltGlyphItemElement.constructor = SVGElement;
6705 SVGAltGlyphItemElement.prototype = new SVGElement();
6706
6707 function SVGGlyphRefElement() { 
6708   SVGElement.apply(this, arguments);
6709   /*DOMString*/ this.glyphRef;
6710   /*DOMString*/ this.format;
6711   /*float*/    this.x;
6712   /*float*/    this.y;
6713   /*float*/    this.dx;
6714   /*float*/    this.dy;
6715   SVGURIReference.apply(this, arguments);
6716   return this;
6717 };
6718 SVGGlyphRefElement.constructor = SVGElement;
6719 SVGGlyphRefElement.prototype = new SVGElement();
6720
6721 function SVGPaint() { 
6722   SVGColor.apply(this, arguments);
6723   return this;
6724 };
6725
6726 (function(t){
6727 t.constructor = SVGColor;
6728 t.prototype = new SVGColor();
6729     // Paint Types
6730   /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN               = 0;
6731   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR              = 1;
6732   /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR     = 2;
6733   /*unsigned short*/ t.SVG_PAINTTYPE_NONE                  = 101;
6734   /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR          = 102;
6735   /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE              = 103;
6736   /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR      = 104;
6737   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR          = 105;
6738   /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6739   /*unsigned short*/ t.SVG_PAINTTYPE_URI                   = 107;
6740   /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6741   /*readonly DOMString*/      t.prototype.uri = null;
6742 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6743   this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6744 };
6745 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6746   if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6747     throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6748   }
6749   this.uri = uri;
6750   this.paintType = paintType;
6751   if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6752     paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6753   }
6754   this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6755 };
6756 //                    raises( SVGException );
6757 t = void 0;
6758 })(SVGPaint);
6759
6760 function SVGMarkerElement(){ 
6761   SVGElement.apply(this);
6762   var sl = SVGAnimatedLength;
6763   /*readonly SVGAnimatedLength*/      this.refX = new sl();
6764   /*readonly SVGAnimatedLength*/      this.refY = new sl();
6765   /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6766   /*readonly SVGAnimatedLength*/      this.markerWidth = new sl();
6767   /*readonly SVGAnimatedLength*/      this.markerHeight = new sl();
6768   sl = void 0;
6769   /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6770   /*readonly SVGAnimatedAngle*/       this.orientAngle = new SVGAnimatedAngle();
6771     //SVGFitToViewBoxのインターフェースを用いる
6772   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
6773   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
6774   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
6775   return this;
6776 };
6777 (function(t){
6778     // Marker Unit Types
6779   /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN        = 0;
6780   /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
6781   /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH    = 2;
6782     // Marker Orientation Types
6783   /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN      = 0;
6784   /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO         = 1;
6785   /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE        = 2;
6786 t.constructor = SVGElement;
6787 t.prototype = new SVGElement();
6788 /*void*/ t.prototype.setOrientToAuto = function() {
6789   
6790 };
6791 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
6792   
6793 };
6794 })(SVGMarkerElement);
6795 function SVGColorProfileElement() { 
6796   SVGElement.apply(this);
6797   /*DOMString*/      this._local;
6798                          // raises DOMException on setting
6799                        // (NOTE: is prefixed by "_"
6800                        // as "local" is an IDL keyword. The
6801                        // prefix will be removed upon processing)
6802   /*DOMString*/      this.name;
6803   /*unsigned short*/ this.renderingIntent;
6804   SVGURIReference.apply(this, arguments);
6805   return this;
6806 };
6807 SVGColorProfileElement.constructor = SVGElement;
6808 SVGColorProfileElement.prototype = new SVGElement();
6809
6810 function SVGColorProfileRule() { 
6811   SVGCSSRule.apply(this);
6812   /*DOMString*/      this.src;
6813   /*DOMString*/      this.name;
6814   /*unsigned short*/ this.renderingIntent;
6815   return this;
6816 };
6817 SVGColorProfileRule.constructor = SVGCSSRule;
6818 SVGColorProfileRule.prototype = new SVGCSSRule();
6819
6820 function SVGGradientElement() { 
6821   SVGElement.apply(this);
6822   SVGURIReference.apply(this);
6823   /*readonly SVGAnimatedEnumeration*/   this.gradientUnits = new SVGAnimatedEnumeration();
6824   /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
6825   /*readonly SVGAnimatedEnumeration*/   this.spreadMethod = new SVGAnimatedEnumeration();
6826   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6827     var grad = evt.target,
6828         ele = evt._tar,
6829         t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
6830         grad2 = grad,
6831         href, stops, length,
6832         color = [],
6833         colors = [],
6834         opacity = [],
6835         stop, sstyle, ci;
6836     if (!ele || !grad) { //まだ、path要素などが設定されていない場合
6837       grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
6838       return;
6839     }
6840     if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
6841       grad2 = grad._instance;
6842     }
6843     stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
6844     if (!stops) {
6845       ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
6846       return;
6847     }
6848     length = stops.length;
6849     for (var i = 0; i < length; ++i) {
6850       stop = stops[i];
6851       sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
6852       ci = sstyle.getPropertyCSSValue("stop-color");
6853       if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
6854         /*再度、設定。css.jsのsetPropertyを参照*/
6855         sstyle.setProperty("color", sstyle.getPropertyValue("color"));
6856       }
6857       color[i] =  "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
6858       colors[i] = stop.offset.baseVal + " " + color[i];
6859       opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
6860     }
6861     ele["method"] = "none";
6862     ele["color"] = color[0];
6863     ele["color2"] = color[length-1];
6864     ele["colors"] = colors.join(",");
6865     // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
6866     ele["opacity"] = opacity[length-1]+ "";
6867     ele["o:opacity2"] = opacity[0]+ "";
6868     /*SVGRadialGradientElementインターフェースで利用する*/
6869     grad._color = color;
6870     var gt = grad2.getAttributeNS(null, "gradientTransform");
6871     if (gt) {
6872       grad.setAttributeNS(null, "transform", gt);
6873     }
6874     grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
6875   }, false);
6876   return this;
6877 };
6878 SVGGradientElement.constructor = SVGElement;
6879 SVGGradientElement.prototype = new SVGElement();
6880     // Spread Method Types
6881   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
6882   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD     = 1;
6883   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
6884   /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT  = 3;
6885
6886 function SVGLinearGradientElement() { 
6887   SVGGradientElement.apply(this);
6888   var sl = SVGAnimatedLength;
6889   /*readonly SVGAnimatedLength*/ this.x1 = new sl();
6890   /*readonly SVGAnimatedLength*/ this.y1 = new sl();
6891   /*readonly SVGAnimatedLength*/ this.x2 = new sl();
6892   /*readonly SVGAnimatedLength*/ this.y2 = new sl();
6893   sl = void 0;
6894   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6895     var grad = evt.target, ele = evt._tar, angle = 270;
6896     if (!!!ele) { //まだ、path要素などが設定されていない場合
6897       return;
6898     }
6899     var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
6900     var fontSize = parseFloat(style.getPropertyValue("font-size"));
6901     grad.x1.baseVal._emToUnit(fontSize);
6902     grad.y1.baseVal._emToUnit(fontSize);
6903     grad.x2.baseVal._emToUnit(fontSize);
6904     grad.y2.baseVal._emToUnit(fontSize);
6905     angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
6906     if (angle >= 360) {
6907       angle -= 360;
6908     }
6909     ele.setAttribute("type", "gradient");
6910     ele.setAttribute("angle", angle + "");
6911     evt = ele = grad = angle = style = fontSize = void 0;
6912   }, false);
6913   return this;
6914 };
6915 SVGLinearGradientElement.constructor = SVGGradientElement;
6916 SVGLinearGradientElement.prototype = new SVGGradientElement();
6917
6918 function SVGRadialGradientElement(_doc) { 
6919   SVGGradientElement.apply(this);
6920   var sl = SVGAnimatedLength;
6921   /*readonly SVGAnimatedLength*/ this.cx = new sl();
6922   /*readonly SVGAnimatedLength*/ this.cy = new sl();
6923   /*readonly SVGAnimatedLength*/ this.r = new sl();
6924   /*readonly SVGAnimatedLength*/ this.fx = new sl();
6925   /*readonly SVGAnimatedLength*/ this.fy = new sl();
6926   sl = void 0;
6927   this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
6928   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6929     var grad = evt.target,
6930         ele = evt._tar,
6931         tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
6932     if (!!!ele) { //まだ、path要素などが設定されていない場合
6933       return;
6934     }
6935     ele.setAttribute("type", "gradientTitle");
6936     ele.setAttribute("focus", "100%");
6937     ele.setAttribute("focusposition", "0.5 0.5");
6938     if (tar.localName === "rect") {
6939       /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
6940        *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
6941        */
6942       var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
6943           fontSize = parseFloat(style.getPropertyValue("font-size"));
6944       grad.cx.baseVal._emToUnit(fontSize);
6945       grad.cy.baseVal._emToUnit(fontSize);
6946       grad.r.baseVal._emToUnit(fontSize);
6947       grad.fx.baseVal._emToUnit(fontSize);
6948       grad.fy.baseVal._emToUnit(fontSize);
6949       var cx = grad.cx.baseVal.value,
6950           cy = grad.cy.baseVal.value,
6951           r = grad.r.baseVal.value,
6952           mr = Math.round,
6953           rx, ry;
6954       rx = ry = r;
6955       var tarrect = tar.getBBox(),
6956           vi = tar.ownerDocument.documentElement.viewport,
6957           el = mr(vi.width),
6958           et = mr(vi.height),
6959           er = 0,
6960           eb = 0,
6961           units = grad.getAttributeNS(null, "gradientUnits");
6962       if (!units || units === "objectBoundingBox") {
6963         //%の場合は小数点に変換(10% -> 0.1)
6964         cx = cx > 1 ? cx/100 : cx;
6965         cy = cy > 1 ? cy/100 : cy;
6966         r = r > 1 ? r/100 : r;
6967         //要素の境界領域を求める(四隅の座標を求める)
6968         var nx = tarrect.x,
6969             ny = tarrect.y,
6970             wid = tarrect.width,
6971             hei = tarrect.height;
6972         cx = cx*wid + nx;
6973         cy = cy*hei + ny;
6974         rx = r*wid;
6975         ry = r*hei;
6976         nx = ny = wid = hei = void 0;
6977       }
6978       var matrix = tar.getScreenCTM().multiply(grad.getCTM());
6979       el = cx - rx;
6980       et = cy - ry;
6981       er = cx + rx;
6982       eb = cy + ry;
6983       var rrx = rx * 0.55228,
6984           rry = ry * 0.55228,
6985           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"];
6986       for (var i = 0, lili = list.length; i < lili;) {
6987         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
6988           ++i;
6989           continue;
6990         }
6991         var p = grad.ownerDocument.documentElement.createSVGPoint();
6992         p.x = parseFloat(list[i]);
6993         p.y = parseFloat(list[i+1]);
6994         var pmt = p.matrixTransform(matrix);
6995         list[i] = mr(pmt.x);
6996         i++;
6997         list[i] = mr(pmt.y);
6998         i++;
6999         p = pmt = void 0;
7000       }
7001       var ellipse = list.join(" "),
7002           outline = _doc.getElementById("_NAIBU_outline"),
7003           background = _doc.createElement("div"),
7004           bstyle = background.style;
7005       bstyle.position = "absolute";
7006       bstyle.display = "inline-block";
7007       var w = vi.width,
7008           h = vi.height;
7009       bstyle.textAlign = "left";
7010       bstyle.top = "0px";
7011       bstyle.left = "0px";
7012       bstyle.width = w+ "px";
7013       bstyle.height = h+ "px";
7014       outline.appendChild(background);
7015       bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
7016       background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
7017       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>',
7018           data = tar._tar.path.value;
7019       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>';
7020       background.filters[0].apply();
7021       background.innerHTML = circle;
7022       background.filters[0].play();
7023       tar._tar.parentNode.insertBefore(background, tar._tar);
7024       tar._tar.filled = "false";
7025       ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
7026     } else if (!ele.parentNode){
7027       tar._tar.appendChild(ele);
7028     }
7029     evt = tar = ele = gard = void 0;
7030   }, false);
7031   return this;
7032 };
7033 SVGRadialGradientElement.constructor = SVGGradientElement;
7034 SVGRadialGradientElement.prototype = new SVGGradientElement();
7035
7036 function SVGStopElement() { 
7037   SVGElement.apply(this, arguments);
7038   /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7039   this.addEventListener("DOMAttrModified", function(evt) {
7040     if (evt.attrName === "offset") {
7041       evt.target.offset.baseVal = parseFloat(evt.newValue);
7042     }
7043     evt = void 0;
7044   }, false);
7045   return this;
7046 };
7047 SVGStopElement.constructor = SVGElement;
7048 SVGStopElement.prototype = new SVGElement();
7049
7050 function SVGPatternElement() { 
7051   SVGElement.apply(this);
7052   var sl = SVGAnimatedLength;
7053   /*readonly SVGAnimatedEnumeration*/   this.patternUnits = new SVGAnimatedEnumeration();
7054   /*readonly SVGAnimatedEnumeration*/   this.patternContentUnits = new SVGAnimatedEnumeration();
7055   /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7056   /*readonly SVGAnimatedLength*/        this.x = new sl();
7057   /*readonly SVGAnimatedLength*/        this.y = new sl();
7058   /*readonly SVGAnimatedLength*/        this.width = new sl();
7059   /*readonly SVGAnimatedLength*/        this.height = new sl();
7060   sl = void 0;
7061   SVGURIReference.apply(this, arguments);
7062     //SVGFitToViewBoxのインターフェースを用いる
7063   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
7064   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7065   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7066   return this;
7067 };
7068 SVGPatternElement.constructor = SVGElement;
7069 SVGPatternElement.prototype = new SVGElement();
7070
7071 function SVGClipPathElement() { 
7072   SVGElement.apply(this, arguments);
7073   /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7074   return this;
7075 };
7076 SVGClipPathElement.constructor = SVGElement;
7077 SVGClipPathElement.prototype = new SVGElement();
7078
7079 function SVGMaskElement() { 
7080   SVGElement.apply(this);
7081   var sl = SVGAnimatedLength;
7082   /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7083   /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7084   /*readonly SVGAnimatedLength*/      this.x = new sl();
7085   /*readonly SVGAnimatedLength*/      this.y = new sl();
7086   /*readonly SVGAnimatedLength*/      this.width = new sl();
7087   /*readonly SVGAnimatedLength*/      this.height = new sl();
7088   sl = void 0;
7089   return this;
7090 };
7091 SVGMaskElement.constructor = SVGElement;
7092 SVGMaskElement.prototype = new SVGElement();
7093
7094 function SVGFilterElement() { 
7095   SVGElement.apply(this);
7096   var sl = SVGAnimatedLength;
7097   /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7098   /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7099   /*readonly SVGAnimatedLength*/      this.x = new sl();
7100   /*readonly SVGAnimatedLength*/      this.y = new sl();
7101   /*readonly SVGAnimatedLength*/      this.width = new sl();
7102   /*readonly SVGAnimatedLength*/      this.height = new sl();
7103   sl = void 0;
7104   /*readonly SVGAnimatedInteger*/     this.filterResX = new SVGAnimatedInteger();
7105   /*readonly SVGAnimatedInteger*/     this.filterResY = new SVGAnimatedInteger();
7106   SVGURIReference.apply(this, arguments);
7107   //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7108   return this;
7109 };
7110 SVGFilterElement.constructor = SVGElement;
7111 SVGFilterElement.prototype = new SVGElement();
7112
7113 function SVGFilterPrimitiveStandardAttributes(ele) { 
7114   SVGStylable.apply(this, arguments);
7115   this._tar = ele;
7116   var sl = SVGAnimatedLength;
7117   /*readonly SVGAnimatedLength*/ this.x = new sl();
7118   /*readonly SVGAnimatedLength*/ this.y = new sl();
7119   /*readonly SVGAnimatedLength*/ this.width = new sl();
7120   /*readonly SVGAnimatedLength*/ this.height = new sl();
7121   /*readonly SVGAnimatedString*/ this.result = new sl();
7122   sl = void 0;
7123   };
7124 SVGFilterPrimitiveStandardAttributes.constructor = SVGStylable;
7125 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7126
7127 function SVGFEBlendElement() {
7128   SVGElement.apply(this, arguments);
7129   /*readonly SVGAnimatedString*/      this.in1 = new SVGAnimatedString();
7130   /*readonly SVGAnimatedString*/      this.in2 = new SVGAnimatedString();
7131   /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7132   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7133   return this;
7134 };
7135 SVGFEBlendElement.constructor = SVGElement;
7136 SVGFEBlendElement.prototype = new SVGElement();
7137     // Blend Mode Types
7138   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN  = 0;
7139   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL   = 1;
7140   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7141   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN   = 3;
7142   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN   = 4;
7143   /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN  = 5;
7144
7145 function SVGFEGaussianBlurElement() { 
7146   SVGElement.apply(this, arguments);
7147   /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7148   /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7149   /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7150   this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7151   return this;
7152 };
7153 SVGFEGaussianBlurElement.constructor = SVGElement;
7154 SVGFEGaussianBlurElement.prototype = new SVGElement();
7155 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7156   
7157 };
7158
7159 function SVGCursorElement() { 
7160   SVGElement.apply(this, arguments);
7161   /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7162   /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7163   SVGURIReference.apply(this, arguments);
7164   return this;
7165 };
7166 SVGCursorElement.constructor = SVGElement;
7167 SVGCursorElement.prototype = new SVGElement();
7168
7169 function SVGAElement(_doc) {
7170   SVGElement.apply(this);
7171   this._tar = _doc.createElement("a");
7172   _doc = void 0;
7173   /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7174   this.target.baseVal = "_self";
7175   this.addEventListener("DOMAttrModified", function(evt){
7176     var tar = evt.target;
7177     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7178       return; //強制終了させる
7179     }
7180     if (evt.attrName === "target") {
7181       tar.target.baseVal = evt.newValue;
7182     } else if (evt.attrName === "xlink:title") {
7183       tar._tar.setAttribute("title", evt.newValue);
7184     }
7185     evt = void 0;
7186   }, false);
7187   this.addEventListener("DOMNodeInserted", function(evt){
7188     var tar = evt.target;
7189     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7190       return; //強制終了させる
7191     }
7192     if (tar.nextSibling) {
7193       if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7194         tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7195       }
7196     } else if (!!tar.parentNode._tar){
7197       tar.parentNode._tar.appendChild(tar._tar);
7198     }
7199     var txts = tar._tar.style;
7200     txts.cursor = "hand";
7201     txts.left = "0px";
7202     txts.top = "0px";
7203     txts.textDecoration = "none";
7204     txts = void 0;
7205     var t = tar.target.baseVal;
7206     var st = "replace";
7207     if (t === "_blank") {
7208       st = "new";
7209     }
7210     tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7211     tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7212     tar = evt = void 0;
7213   }, false);
7214   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7215     var tar = evt.target;
7216     if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7217       var txts = tar._tar.style;
7218       txts.cursor = "hand";
7219       txts.textDecoration = "none";
7220       txts = void 0;
7221     }
7222     tar = evt = void 0;
7223     return; //強制終了させる
7224   }, true);
7225   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7226     var tar = evt.target;
7227     tar._tar.setAttribute("target", tar.target.baseVal);
7228     if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7229       tar.addEventListener("click", function(evt){
7230           var tar = evt.target,
7231               sd = document.body,
7232               ob, nd;
7233           sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7234           if (tar.target.baseVal === "_self") {
7235             nd = tar.ownerDocument._iframe;
7236             nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7237             ob = nd.nextSibling;
7238             if (ob && (ob.tagName === "OBJECT")) {
7239               nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7240               nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7241               nd.parentNode.removeChild(ob);
7242             }
7243             ob = NAIBU._search([nd.previousSibling]);
7244             nd.parentNode.removeChild(nd);
7245           } else {
7246             sd.appendChild(sd.lastChild.firstChild);
7247             while (sd.firstChild !== sd.lastChild) {     //オブジェクト要素以外を除去
7248               sd.removeChild(sd.firstChild);
7249             }
7250             ob = NAIBU._search([sd.lastChild]);
7251           }
7252           NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7253           evt.preventDefault();
7254           ob._next = {
7255             _init: (function (ob) {
7256               return (function(){
7257                 document.title = ob.getSVGDocument().title;
7258                 ob = void 0;
7259               });
7260             })(ob)
7261           };
7262           ob._init();
7263           sd = ob = nd = void 0;
7264       }, false);
7265     }
7266     tar = void 0;
7267   }, false);
7268   SVGURIReference.apply(this, arguments);
7269   return this;
7270 };
7271 SVGAElement.constructor = SVGElement;
7272 SVGAElement.prototype = new SVGElement();
7273
7274 function SVGViewElement() { 
7275   SVGElement.apply(this, arguments);
7276   /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7277       //SVGFitToViewBoxのインターフェースを用いる
7278   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
7279   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7280   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7281   return this;
7282 };
7283 SVGViewElement.constructor = SVGElement;
7284 SVGViewElement.prototype = new SVGElement();
7285
7286 function SVGScriptElement() { 
7287   SVGElement.apply(this);
7288   /*DOMString*/ this.type;
7289   SVGURIReference.apply(this, arguments);
7290   this.addEventListener("DOMAttrModified", function(evt){
7291     if (evt.attrName === "type") {
7292       evt.target.type = evt.newValue;
7293     }
7294     evt = void 0;
7295   }, false);
7296   this.addEventListener("S_Load", function(evt){
7297     var tar = evt.target, script = tar._text;
7298     var tod = tar.ownerDocument;
7299     NAIBU._temp_doc = tod;
7300     script = script.replace(/function\s+(\w+)/g, "$1 = function");
7301     script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7302     try {
7303       eval(script);
7304     } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7305       script = script.replace(/function\(document\){/, "function() {");
7306       eval(script);
7307     }
7308     tar = evt = script = void 0;
7309   }, false);
7310   this.addEventListener("DOMNodeInserted", function(evt){
7311     var tar = evt.target;
7312     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7313       if (tar.nodeName === "#cdata-section") {
7314         evt.currentTarget._text = tar.data;
7315       }
7316       return;
7317     }
7318     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7319       var tar = evt.target;
7320       if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7321         var evtt = tar.ownerDocument.createEvent("SVGEvents");
7322         evtt.initEvent("S_Load", false, false);
7323         evt.currentTarget.dispatchEvent(evtt);
7324       }
7325       tar = evt = void 0;
7326     }, false);
7327   }, false);
7328   return this;
7329 };
7330 SVGScriptElement.constructor = SVGElement;
7331 SVGScriptElement.prototype = new SVGElement();
7332
7333 function SVGEvent() {
7334   Event.apply(this, arguments);
7335   return this;
7336 };
7337 SVGEvent.constructor = Event;
7338 SVGEvent.prototype = new Event();
7339
7340 function SVGZoomEvent() { 
7341   UIEvent.apply(this, arguments);
7342   /*readonly SVGRect*/  this.zoomRectScreen = new SVGRect();
7343   /*readonly float*/    this.previousScale = 1;
7344   /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7345   /*readonly float*/    this.newScale = 1;
7346   /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7347   return this;
7348 };
7349 SVGZoomEvent.constructor = UIEvent;
7350 SVGZoomEvent.prototype = new UIEvent();
7351
7352 function SVGAnimationElement(es) {
7353   if (!!es) {
7354     return this;
7355   }
7356   SVGElement.apply(this);
7357   /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7358    *styleのsetPropertyメソッドを無効化させておく必要がある
7359    */
7360   this.style.setProperty = function(){};
7361   this._tar = null;
7362   /*readonly SVGElement*/ this.targetElement;
7363   this._beginValue = "0ms";
7364   this._endValue = null;
7365   this._currentFrame = 0;
7366   this._currentCount = 0;
7367   /*_maxCountはrepeatCount属性で指定された数値
7368    *_maxDurはrepeatDur属性で指定された数値
7369    */
7370   this._maxCount = 0;
7371   this._maxDur = 0;
7372   this._isRepeat = false;
7373   /*_simpleDurationプロパティは
7374    *dur属性の数値を収納しておく。属性がなければnullのまま
7375    */
7376   this._simpleDuration = null;
7377   /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
7378    *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
7379    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7380    */
7381   this._begin = null;
7382   this._end = null;
7383   this._from = this._to = this._values = this._by = null;
7384   this._keyTimes = null;
7385   this.addEventListener("beginEvent", function(evt) {
7386     var tar = evt.target;
7387     if (!tar.isRepeat) {
7388       tar.endElementAt(tar.getSimpleDuration());
7389     } else {
7390       tar.beginElementAt(tar.getSimpleDuration());
7391       if (tar.getCurrentTime() !== 0) {
7392         var ttd = tar.ownerDocument, evt = ttd.createEvent("TimeEvents");
7393         tar._currentCount++;
7394         evt.initTimeEvent("repeatEvent", ttd.defaultView, tar._currentCount);
7395         tar.dispatchEvent(evt);
7396       }
7397     }
7398   }, false);
7399   this.addEventListener("DOMAttrModified", function(evt){
7400     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7401       return;
7402     }
7403     var tar = evt.target, name = evt.attrName;
7404     if (name === "begin") {
7405       tar._beginValue = evt.newValue;
7406     } else if (name === "end") {
7407       tar._endValue = evt.newValue;
7408     } else if (name === "dur") {
7409       tar._simpleDuration = tar._getOffset(evt.newValue);
7410     } else if (name === "repeatCount") {
7411       tar._maxCount = parseFloat(evt.newValue);
7412       tar._isRepeat = true;
7413     } else if (name === "repeatDur") {
7414       tar._maxDur = parseFloat(evt.newValue);
7415       tar._isRepeat = true;
7416     } else if (name === "from") {
7417       tar._from = evt.newValue;
7418     } else if (name === "to") {
7419       tar._to = evt.newValue;
7420     } else if (name === "values") {
7421       tar._values = evt.newValue.split(";");
7422     } else if (name === "by") {
7423       tar._by = evt.newValue;
7424     } else if (name === "keyTimes") {
7425       var s = evt.newValue.split(";");
7426       tar._keyTimes = []; //_keyTimesプロパティを初期化
7427       for (var i=0;i<s.length;++i) {
7428         tar._keyTimes[i] = parseFloat(s[i]);
7429       }
7430       s = void 0;
7431     }
7432     evt = void 0;
7433   }, false);
7434   this.addEventListener("DOMNodeInserted", function(evt){
7435     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7436       return; //強制終了させる
7437     }
7438     var tar = evt.target;
7439     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7440       var tar = evt.target;
7441       /*以降の場合分けルールに関しては、下記の仕様を参照
7442        *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7443        */
7444       if (tar._values) {
7445       } else if (tar._from && tar._to) {
7446         tar._values = [tar._from, tar._to];
7447       } else if (tar._from && tar._by) {
7448         var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7449         tar._values = [tar._from, n+tanni[0]];
7450       } else if (tar._to) {
7451         tar._values = [null, tar._to];
7452       } else if (tar._by) {
7453         tar._values = [null, null, tar._by];
7454       } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7455         /*アニメーションの効果が出ないように調整する
7456          *SMILアニメーションの仕様を参照
7457          *
7458          *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7459          *「3.2.2. Animation function values」より引用
7460          *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7461          */
7462         return this;
7463       }
7464       if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7465         tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
7466       } else {
7467         tar.targetElement = tar.parentNode;
7468       }
7469       tar._eventSync(tar._beginValue,
7470           (function(te, offse, ta, t) {
7471             ta.addEventListener( t.match(te._eventRegExp)[0],
7472               function(){
7473                 if (offse !== 0) {
7474                   te.beginElementAt(offse);
7475                 } else {
7476                   te._begin = NAIBU.Time.currentFrame;
7477                   te.beginElement();
7478                   te._currentFrame++;
7479                 }
7480               }, false);
7481            }), "beginElementAt");
7482       if (tar._endValue) {
7483         tar._eventSync(tar._endValue,
7484             (function(te, offse, ta, t) {
7485               ta.addEventListener( t.match(te._eventRegExp)[0],
7486                   function(){
7487                     te.endElementAt(offse);
7488                   }, false );
7489               }), "endElementAt");
7490       }
7491       evt = tar = void 0;
7492     }, false);
7493     evt = tar = void 0;
7494   }, false);
7495   this.addEventListener("repeatEvent", function(evt) {
7496     var tar = evt.target;
7497     if ((tar._currentCount >= tar._maxCount) || (tar.getCurrentTime() >= (tar._maxDur+tar.getStartTime()))) {
7498       tar._isRepeat = false;
7499     }
7500   }, false);
7501   return this;
7502 };
7503 SVGAnimationElement.constructor = SVGElement;
7504 SVGAnimationElement.prototype = new SVGElement();
7505 /*以下のメソッド(beginElementなど)については、
7506  *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7507  */
7508 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7509   var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7510   evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7511   this.dispatchEvent(evt);
7512 };
7513 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7514   var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7515   evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7516   this.dispatchEvent(evt);
7517 };
7518 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7519   var ntc = this.ownerDocument.documentElement.getCurrentTime();
7520   this._begin = offset + ntc;
7521 };
7522 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7523   var ntc = this.ownerDocument.documentElement.getCurrentTime();
7524   this._end = offset + ntc;
7525 };
7526 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7527 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
7528 SVGAnimationElement.prototype._unit = {
7529     "h"   : 2880000,
7530     "min" : 48000,
7531     "s"   : 800,
7532     "ms"  : 0.8
7533 };
7534 /*_getOffsetメソッド
7535  * どれだけズレの時間があるかを計測するメソッド
7536  *tに数値が使われていないときは0を返す
7537  *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7538  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7539  *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7540  ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7541  */
7542 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
7543   var n = parseFloat(t.match(this._timeRegExp));
7544   if (!isNaN(n) && RegExp.$1) {
7545     var offset = n * this._unit[RegExp.$1]
7546   } else if (!isNaN(n)) {
7547     var offset = n;
7548   } else {
7549     var offset = 0;
7550   }
7551   n = t = void 0;
7552   return offset;
7553 };
7554 /*_eventSyncメソッド
7555  *イベントがある場合とない場合とで、別々の処理に分けるメソッド
7556  */
7557 SVGAnimationElement.prototype._eventSync = function(/*string*/ t, /*function*/ f, /*string*/ methodName) {
7558   var offset = this._getOffset(t);
7559   this._begin = NAIBU.Time.Max;
7560   if ( /(mouse|activ|click|begin|end)/.test(t) ) { //イベントがある場合
7561     var tar;
7562     if ( /([^;]+)\.\D/.test(t) ) {
7563       tar = this.ownerDocument.getElementById(RegExp.$1);
7564     } else {
7565       tar = this.targetElement;
7566     }
7567     if (!offset && offset !== 0) {
7568       offset = NAIBU.Time.Max;
7569     }
7570     f(this, offset, tar, t);
7571   } else if (!offset && (t !== "undefined") && (offset !== 0)) {
7572     this._begin = 0;
7573   } else {
7574     this[methodName](offset);
7575   }
7576 };
7577 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7578   if (!!this._begin || (this._begin === 0)) {
7579     return (this._begin);
7580   } else {
7581     throw new DOMException(DOMException.INVALID_STATE_ERR);
7582   }
7583 };
7584 /*getCurrentTimeメソッド
7585  *現在の時間コンテナ内での時刻であり、
7586  *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7587  */
7588 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7589   return (this._currentFrame * 125 * 0.8);
7590 };
7591 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7592   if (!!!this._simpleDuration && !!!this._end && (this._simpleDuration !== 0)) {
7593     throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7594   } else if (!!this._simpleDuration && !!this._end) {
7595     var s = (this._simpleDuration > this._end - this._begin) ? this._end - this._begin : this._simpleDuration;
7596   } else {
7597     var s = !!this._end ? this._end - this._begin : this._simpleDuration;
7598   }
7599  return s;
7600 };
7601                     //raises( DOMException );
7602 NAIBU.Time = {
7603   currentFrame : 0,
7604   Max : 7000,
7605   start : function() {
7606   if (NAIBU.Clip.length > 0) {
7607     screen.updateInterval = 42; //24fpsとして描画処理
7608     window.onscroll = function () {
7609       screen.updateInterval = 0;
7610       screen.updateInterval = 42;
7611     }
7612     NAIBU.stop = setInterval( (function() {
7613 /*      try{*/
7614         var ntc = NAIBU.Time.currentFrame++;
7615         var nc = NAIBU.Clip;
7616         var s = ntc * 100; //フレーム数ntcをミリ秒数sに変換
7617         if (ntc > NAIBU.Time.Max) {
7618           clearInterval(NAIBU.stop);
7619         }
7620         for (var i=0,ncli=nc.length;i<ncli;++i) {
7621           var nci = nc[i];
7622           nci.ownerDocument.documentElement.setCurrentTime(s);
7623           if ("_begin" in nci) {
7624             if (nci.getStartTime() <= s) {
7625               if (nci.getCurrentTime() === 0) {
7626                 nci.beginElement();
7627               }
7628               nci._currentFrame++;
7629             }
7630             if (nci._end && (nci._end <= s) && (nci.getCurrentTime() !== 0)) {
7631               nci.endElement();
7632               nci._frame && nci._frame();
7633               nci._currentFrame = 0;
7634               delete nci._begin;
7635               nci._end = null;
7636             } else if (!!nci._frame) {
7637               nci._frame();
7638             }
7639           }
7640           nci = void 0;
7641         }
7642 /*      } catch (e) {
7643         stlog.add(e, 4157);
7644       }*/
7645         }),
7646          1
7647       );
7648     } else {
7649       window.onscroll = function () {
7650         screen.updateInterval = 0;
7651                window.onscroll = NAIBU.emptyFunction;
7652       }
7653     }
7654  }
7655 };
7656 NAIBU.Clip = [];
7657   
7658 function SVGAnimateElement(){
7659   SVGAnimationElement.apply(this);
7660   /*NAIBU.Clipについては、NAIBU.Timeで使う
7661    *くわしくはNAIBU.Time.start関数のコードを参照
7662    */
7663   NAIBU.Clip[NAIBU.Clip.length] = this;
7664   /*_valueListプロパティは、
7665    *機械が理解できる形で保管されているvalueの値の配列リスト
7666    */
7667   this._valueList = [];
7668   this._isDiscrete = false;
7669   this.addEventListener("DOMAttrModified", function(evt){
7670     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7671       return; //強制終了させる
7672     }
7673     if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
7674       evt.target._isDiscrete = true;
7675     }
7676   }, false);
7677   this.addEventListener("DOMNodeInserted", function(evt){
7678     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7679       return; //強制終了させる
7680     }
7681     var tar = evt.target;
7682     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7683       var tar = evt.target,
7684           attrName = tar.getAttributeNS(null, "attributeName"),
7685           ttr = tar.targetElement,
7686           tta = ttr[attrName];
7687       /*tar.valuesのリスト:  ["12px", "13px"]
7688        *tar._valueList:   [(new SVGPoint()), (new SVGPoint())]
7689        *  tar.valuesを機械が理解できるように変換したものがtar._valueList
7690        *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
7691        */
7692       var vi = ttr.cloneNode(false);
7693       if (!tar._values[0]) {   //to属性か、by属性が設定されている場合
7694         var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
7695         tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
7696         if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
7697           var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
7698           tar._values[1] = v2 + tanni[0];
7699           tar._values.pop();
7700           v2 = tanni = void 0;
7701         }
7702       }
7703       if ("animatedPoints" in ttr) {
7704         ttr.animatedPoints = vi.points;
7705         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7706           var vir = ttr.cloneNode(false);
7707           delete vir._tar;
7708           vir.setAttributeNS(null, "points", tav[i]);
7709           tar._valueList[tar._valueList.length] = vir.points;
7710         }
7711       } else if (!!tta) {
7712         tta.animVal = vi[attrName].baseVal;
7713         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7714           var vir = ttr.cloneNode(false); //仮の要素
7715           delete vir._tar;
7716           vir.setAttributeNS(null, attrName, tav[i]);
7717           tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
7718         }
7719       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7720         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7721           if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
7722             tar._valueList[i] = new SVGPaint();
7723             tar._valueList[i].setPaint(1, null, tav[i], null)
7724           } else {
7725             tar._valueList[i] = parseFloat(tav[i]);
7726           }
7727         }
7728       } else if ("normalizedPathSegList" in ttr) {
7729         ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
7730         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7731           var vir = ttr.cloneNode(false);
7732           delete vir._tar;
7733           vir.setAttributeNS(null, "d", tav[i]);
7734           tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
7735         }
7736       } else {
7737         vi = void 0;
7738         return;
7739       }
7740       evt = tta = vir = vi = void 0;
7741     }, false);
7742   }, false);
7743   this.addEventListener("beginEvent", function(evt) {
7744     var tar = evt.target;
7745     var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName);
7746     var ttr = tar.targetElement, tta = ttr[attrName];
7747     tar._frame = function() {
7748       var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime();
7749       if ((n !== -1) && (d !== 0) && (tg <= d)) {
7750         if (tar._isDiscrete) {
7751           ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
7752         }
7753         var ii = Math.floor((tg*n) / d);
7754         if (ii === n) { //iiが境い目のときは、n-2を適用
7755           ii -= 1;
7756         }
7757       } else {
7758         return;
7759       }
7760       /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7761       *
7762       * 参照:アニメーションサンドイッチモデル
7763       * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7764       *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7765       */
7766       var evt = tar.ownerDocument.createEvent("MutationEvents");
7767       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7768       if (tar._keyTimes) {
7769         var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
7770         var ti = tar._keyTimes[ii];
7771       } else {
7772         var di = d / n; //keyTimesがなければ均等に時間を配分しておく
7773         var ti = ii / n;
7774       }
7775       if ("animatedPoints" in ttr) {
7776         var base = ttr.points;
7777         ttr.points = ttr.animatedPoints;
7778         ttr.dispatchEvent(evt);
7779         ttr.animatedPoints = ttr.points;
7780         ttr.points = base;
7781       } else if (!!tta) {
7782         var base = tta.baseVal, tanim = tta.animVal;
7783         var v1 = tar._valueList[ii].value;
7784         /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
7785          * 3.4.2 Specifying the simple animation function f(t)
7786          *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
7787          */
7788         if (!tar._isDiscrete) {
7789           var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
7790         } else {
7791           var v = v1;
7792         }
7793         tanim.newValueSpecifiedUnits(base.unitType, v);
7794         tta.baseVal = tanim;
7795         tanim = void 0;
7796         ttr.dispatchEvent(evt);
7797         /*変化値はanimValプロパティに収納しておき、
7798          *変化する前の、元の値はbaseValプロパティに再び収納しておく
7799          */
7800         tta.animVal = tta.baseVal;
7801         tta.baseVal = base;
7802         di = void 0;
7803       } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7804         var base = null;
7805         var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
7806         if (!tar._isDiscrete) {
7807           var v = v1 + (v2-v1) * (tg-ti*d) / di;
7808         } else {
7809           var v = v1;
7810         }
7811       } else if ("normalizedPathSegList" in ttr) {
7812         var base = ttr.normalizedPathSegList;
7813         ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
7814         ttr.dispatchEvent(evt);
7815         ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
7816         ttr.normalizedPathSegList = base;
7817       }
7818      evt = v1 = v2 = v = d = n = ii = tg = void 0;
7819     };
7820     evt = vir = void 0;
7821   }, false);
7822   this.addEventListener("endEvent", function(evt) {
7823     var tar = evt.target, fill = tar.getAttributeNS(null, "fill");
7824     if (!fill || (fill === "remove")) {
7825       var evt = tar.ownerDocument.createEvent("MutationEvents");
7826       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7827       tar.targetElement.dispatchEvent(evt);
7828       evt = void 0;
7829     }
7830   }, false);
7831   this.addEventListener("repeatEvent", function(evt) {
7832     var tar = evt.target;
7833   }, false);
7834   return this;
7835 };
7836 SVGAnimateElement.constructor = SVGAnimationElement;
7837 SVGAnimateElement.prototype = new SVGAnimationElement(1);
7838
7839 function SVGSetElement(){
7840   SVGAnimationElement.apply(this);
7841   NAIBU.Clip[NAIBU.Clip.length] = this;
7842   this._to = "";
7843   this.addEventListener("DOMAttrModified", function(evt) {
7844     var tar = evt.target, name = evt.attrName;
7845     if (name === "to") {
7846       tar._to = evt.newValue;
7847     }
7848     tar = name = void 0;
7849   }, false);
7850   this.addEventListener("beginEvent", function(evt) {
7851     var tar = evt.target;
7852     if (tar.targetElement) {
7853       var attrName = tar.getAttributeNS(null, "attributeName"),
7854           newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
7855           tta = tar.targetElement[attrName];
7856       if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7857         var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
7858         style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
7859         style = void 0;
7860       } else if (!!tta) {
7861         var base = tta.baseVal;
7862         if (base instanceof SVGLength) {
7863           tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
7864         } else if (base instanceof SVGRect) {
7865           tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
7866         }
7867         /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7868          *
7869          * 参照:アニメーションサンドイッチモデル
7870          * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7871          *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7872          */
7873         var evt = tar.ownerDocument.createEvent("MutationEvents");
7874         evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
7875         tar.targetElement.dispatchEvent(evt);
7876         evt = void 0;
7877         /*変化値はanimValプロパティに収納しておき、
7878          *変化する前の、元の値はbaseValプロパティに再び収納しておく
7879          */
7880         tta.animVal = tta.baseVal;
7881         tta.baseVal = base;
7882       }
7883     }
7884     evt = tar = attrName = void 0;
7885   }, false);
7886   this.addEventListener("endEvent", function(evt) {
7887     var tar = evt.target,
7888         fill = tar.getAttributeNS(null, "fill");
7889     if (!fill || (fill === "remove")) {
7890       var attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7891       tar.targetElement.style.setProperty(attrName, style.getPropertyValue(attrName), null);
7892       var evtt = tar.ownerDocument.createEvent("MutationEvents");
7893       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7894       tar.targetElement.dispatchEvent(evtt);
7895       attrName = style = evtt = void 0;
7896     }
7897     tar = fill = void 0;
7898   }, false);
7899   this.addEventListener("repeatEvent", function(evt) {
7900     var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7901   }, false);
7902   return this;
7903 };
7904 SVGSetElement.constructor = SVGAnimationElement;
7905 SVGSetElement.prototype = new SVGAnimationElement(1);
7906
7907 function SVGAnimateMotionElement(){
7908   SVGAnimationElement.apply(this);
7909   NAIBU.Clip[NAIBU.Clip.length] = this;
7910   this.addEventListener("DOMAttrModified", function(evt){
7911     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7912       return;
7913     }
7914     var tar = evt.target,
7915         name = evt.attrName;
7916     if (name === "path") {
7917       var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
7918       d.setAttributeNS(null, "d", evt.newValue);
7919       tar._path = d;
7920       d = void 0;
7921     }
7922   }, false);
7923   this.addEventListener("DOMNodeInserted", function(evt){
7924     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7925       return; //強制終了させる
7926     }
7927     var tar = evt.target;
7928     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7929       var vlist = [],
7930           ti;
7931       if (tar._values) {
7932         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7933           ti = tav[i];
7934           ti = ti.split(",");
7935           vlist[i] = [+ti[0], +ti[1]];
7936         }
7937         tar._valueList = vlist;
7938       }
7939     }, false);
7940   }, false);
7941   this.addEventListener("beginEvent", function(evt) {
7942     var tar = evt.target,
7943         trans = tar.targetElement.transform;
7944     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
7945      *baseValと同じような値に設定。
7946      */
7947     trans.animVal = new SVGTransformList();
7948     if (trans.baseVal.numberOfItems !== 0) {
7949       trans.baseVal.consolidate();
7950       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
7951       } else {
7952       trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
7953     }
7954     tar._frame = function() {
7955       var _tar = tar,
7956           tpn = _tar._path,
7957           tgsd = _tar.getSimpleDuration(),
7958           d = tgsd * 0.8,
7959           tg = _tar.getCurrentTime(),
7960           ii;
7961       if (tgsd === 0) {
7962          tgsd = void 0;
7963          return;
7964       }
7965       if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
7966         var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
7967             p = tpn.getPointAtLength(st),
7968             trans = _tar.targetElement.transform;
7969         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
7970         var base = trans.baseVal;
7971         trans.baseVal = trans.animVal;
7972         _tar.targetElement._cacheMatrix = null;
7973         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
7974         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7975         _tar.targetElement.dispatchEvent(evtt);
7976         trans.baseVal = base;
7977         evtt = base = trans = st = p = void 0;
7978       } else if (tar._valueList) {
7979         var total = 0, //totalは総距離
7980             st = 0,    //stは現在にいたるまでの距離
7981             tav = tar._valueList,
7982             n = tav.length - 1;
7983         if ((n !== -1) && (d !== 0) && (tg <= d)) {
7984           ii = Math.floor((tg*n) / d);
7985           if (ii === n) { //iiが境い目のときは、n-2を適用
7986             ii -= 1;
7987           }
7988         } else {
7989           return;
7990         }
7991         for (var i=1, tvli=tav.length;i<tvli;i+=2) {
7992           total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7993         }
7994         for (var i=1;i<ii;i+=2) {
7995           st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7996         }
7997         var p = tar.ownerDocument.documentElement.createSVGPoint(),
7998             trans = _tar.targetElement.transform;
7999         st = (st / total) * d;
8000         p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
8001         p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
8002         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8003         var base = trans.baseVal;
8004         trans.baseVal = trans.animVal;
8005         _tar.targetElement._cacheMatrix = void 0;
8006         var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8007         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8008         _tar.targetElement.dispatchEvent(evtt);
8009         trans.baseVal = base;
8010         evtt = base = trans = st = p = void 0;
8011       }
8012     }
8013     evt = trans = tpn = tgsd = void 0;
8014   }, false);
8015   this.addEventListener("endEvent", function(evt) {
8016     var tar = evt.target,
8017         trans = tar.targetElement.transform,
8018         fill = tar.getAttributeNS(null, "fill");
8019     if (!fill || (fill === "remove")) {
8020       trans.animVal = trans.baseVal;
8021       var evtt = tar.ownerDocument.createEvent("MutationEvents");
8022       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8023       tar.targetElement.dispatchEvent(evtt);
8024     }
8025     tar._frame = evt = evtt = void 0;
8026   }, false);
8027   this.addEventListener("repeatEvent", function(evt) {
8028     var tar = evt.target;
8029   }, false);
8030   return this;
8031 };
8032 SVGAnimateMotionElement.constructor = SVGAnimationElement;
8033 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
8034
8035 function SVGMPathElement() /* : 
8036                 SVGElement,
8037                 SVGURIReference,
8038                 SVGExternalResourcesRequired*/ {
8039   SVGElement.apply(this);
8040   SVGURIReference.apply(this);
8041   return this;
8042 };
8043 SVGMPathElement.constructor = SVGElement;
8044 SVGMPathElement.prototype = new SVGElement();
8045
8046 function SVGAnimateColorElement() {
8047   SVGAnimationElement.apply(this);
8048   NAIBU.Clip[NAIBU.Clip.length] = this;
8049   this._valueList = [];
8050   this.addEventListener("DOMNodeInserted", function(evt){
8051     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8052       return; //強制終了させる
8053     }
8054     var tar = evt.target;
8055     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8056       var tar = evt.target,
8057           attrName = tar.getAttributeNS(null, "attributeName"),
8058           ttr = tar.targetElement,
8059           fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8060           css, n;
8061       if (!tar._values[0]) {
8062         tar._values[0] = fstyle.getPropertyValue(attrName);
8063       }
8064       for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8065         var to = new SVGColor();
8066         if (tar._values[i] === "currentColor") {
8067           to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8068         } else if (tar._values[i] === "inherit") {
8069           /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8070           css = fstyle.getPropertyCSSValue(attrName);
8071           n = css.cssValueType;
8072           css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8073           to = fstyle.getPropertyCSSValue(attrName);
8074           css.cssValueType = n;
8075         } else {
8076           to.setRGBColor(tar._values[i]);
8077         }
8078         tar._valueList[tar._valueList.length] = to;
8079         to = void 0;
8080       }
8081       tar = ttr = fstyle = css = n = attrName = void 0;
8082     }, false);
8083   }, false);
8084   this.addEventListener("beginEvent", function(evt) {
8085     var tar = evt.target,
8086         attrName = tar.getAttributeNS(null, "attributeName"),
8087         style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8088         fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8089     tar._frame = function() {
8090       var _tar = tar;
8091       /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8092        * 3.4.2 Specifying the simple animation function f(t)
8093        *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8094        */
8095       var d = _tar.getSimpleDuration() * 0.8,
8096           n = _tar._valueList.length - 1,
8097           tg = _tar.getCurrentTime(),
8098           ii, di, ti;
8099       if ((n !== -1) && (d !== 0) && (tg <= d)) {
8100         ii = Math.floor((tg*n) / d);
8101         if (ii === n) { //iiが境い目のときは、n-2を適用
8102           ii -= 1;
8103         }
8104       } else {
8105         return;
8106       }
8107       if (tar._keyTimes) {
8108         di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8109         ti = tar._keyTimes[ii];
8110       } else {
8111         di = d / n; //keyTimesがなければ均等に時間を配分しておく
8112         ti = ii / n;
8113       }
8114       var fc = _tar._valueList[ii].rgbColor,
8115           tc = _tar._valueList[ii+1].rgbColor,
8116           durd = (tg-ti*d) / di,
8117           num = CSSPrimitiveValue.CSS_NUMBER,
8118           fr = fc.red.getFloatValue(num),
8119           fg = fc.green.getFloatValue(num),
8120           fb = fc.blue.getFloatValue(num),
8121           r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8122           g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8123           b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8124       style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8125       _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = void 0;
8126     };
8127     tar._frame();
8128   }, false);
8129   this.addEventListener("endEvent", function(evt) {
8130     var tar = evt.target;
8131     if (!fill || (fill === "remove")) {
8132       var evtt = tar.ownerDocument.createEvent("MutationEvents");
8133       evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8134       tar.targetElement.dispatchEvent(evtt);
8135     }
8136     tar._frame = evt = evtt = void 0;
8137   }, false);
8138   this.addEventListener("repeatEvent", function(evt) {
8139     var tar = evt.target;
8140   }, false);
8141   return this;
8142 };
8143 SVGAnimateColorElement.constructor = SVGAnimationElement;
8144 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8145
8146 function SVGAnimateTransformElement() {
8147   SVGAnimationElement.apply(this);
8148   NAIBU.Clip[NAIBU.Clip.length] = this;
8149   this.addEventListener("beginEvent", function(evt) {
8150     var tar = evt.target, trans = tar.targetElement.transform;
8151     /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8152      *baseValと同じような値に設定。
8153      */
8154     trans.animVal = new SVGTransformList();
8155     if (trans.baseVal.numberOfItems !== 0) {
8156       trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8157     }
8158     trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8159   }, false);
8160   this.addEventListener("endEvent", function(evt) {
8161     var tar = evt.target;
8162   }, false);
8163   this.addEventListener("repeatEvent", function(evt) {
8164     var tar = evt.target;
8165   }, false);
8166   return this;
8167 };
8168 SVGAnimateTransformElement.constructor = SVGAnimationElement;
8169 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8170
8171 function SVGFontElement() /*: 
8172                 SVGElement,
8173                 SVGExternalResourcesRequired,
8174                 SVGStylable*/ {
8175   SVGElement.apply(this);
8176   /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8177   /*boolean or number*/ this._isExternal = 0;
8178   this.addEventListener("DOMNodeInserted", function(evt){
8179     var tar = evt.target;
8180     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8181       return;
8182     }
8183     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8184       var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8185       var nefunc = function(evt){
8186         var svg = evt.target;
8187         /*以下のtarはfont要素*/
8188         var familyName = fontFace.getAttributeNS(null, "font-family");
8189         var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8190         for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8191           var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8192           if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8193             NAIBU._noie_createFont(ti, _tar, true);
8194           }
8195         }
8196         evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8197       };
8198       if (!fontFace.__isLinked || tar._isExternal) {
8199         tar.ownerDocument.documentElement._svgload_limited = 0;
8200         tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8201       }
8202     }, false);
8203   }, false);
8204   return this;
8205 };
8206 SVGFontElement.constructor = SVGElement;
8207 SVGFontElement.prototype = new SVGElement();
8208
8209 function SVGGlyphElement() /*: 
8210                 SVGElement,
8211                 SVGStylable*/ {
8212   SVGElement.apply(this);
8213   return this;
8214 };
8215 SVGGlyphElement.constructor = SVGElement;
8216 SVGGlyphElement.prototype = new SVGElement();
8217
8218 function SVGMissingGlyphElement() /*: 
8219                 SVGElement,
8220                 SVGStylable*/ {
8221   SVGElement.apply(this);
8222   return this;
8223 };
8224 SVGMissingGlyphElement.constructor = SVGElement;
8225 SVGMissingGlyphElement.prototype = new SVGElement();
8226
8227 function SVGHKernElement() {
8228   SVGElement.apply(this);
8229   return this;
8230 };
8231 SVGHKernElement.constructor = SVGElement;
8232 SVGHKernElement.prototype = new SVGElement();
8233
8234 function SVGVKernElement() {
8235   SVGElement.apply(this);
8236   return this;
8237 };
8238 SVGVKernElement.constructor = SVGElement;
8239 SVGVKernElement.prototype = new SVGElement();
8240
8241 function SVGFontFaceElement() {
8242   SVGElement.apply(this);
8243   /*boolean(or number)*/ this._isLinked = 0;
8244   this.addEventListener("DOMNodeInserted", function(evt){
8245     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8246       if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8247         evt.currentTarget._isLinked = 1;
8248       }
8249       return; //強制終了させる
8250     }
8251   }, false);
8252   return this;
8253 };
8254 SVGFontFaceElement.constructor = SVGElement;
8255 SVGFontFaceElement.prototype = new SVGElement();
8256
8257 function SVGFontFaceSrcElement() {
8258   SVGElement.apply(this);
8259   return this;
8260 };
8261 SVGFontFaceSrcElement.constructor = SVGElement;
8262 SVGFontFaceSrcElement.prototype = new SVGElement();
8263
8264 function SVGFontFaceUriElement() {
8265   SVGElement.apply(this);
8266   this.addEventListener("DOMNodeInserted", function(evt){
8267     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8268       return; //強制終了させる
8269     }
8270     evt.target.ownerDocument.documentElement._svgload_limited--
8271     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8272   }, false);
8273   this.addEventListener("S_Load", function(evt){
8274     var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8275     if (tpp.localName === "defs") {
8276       tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8277     }
8278     tar._instance._isExternal = 1;
8279     tpp.parentNode.appendChild(tar._instance);
8280     evt = tar = tpp = void 0;
8281   }, false);
8282   SVGURIReference.apply(this);
8283   return this;
8284 };
8285 SVGFontFaceUriElement.constructor = SVGElement;
8286 SVGFontFaceUriElement.prototype = new SVGElement();
8287
8288 function SVGFontFaceFormatElement() {
8289   SVGElement.apply(this);
8290   return this;
8291 };
8292 SVGFontFaceFormatElement.constructor = SVGElement;
8293 SVGFontFaceFormatElement.prototype = new SVGElement();
8294
8295 function SVGFontFaceNameElement() {
8296   SVGElement.apply(this);
8297   return this;
8298 };
8299 SVGFontFaceNameElement.constructor = SVGElement;
8300 SVGFontFaceNameElement.prototype = new SVGElement();
8301
8302 function SVGDefinitionSrcElement() {
8303   SVGElement.apply(this);
8304   return this;
8305 };
8306 SVGDefinitionSrcElement.constructor = SVGElement;
8307 SVGDefinitionSrcElement.prototype = new SVGElement();
8308
8309 function SVGMetadataElement() {
8310   SVGElement.apply(this);
8311   return this;
8312 };
8313 SVGMetadataElement.constructor = SVGElement;
8314 SVGMetadataElement.prototype = new SVGElement();
8315
8316 function SVGForeignObjectElement() /*: 
8317                 SVGElement,
8318                 SVGTests,
8319                 SVGLangSpace,
8320                 SVGExternalResourcesRequired,
8321                 SVGStylable,
8322                 SVGTransformable,
8323                 events::EventTarget*/ { 
8324   SVGElement.apply(this);
8325   var sl = SVGAnimatedLength;
8326   /*readonly SVGAnimatedLength*/ this.x = new sl();
8327   /*readonly SVGAnimatedLength*/ this.y = new sl();
8328   /*readonly SVGAnimatedLength*/ this.width = new sl();
8329   /*readonly SVGAnimatedLength*/ this.height = new sl();
8330   sl = void 0;
8331   return this;
8332 };
8333 SVGForeignObjectElement.constructor = SVGElement;
8334 SVGForeignObjectElement.prototype = new SVGElement();
8335
8336 //#endif  _SVG_IDL_
8337 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8338  *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8339  *SIEでは軽量化のために、マッピングを用いた
8340  */
8341 DOMImplementation["http://www.w3.org/2000/svg"] = {
8342   Document:        SVGDocument,
8343   svg:             SVGSVGElement,
8344   g:               SVGGElement,
8345   path:            NAIBU.SVGPathElement,
8346   title:           SVGTitleElement,
8347   desc:            SVGDescElement,
8348   defs:            SVGDefsElement,
8349   linearGradient:  SVGLinearGradientElement,
8350   radialGradient:  SVGRadialGradientElement,
8351   stop:            SVGStopElement,
8352   rect:            SVGRectElement,
8353   circle:          SVGCircleElement,
8354   ellipse:         SVGEllipseElement,
8355   polyline:        SVGPolylineElement,
8356   polygon:         SVGPolygonElement,
8357   text:            SVGTextElement,
8358   tspan:           SVGTSpanElement,
8359   image:           SVGImageElement,
8360   line:            SVGLineElement,
8361   a:               SVGAElement,
8362   altGlyphDef:     SVGAltGlyphDefElement,
8363   altGlyph:        SVGAltGlyphElement,
8364   altGlyphItem:    SVGAltGlyphItemElement,
8365   animateColor:    SVGAnimateColorElement,
8366   animate:         SVGAnimateElement,
8367   animateMotion:   SVGAnimateMotionElement,
8368   animateTransform:SVGAnimateTransformElement,
8369   clipPath:        SVGClipPathElement,
8370   colorProfile:    SVGColorProfileElement,
8371   cursor:          SVGCursorElement,
8372   definitionSrc:   SVGDefinitionSrcElement,
8373   feBlend:         SVGFEBlendElement,
8374   feGaussianBlur:  SVGFEGaussianBlurElement,
8375   filter:          SVGFilterElement,
8376   font:            SVGFontElement,
8377   "font-face":     SVGFontFaceElement,
8378   "font-face-format":SVGFontFaceFormatElement,
8379   "font-face-name":SVGFontFaceNameElement,
8380   "font-face-src": SVGFontFaceSrcElement,
8381   "font-face-uri": SVGFontFaceUriElement,
8382   foreignObject:   SVGForeignObjectElement,
8383   glyph:           SVGGlyphElement,
8384   glyphRef:        SVGGlyphRefElement,
8385   hkern:           SVGHKernElement,
8386   marker:          SVGMarkerElement,
8387   mask:            SVGMaskElement,
8388   metadata:        SVGMetadataElement,
8389   missingGlyph:    SVGMissingGlyphElement,
8390   mpath:           SVGMPathElement,
8391   script:          SVGScriptElement,
8392   set:             SVGSetElement,
8393   style:           SVGStyleElement,
8394   "switch":        SVGSwitchElement,
8395   textPath:        SVGTextPathElement,
8396   tref:            SVGTRefElement,
8397   use:             SVGUseElement,
8398   view:            SVGViewElement,
8399   vkern:           SVGVKernElement,
8400   pattern:         SVGPatternElement
8401 };
8402
8403 NAIBU._fontSearchURI = function(evt){
8404   var doc = evt.target.ownerDocument;
8405   var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8406   for (var i=0;i<tsrc.length;++i) {
8407     var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8408         ids = src.split(":")[1],
8409         xmlhttp = NAIBU.xmlhttp;
8410     xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8411     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8412     xmlhttp.onreadystatechange = function() {
8413       if ((xmlhttp.readyState === 4)  &&  (xmlhttp.status === 200)) {
8414         var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8415         NAIBU._font({document:doce, docu:doc, id:ids});
8416         xmlhttp = doc = doce = void 0;
8417       }
8418     };
8419     xmlhttp.send(null);
8420   }
8421 };
8422 /*_font関数は、SVGFontで使う*/
8423 NAIBU._font = function (data) {
8424   var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8425   //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8426   var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8427   var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8428   if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8429     var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8430     for (var i=0,tli=textElements.length;i<tli;++i) {
8431       var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8432       if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8433         NAIBU._noie_createFont(ti, font, false);
8434       }
8435     }
8436   }
8437   doc = data = void 0;
8438 };
8439 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8440   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8441       svgns = "http://www.w3.org/2000/svg",
8442       //isTategakiは縦書きならば真
8443       isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8444       horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8445       node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8446       em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8447       advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8448       dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8449       dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8450       fontSize = parseFloat(style.getPropertyValue("font-size")),
8451       fe = fontSize / em,
8452       ds = false, npdlist = ["fill",
8453   "fill-opacity",
8454   "stroke",
8455   "stroke-width",
8456   "stroke-linecap",
8457   "stroke-linejoin",
8458   "stroke-miterlimit",
8459   "stroke-dasharray",
8460   "stroke-opacity",
8461   "opacity",
8462   "cursor"];
8463   if (/a/[-1] === 'a') { //Firefoxならば
8464     ds = true;
8465   } else if (isMSIE || isTategaki) {
8466     ds = true;
8467   }
8468   if (ds){
8469      while(node) {
8470       if (!glyphs) {
8471         break;
8472       }
8473       data = node.data;
8474       if (data !== void 0) { //dataがある場合
8475         var advanceX = [], glyphData = [];
8476         for (var i=0,gli=glyphs.length;i<gli;++i) {
8477           var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8478           var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8479           if (orientation) {
8480             if (orientation === "h") {
8481               isVert = false;
8482             }
8483           } else {
8484             isOrientationAttribute = false;
8485           }
8486           if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8487             //indexは該当する文字が何番目にあるかの数字
8488             var index = data.indexOf(unicode);
8489             while (index > -1) {
8490               advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8491               glyphData[index] = glyph.getAttributeNS(null, "d");
8492               index = data.indexOf(unicode, index+1);
8493             }
8494           }
8495         }
8496         for (var i=0,adv=0;i<data.length;++i) {
8497           if (advanceX[i] !== void 0) { //配列に含まれていれば
8498             var path = ti.ownerDocument.createElementNS(svgns, "path");
8499             //advance、すなわち字幅の長さ分、ずらしていく
8500             var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8501             matrix.a = fe;
8502             matrix.d = -fe;
8503             for (var j=0;j<npdlist.length;++j){
8504               var nj = npdlist[j],
8505                   tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
8506               if (nj === "stroke-width") {
8507                 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
8508                 tg += "";
8509               }
8510               if (tg) {
8511                 path.setAttributeNS(null, nj, tg);
8512               }
8513             }
8514             if (isTategaki) {
8515               var y= dy + adv*fe, x = dx;
8516               if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8517                 var fms = fontSize / Math.SQRT2;
8518                 x += fms;
8519                 y -= fms;
8520                 fms = void 0;
8521               }
8522               matrix.e = x;
8523               matrix.f = y;
8524             } else {
8525               matrix.e = dx + adv*fe;
8526               matrix.f = dy;
8527             }
8528             path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8529             path.setAttributeNS(null, "d", glyphData[i]);
8530             ti.parentNode.insertBefore(path, ti);
8531             adv += advanceX[i];
8532             matrix = void 0;
8533           }
8534         }
8535         adv = advanceX = glyphData = void 0;
8536       } else if ("tspan|a".indexOf(node.localName) > -1){
8537         NAIBU._noie_createFont(node, font, isMSIE);
8538       }
8539       node = node.nextSibling;
8540     }
8541     if (isMSIE) {
8542       var style = ti.ownerDocument.getOverrideStyle(ti, null);
8543       style.setProperty("visibility", "hidden");
8544       style = void 0;
8545     } else {
8546       ti.setAttributeNS(null, "opacity", "0");
8547     }
8548   }
8549   data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8550 };
8551
8552 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8553  *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8554  */
8555 (function(){
8556   var s = new CSSStyleDeclaration(),
8557        slis = s._list,
8558       n = 0,
8559       regAZ = /([A-Z])/,
8560       regm = /\-/,
8561       u, t;
8562   for (var i in CSS2Properties) {
8563     if(CSS2Properties.hasOwnProperty(i)) {
8564       t = i.replace(regAZ, "-");
8565       if (!!RegExp.$1) {
8566         u = "-" +RegExp.$1.toLowerCase();
8567       } else {
8568         u = "-";
8569       }
8570       t = t.replace(regm, u);
8571       s.setProperty(t, CSS2Properties[i]);
8572       slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8573       slis[n]._isDefault = 1;
8574       ++n;
8575       i = t = u =  void 0;
8576     }
8577   }
8578   slis._opacity = 1;
8579   slis._fontSize = 12;
8580   CSS2Properties._list = slis;
8581   Document.prototype.defaultView._defaultCSS = slis;
8582   s = n = regAZ = regm = slis =null;
8583 })();
8584
8585 NAIBU.addEvent = function(evt,lis){
8586   if (window.addEventListener) {
8587     window.addEventListener(evt, lis, false);
8588   } else if (window.attachEvent) {
8589     window.attachEvent('on'+evt, lis);
8590   } else {
8591     window['on'+evt] = lis;
8592   }
8593   //Sieb用
8594   if (sieb_s) {
8595     lis();
8596   }
8597 };
8598
8599 function unsvgtovml() {
8600   try {
8601     if ("stop" in NAIBU) {
8602       clearInterval(NAIBU.stop);
8603     }
8604     window.onscroll = NAIBU.emptyFunction;
8605     window.detachEvent("onload", NAIBU._main);
8606     NAIBU.freeArg();
8607     Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
8608     Array = ActiveXObject = void 0;
8609   } catch(e) {}
8610 }
8611 /*_main関数
8612  *一番最初に起動するべき関数 
8613  */
8614 NAIBU._main = (function() {
8615   stlog = new STLog(false);
8616   var xmlhttp,         //XMLHttpオブジェクトを生成
8617       _doc = document; //documentのエイリアスを作成
8618   try {
8619     if (XMLHttpRequest) {
8620       xmlhttp = false;
8621     } else {
8622       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
8623     }
8624   } catch (e) {
8625     try {
8626       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
8627     } catch (E) {
8628       xmlhttp = false;
8629     }
8630   }
8631   if (!xmlhttp) {
8632     try {
8633       xmlhttp = new XMLHttpRequest();
8634     } catch (e) {
8635       xmlhttp = false;
8636     }
8637   }
8638   NAIBU.xmlhttp = xmlhttp;
8639   var nd;
8640   if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
8641     try {
8642       NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
8643     } catch (e) {
8644       
8645     }
8646     nd = NAIBU.doc;
8647     _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
8648     _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
8649     var st = _doc.createStyleSheet();
8650     var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
8651     st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
8652       + "dn\\:defs{display:none}"
8653       + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
8654       + "v\\:shape{width:100%;height:100%;" +vmlUrl;
8655   }
8656   var ary = _doc.getElementsByTagName("script");
8657   //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
8658   for (var i=0; ary[i]; ++i) {
8659     var ai = ary[i],
8660         hoge = ai.type;
8661     if (ai.type === "image/svg+xml") {
8662       var ait = ai.text;
8663       if (sieb_s && ait.match(/&lt;svg/)) {
8664         //ソース内のタグを除去
8665         ait = ait.replace(/<.+?>/g, "");
8666         //エンティティを文字に戻す
8667         ait = ait.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
8668       }
8669       if (NAIBU.isMSIE) {
8670         var gsd = new GetSVGDocument(ai);
8671         gsd.xmlhttp = {
8672           readyState : 4,
8673           status : 200,
8674           responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
8675         }
8676         gsd._ca();
8677       } else {
8678         var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
8679         ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
8680         var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
8681         ai.parentNode.insertBefore(s,ai);
8682       }
8683       ai = ait = void 0;
8684     }
8685     hoge = void 0;
8686   }
8687   NAIBU.doc = nd;
8688   nd = ary = void 0;
8689   if (xmlhttp && NAIBU.isMSIE) {
8690     if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
8691     } else { //IE6-8ならば
8692       var ob = _doc.getElementsByTagName("object"),
8693           em = _doc.getElementsByTagName("embed"),
8694           s=[],
8695           _search = function(_ob) {
8696             var ifr, obi, n;
8697             s || (s = []);             //NAIBU._searchで呼ばれたときに必要
8698             _doc || (_doc = document);
8699             for (var i=0;_ob[i];++i) {
8700               obi = _ob[i];
8701               s[s.length] = new GetSVGDocument(obi);
8702               ifr = _doc.createElement("iframe");
8703               ifr.style.background = "black";
8704               n = obi.getAttribute("width");
8705               n && ifr.setAttribute("width", n);
8706               n = obi.getAttribute("height");
8707               n && ifr.setAttribute("height", n);
8708               ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
8709               ifr.scrolling = "no";
8710               ifr.frameBorder = "0";
8711              /*iframe要素を使って、描画のプロセスを分離する
8712               *したがって、_docはdocumentとは別のオブジェクトとなる
8713               */
8714               obi.parentNode.insertBefore(ifr, obi);
8715             }
8716             i = obi = ifr = _ob = void 0;
8717             return s[s.length-1];
8718           };
8719       _search(ob);
8720       _search(em);
8721       NAIBU._search = _search; //a要素がクリックされたときに使う関数
8722       ob = em = _search = void 0;
8723       for (var i=0;i<s.length;++i) {
8724         if (i < s.length-1) {
8725           s[i]._next = s[i+1]
8726         }
8727       }
8728       if (i > 0) {
8729         s[0]._init(); //初期化作業を開始
8730       }
8731       s = void 0;
8732     }
8733   } else {
8734     var ob = _doc.getElementsByTagName("object");
8735     for (var i=0;i<ob.length;++i) {
8736       if (ob[i].contentDocument) {
8737         NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
8738       } else if (ob[i].getSVGDocument) {
8739         ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
8740       } else {
8741       }
8742     }
8743   }
8744   xmlhttp = _doc = void 0;
8745 });
8746 NAIBU.addEvent("load", NAIBU._main);
8747 NAIBU.utf16 = function ( /*string*/ s)  {
8748   return unescape(s);
8749 }
8750 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
8751   return s.replace(/%u\w\w\w\w/g,  NAIBU.utf16);
8752 }
8753 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
8754 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
8755   /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
8756    *dataスキーム方式を採用する
8757    */
8758   if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
8759     var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
8760     var ob = document.createElement("object");
8761     ob.setAttribute("data",data);
8762     ob.setAttribute("width",w);
8763     ob.setAttribute("height",h);
8764     ob.setAttribute("type","image/svg+xml");
8765     return ob;
8766   } else {
8767     var doc = (new DOMParser()).parseFromString(source, "text/xml");
8768     return (document.importNode(doc.documentElement, true));
8769   }
8770 };
8771 NAIBU.addEvent("unload", unsvgtovml);
8772 //IEならばtrue
8773 NAIBU.isMSIE = /*@cc_on!@*/false;