OSDN Git Service

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