/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:24
*/
KISSY.add("htmlparser/Parser",function(b,j,i,e,a,g,l,n){function h(c,f){this.originalHtml=c=b.trim(c);c=/^(<!doctype|<html|<body)/i.test(c)?"<document>"+c+"</document>":"<body>"+c+"</body>";this.lexer=new g(c);this.opts=f||{}}function k(c){var f=q(c,"body",3);if(f){var c=f.parentNode,d=c.childNodes,h=b.indexOf(f,d);if(h!=d.length-1){d=d.slice(h+1,d.length);for(h=0;h<d.length;h++)c.removeChild(d[h]),"body"==d[h].tagName?b.each(d[h].childNodes,function(c){f.appendChild(c)}):f.appendChild(d[h])}}return f}
function f(c){var f=c.childNodes,d,h,q=j.p,a=0;for(h=0;h<f.length;h++)if(d=f[h],3==d.nodeType||1==d.nodeType&&q[d.nodeName]){a=1;break}if(a){var a=[],g=new i;g.nodeName=g.tagName="p";for(h=0;h<f.length;h++)d=f[h],3==d.nodeType||1==d.nodeType&&q[d.nodeName]?g.appendChild(d):(g.childNodes.length&&(a.push(g),g=g.clone()),a.push(d));g.childNodes.length&&a.push(g);c.empty();for(h=0;h<a.length;h++)c.appendChild(a[h])}}function q(f,d,h){if(0===h)return 0;b.isNumber(h)&&h--;var a=f.childNodes;if(a)for(var g=
0;g<a.length;g++){if(a[g].tagName===d)return a[g];if(f=q(a[g],d,h))return f}return 0}function d(f){for(var d=[].concat(f.childNodes),h=0;h<d.length;h++)if("html"==d[h].nodeName){for(var a=d[h],g=0;g<h;g++)3==d[g].nodeType&&!b.trim(d[g].toHtml())&&f.removeChild(d[g]);for(;a.firstChild&&3==a.firstChild.nodeType&&!b.trim(a.firstChild.toHtml());)a.removeChild(a.firstChild);break}}h.prototype={elements:function(){var c,h,a=this.lexer,g=this.opts;h=c=a.nextNode();"document"!=c.tagName&&(h=new l,h.appendChild(c));
h.nodeType=9;n.getScanner("div").scan(c,a,g);(c=k(h))&&g.autoParagraph&&f(c);d(h);var g=this.originalHtml,q=new e;h=/^(<!doctype|<html|<body)/i.test(g)?h.childNodes:c.childNodes;b.each(h,function(f){q.appendChild(f)});return q},parse:function(){return this.elements()}};return h},{requires:"./dtd,./nodes/Tag,./nodes/Fragment,./lexer/Cursor,./lexer/Lexer,./nodes/Document,./Scanner".split(",")});
KISSY.add("htmlparser/Scanner",function(b,j,i){return{getScanner:function(b){return i[b]||j}}},{requires:["./scanners/TagScanner","./scanners/SpecialScanners","./scanners/QuoteCdataScanner","./scanners/TextareaScanner"]});
KISSY.add("htmlparser/Utils",function(){return{collapseWhitespace:function(b){return b.replace(/[\s\xa0]+/g," ")},isLetter:function(b){return"a"<=b&&"z">=b||"A"<=b&&"Z">=b},isValidAttributeNameStartChar:function(b){return!this.isWhitespace(b)&&'"'!=b&&"'"!=b&&">"!=b&&"<"!=b&&"/"!=b&&"="!=b},isWhitespace:function(b){return/^[\s\xa0]$/.test(b)}}});
KISSY.add("htmlparser/dtd",function(b){var b=b.merge,j={isindex:1,fieldset:1},i={input:1,button:1,select:1,textarea:1,label:1},e=b({a:1},i),a=b({iframe:1},e),g={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},l={ins:1,del:1,script:1,style:1},n=b({b:1,acronym:1,bdo:1,"var":1,"#text":1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},l),h=b({sub:1,img:1,object:1,
sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},n),k=b({p:1},h),i=b({iframe:1},h,i),h={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,"#text":1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,"var":1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,
u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},f=b({a:1},i),q={tr:1},d={"#text":1},c=b({param:1},h),m=b({form:1},j,a,g,k),s={li:1},p={base:1,link:1,meta:1,title:1},o=b(p,{style:1,script:1}),t={head:1,body:1},r={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1},b={$nonBodyContent:b({html:1},t,p),$block:r,$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:f,$body:b({script:1,style:1},
r),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,
select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:t,head:o,style:d,body:m,base:{},link:{},meta:{},title:d,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:m,td:m,br:{},th:m,center:m,kbd:f,button:b(k,g),basefont:{},h5:f,h4:f,samp:f,h6:f,ol:s,h1:f,h3:f,option:d,h2:f,form:b(j,a,g,k),select:{optgroup:1,option:1},font:f,ins:f,menu:s,abbr:f,label:f,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:f,script:d,tfoot:q,cite:f,
li:m,input:{},iframe:m,strong:f,textarea:d,noframes:m,big:f,small:f,span:f,hr:{},dt:f,sub:f,optgroup:{option:1},param:{},bdo:f,"var":f,div:m,object:c,sup:f,dd:m,strike:f,area:{},dir:s,map:b({area:1,form:1,p:1},j,l,g),applet:c,dl:{dt:1,dd:1},del:f,isindex:{},fieldset:b({legend:1},h),thead:q,ul:s,acronym:f,b:f,a:i,blockquote:m,caption:f,i:f,u:f,tbody:q,s:f,address:b(a,k),tt:f,legend:f,q:f,pre:b(n,e),p:f,em:f,dfn:f},e="article,figure,nav,aside,section,footer".split(","),u;for(u in b)for(var v in b[u])if("div"==
v)for(j=0;j<e.length;j++)b[u][e[j]]=b[u][v];for(j=0;j<e.length;j++)b[e[j]]=b.div;b.$empty["!doctype"]=1;return b});KISSY.add("htmlparser",function(b,j,i,e,a,g,l,n,h,k,f,q,d){return{CData:h,Comment:k,Node:f,Tag:q,Text:d,Lexer:i,Parser:e,BasicWriter:a,BeautifyWriter:g,MinifyWriter:l,Filter:n,DTD:j,serialize:function(f,d){var h=new a;f.writeHtml(h,d);return h.getHtml()},parse:function(f){return(new e(f)).parse()}}},{requires:"htmlparser/dtd,htmlparser/lexer/Lexer,htmlparser/Parser,htmlparser/writer/basic,htmlparser/writer/beautify,htmlparser/writer/minify,htmlparser/writer/filter,htmlparser/nodes/CData,htmlparser/nodes/Comment,htmlparser/nodes/Node,htmlparser/nodes/Tag,htmlparser/nodes/Text".split(",")});
KISSY.add("htmlparser/lexer/Cursor",function(){function b(b){this.position=b||0}b.prototype={advance:function(){this.position++},retreat:function(){this.position=Math.max(--this.position,0)}};return b});
KISSY.add("htmlparser/lexer/Index",function(){function b(){this.lineCursors=[]}function j(b,a){for(var g=0;g<b.length;g++)if(b[g].position===a.position)return g;return-1}function i(b,a){for(var g=0;g<b.length&&!(b[g].position>a.position);g++);return g}b.prototype={add:function(b){-1==j(this.lineCursors,b)&&this.lineCursors.splice(i(this.lineCursors,b),0,b)},remove:function(b){var a=this.lineCursors,b=j(this.lineCursors,b);-1!=b&&a.splice(b,1)},row:function(b){return i(this.lineCursors,b)-1},col:function(b){var a=
i(this.lineCursors,b)-1;return b.position-this.lineCursors[a]}};return b});
KISSY.add("htmlparser/lexer/Lexer",function(b,j,i,e,a,g,l,n,h){function k(f){this.page=new i(f);this.cursor=new j;this.nodeFactory=this}k.prototype={setPosition:function(f){this.cursor.position=f},getPosition:function(){return this.cursor.position},nextNode:function(f){var h,d,c=this.cursor,a=this.page;h=c.position;d=a.getChar(c);switch(d){case -1:f=null;break;case "<":d=a.getChar(c);-1==d?f=this.makeString(h,c.position):"/"==d||g.isLetter(d)?(a.ungetChar(c),f=this.parseTag(h)):"!"==d||"?"==d?(d=
a.getChar(c),-1==d?f=this.makeString(h,c.position):">"==d?f=this.makeComment(h,c.position):(a.ungetChar(c),"-"==d?f=this.parseComment(h,f):(a.ungetChar(c),f=this.parseTag(h)))):(a.ungetChar(c),f=this.parseString(h,f));break;default:a.ungetChar(c),f=this.parseString(h,f)}return f},makeComment:function(f,h){var d;d=h-f;if(0!=d){if(2>d)return this.makeString(f,h);d=this.nodeFactory.createCommentNode(this.page,f,h)}else d=null;return d},makeString:function(f,h){var d=null;0<h-f&&(d=this.nodeFactory.createStringNode(this.page,
f,h));return d},makeCData:function(f,h){var d=null;0<h-f&&(d=this.nodeFactory.createCDataNode(this.page,f,h));return d},makeTag:function(f,h,d){var c;c=h-f;if(0!=c){if(2>c)return this.makeString(f,h);f=this.nodeFactory.createTagNode(this.page,f,h,d)}else f=null;return f},createTagNode:function(f,h,d,c){return new n(f,h,d,c)},createStringNode:function(f,h,d){return new e(f,h,d)},createCDataNode:function(f,h,d){return new a(f,h,d)},createCommentNode:function(f,a,d){return new h(f,a,d)},parseTag:function(f){var h,
d=[],c=[],a,b=this.page,k=0,e=this.cursor;for(d[0]=e.position;!h;)switch(d[k+1]=e.position,a=b.getChar(e),k){case 0:if(-1==a||">"==a||"<"==a)"<"==a&&(b.ungetChar(e),d[k+1]=e.position),h=!0;else if("/"==a||g.isValidAttributeNameStartChar(a))k=1;break;case 1:-1==a||">"==a||"<"==a?("<"==a&&(b.ungetChar(e),d[k+1]=e.getPosition),this.standalone(c,d),h=!0):g.isWhitespace(a)?(d[6]=d[2],k=6):"="==a&&(k=2);break;case 2:-1==a||">"==a?(this.standalone(c,d),h=!0):"'"==a?(k=4,d[4]=d[3]):'"'==a?(k=5,d[5]=d[3]):
g.isWhitespace(a)||(k=3);break;case 3:-1==a||">"==a?(this.naked(c,d),h=!0):g.isWhitespace(a)&&(this.naked(c,d),d[0]=d[4],k=0);break;case 4:-1==a?(this.single_quote(c,d),h=!0):"'"==a&&(this.single_quote(c,d),d[0]=d[5]+1,k=0);break;case 5:-1==a?(this.double_quote(c,d),h=!0):'"'==a&&(this.double_quote(c,d),d[0]=d[6]+1,k=0);break;case 6:-1==a?(this.standalone(c,d),d[0]=d[6],b.ungetChar(e),k=0):g.isWhitespace(a)||("="==a?(d[2]=d[6],d[3]=d[7],k=2):(this.standalone(c,d),d[0]=d[6],b.ungetChar(e),k=0));break;
default:throw Error("how ** did we get in state "+k);}return this.makeTag(f,e.position,c)},parseComment:function(h,a){var d,c,b=this.page,k=this.cursor,e;d=!1;for(e=0;!d;)if(c=b.getChar(k),-1==c)d=!0;else switch(e){case 0:">"==c&&(d=!0);if("-"==c)e=1;else return this.parseString(h,a);break;case 1:if("-"==c)c=b.getChar(k),-1==c?d=!0:">"==c?d=!0:(b.ungetChar(k),e=2);else return this.parseString(h,a);break;case 2:if("-"==c)e=3;else if(-1==c)return this.parseString(h,a);break;case 3:e="-"==c?4:2;break;
case 4:">"==c?d=!0:g.isWhitespace(c)||(e=2);break;default:throw Error("how ** did we get in state "+e);}return this.makeComment(h,k.position)},parseString:function(h,a){for(var d=0,c,b=this.page,k=this.cursor,e=0;!d;)if(c=b.getChar(k),-1==c)d=1;else if(a&&0==e&&("'"==c||'"'==c))e=c;else if(a&&0!=e&&"\\"==c)c=b.getChar(k),-1!=c&&"\\"!=c&&c!=e&&b.ungetChar(k);else if(a&&c==e)e=0;else if(a&&0==e&&"/"==c)if(c=b.getChar(k),-1==c)d=1;else if("/"==c){do c=b.getChar(k);while(-1!=c&&"\n"!=c)}else if("*"==
c){do{do c=b.getChar(k);while(-1!=c&&"*"!=c);c=b.getChar(k);"*"==c&&b.ungetChar(k)}while(-1!=c&&"/"!=c)}else b.ungetChar(k);else if(0==e&&"<"==c)if(c=b.getChar(k),-1==c)d=1;else{if("/"==c||g.isLetter(c)||"!"==c||"?"==c)d=1,b.ungetChar(k);b.ungetChar(k)}return this.makeString(h,k.position)},parseCDATA:function(h,a){var d,c,b,k,e,j,i=this.cursor,l=this.page;d=i.position;c=0;b=!1;k="";for(j=!1;!b;)switch(e=l.getChar(i),c){case 0:switch(e){case -1:b=!0;break;case "'":h&&!j&&(""==k?k="'":"'"==k&&(k=""));
break;case '"':h&&!j&&(""==k?k='"':'"'==k&&(k=""));break;case "\\":h&&""!=k&&(e=l.getChar(i),-1==e?b=!0:"\\"!=e&&e!=k&&l.ungetChar(i));break;case "/":if(h&&""==k)if(e=l.getChar(i),-1==e)b=!0;else if("/"==e)j=!0;else if("*"==e){do{do e=l.getChar(i);while(-1!=e&&"*"!=e);e=l.getChar(i);"*"==e&&l.ungetChar(i)}while(-1!=e&&"/"!=e)}else l.ungetChar(i);break;case "\n":j=!1;break;case "<":h?""==k&&(c=1):c=1}break;case 1:switch(e){case -1:b=!0;break;case "/":c=!a||l.getText(i.position,i.position+a.length)===
a&&!l.getText(i.position+a.length,i.position+a.length+1).match(/\w/)?2:0;break;case "!":e=l.getChar(i);-1==e?b=!0:"-"==e?(e=l.getChar(i),-1==e?b=!0:c="-"==e?3:0):c=0;break;default:c=0}break;case 2:j=!1;-1==e?b=!0:g.isLetter(e)?(b=!0,l.ungetChar(i),l.ungetChar(i),l.ungetChar(i)):c=0;break;case 3:j=!1;-1==e?b=!0:"-"==e&&(e=l.getChar(i),-1==e?b=!0:"-"==e?(e=l.getChar(i),-1==e?b=!0:">"==e?c=0:(l.ungetChar(i),l.ungetChar(i))):l.ungetChar(i));break;default:throw Error("unexpected "+c);}return this.makeCData(d,
i.position)},single_quote:function(h,a){var d=this.page;h.push(new l(d.getText(a[1],a[2]),"=",d.getText(a[4]+1,a[5]),"'"))},double_quote:function(h,a){var d=this.page;h.push(new l(d.getText(a[1],a[2]),"=",d.getText(a[5]+1,a[6]),'"'))},standalone:function(h,a){h.push(new l(this.page.getText(a[1],a[2])))},naked:function(h,a){var d=this.page;h.push(new l(d.getText(a[1],a[2]),"=",d.getText(a[3],a[4])))}};return k},{requires:"./Cursor,./Page,../nodes/Text,../nodes/CData,../Utils,../nodes/Attribute,../nodes/Tag,../nodes/Comment".split(",")});
KISSY.add("htmlparser/lexer/Page",function(b,j){function i(b){this.source=b;this.lineIndex=new j}i.prototype={getChar:function(b){var a=this.source,g=b.position;if(g>=a.length)return-1;var i=a.charAt(g);b.advance();"\r"===i&&(i="\n",g=b.position,"\n"===a.charAt(g)&&b.advance());"\n"===i&&this.lineIndex.add(b);return i},ungetChar:function(b){var a=this.source;b.retreat();var g=b.position,i=a.charAt(g);"\n"===i&&0!=g&&(i=a.charAt(g-1),"\r"===i&&b.retreat())},getText:function(b,a){return this.source.slice(b,
a)},row:function(b){return this.lineIndex.row(b)},col:function(b){return this.lineIndex.col(b)}};return i},{requires:["./Index"]});KISSY.add("htmlparser/nodes/Attribute",function(b){function j(b,e,a,g){this.nodeType=2;this.name=b;this.assignMent=e;this.value=a;this.quote=g}b.augment(j,{clone:function(){var i=new j;b.mix(i,this);return i},equals:function(b){return this.name==b.name&&this.value==b.value&&this.nodeType==b.nodeType}});j.prototype.clone=function(){var i=new j;b.mix(i,this);return i};return j});
KISSY.add("htmlparser/nodes/CData",function(b,j){function i(){i.superclass.constructor.apply(this,arguments);this.nodeType=4;this.nodeName="#cdata"}b.extend(i,j,{writeHtml:function(b,a){var g;if(!a||!1!==(g=a.onCData(this)))g&&this!==g?g.writeHtml(b,a):b.cdata(this.toHtml())}});return i},{requires:["./Text"]});
KISSY.add("htmlparser/nodes/Comment",function(b,j){function i(){i.superclass.constructor.apply(this,arguments);this.nodeType=8;this.nodeName="#comment"}b.extend(i,j,{writeHtml:function(b,a){var g;if(!a||!1!==(g=a.onComment(this)))g&&this!==g?g.writeHtml(b,a):b.comment(this.toHtml())},toHtml:function(){if(this.nodeValue)return this.nodeValue;var b=j.superclass.toHtml.apply(this,arguments);return b.substring(4,b.length-3)}});return i},{requires:["./Text"]});
KISSY.add("htmlparser/nodes/Document",function(b,j){function i(){this.childNodes=[];this.nodeType=9;this.nodeName="#document"}b.extend(i,j,{writeHtml:function(b,a){this.__filter=a;this._writeChildrenHtml(b)}});return i},{requires:["./Tag"]});
KISSY.add("htmlparser/nodes/Fragment",function(b,j){function i(){this.childNodes=[];this.nodeType=9;this.nodeName="#fragment"}b.extend(i,j,{writeHtml:function(b,a){this.__filter=a;this.isChildrenFiltered=0;if(a)a.onFragment(this);this._writeChildrenHtml(b)}});return i},{requires:["./Tag"]});
KISSY.add("htmlparser/nodes/Node",function(b){function j(b){var a=0;b.replace(/\n/g,function(){a++});return a}function i(e,a,g){this.parentNode=null;this.page=e;this.startPosition=a;this.endPosition=g;this.nextSibling=this.previousSibling=this.nodeName=null;e&&(this.startLine=j(this.page.getText(0,a)),this.endLine=j(this.page.getText(0,g)));b.Config.debug&&(this.toHtmlContent=this.toHtml())}i.prototype={toHtml:function(){if(this.page&&this.page.getText)return this.page.getText(this.startPosition,
this.endPosition)},toString:function(){var b=[];b.push(this.nodeName+"  [ "+this.startPosition+"|"+this.startLine+" : "+this.endPosition+"|"+this.endLine+" ]\n");b.push(this.toHtml());return b.join("")}};return i});
KISSY.add("htmlparser/nodes/Tag",function(b,j,i,e){function a(h,a,f){h.nodeName=h.tagName=a.toLowerCase();h._updateSelfClosed();b.each(f,function(a,b){h.setAttribute(b,a)})}function g(h,k,f,e){this.childNodes=[];this.lastChild=this.firstChild=null;this.attributes=e||[];this.nodeType=1;if(b.isString(h))a.apply(null,[this].concat(b.makeArray(arguments)));else{g.superclass.constructor.apply(this,arguments);e=this.attributes;e[0]&&(this.nodeName=e[0].name.toLowerCase(),this.tagName=this.nodeName.replace(/\//,
""),this._updateSelfClosed(),e.splice(0,1));var d=e[e.length-1];if(d=!(!d||!/\/$/.test(d.name)))e.length-=1;this.closed=this.isSelfClosed=this.isSelfClosed||d}this.closedEndPosition=this.closedStartPosition=-1}function l(h){var a=h.childNodes;h.firstChild=a[0];h.lastChild=a[a.length-1];1<=a.length&&(a[0].nextSibling=a[0].nextSibling=null,a[0].parentNode=h);if(1<a.length){for(var b=0;b<a.length-1;b++)a[b].nextSibling=a[b+1],a[b+1].previousSibling=a[b],a[b+1].parentNode=h;a[a.length-1].nextSibling=
null}}function n(a,b){for(var f=0;f<a.length;f++)if(a[f].name==b)return a[f];return null}b.extend(g,j,{_updateSelfClosed:function(){this.isSelfClosed=!!e.$empty[this.nodeName];this.isSelfClosed||(this.isSelfClosed=/\/$/.test(this.nodeName));this.closed=this.isSelfClosed},clone:function(){var a=new g,k=[];b.each(this.attributes,function(a){k.push(a.clone())});b.mix(a,{childNodes:[],firstChild:null,lastChild:null,attributes:k,nodeType:this.nodeType,nodeName:this.nodeName,tagName:this.tagName,isSelfClosed:this.isSelfClosed,
closed:this.closed,closedStartPosition:this.closedStartPosition,closedEndPosition:this.closedEndPosition});return a},setTagName:function(a){(this.nodeName=this.tagName=a)&&this._updateSelfClosed()},equals:function(a){if(!a||this.nodeName!=a.nodeName||this.nodeType!=a.nodeType||this.attributes.length!=a.attributes.length)return 0;for(var b=0;b<this.attributes.length;b++)if(!this.attributes[b].equals(a.attributes[b]))return 0;return 1},isEndTag:function(){return/^\//.test(this.nodeName)},appendChild:function(a){this.childNodes.push(a);
l(this)},replace:function(a){var g=a.parentNode.childNodes,f=b.indexOf(a,g);g[f]=this;l(a.parentNode)},replaceChild:function(a,g){var f=this.childNodes,e=b.indexOf(g,f);f[e]=a;l(this)},prepend:function(a){this.childNodes.unshift(a);l(this)},insertBefore:function(a){var g=a.parentNode.childNodes,f=b.indexOf(a,g);g.splice(f,0,this);l(a.parentNode)},insertAfter:function(a){var g=a.parentNode.childNodes,f=b.indexOf(a,g);f==g.length-1?a.parentNode.appendChild(this):this.insertBefore(a.parentNode.childNodes[[f+
1]])},empty:function(){this.childNodes=[];l(this)},removeChild:function(a){var g=a.parentNode.childNodes,f=b.indexOf(a,g);g.splice(f,1);l(a.parentNode)},getAttribute:function(a){return(a=n(this.attributes,a))&&a.value},setAttribute:function(a,b){var f=n(this.attributes,a);f?f.value=b:this.attributes.push(new i(a,"=",b,'"'))},removeAttribute:function(a){(a=n(this.attributes,a))&&this.attributes.splice(b.indexOf(a,this.attributes),1)},filterChildren:function(){var a=this;if(!a.isChildrenFiltered){var g=
new (b.require("htmlparser/writer/basic"));a._writeChildrenHtml(g);g=(new (b.require("htmlparser/Parser"))(g.getHtml())).parse().childNodes;a.empty();b.each(g,function(b){a.appendChild(b)});a.isChildrenFiltered=1}},writeHtml:function(a,b){var f=this,g;g=f.tagName;if("!doctype"==g)a.append(this.toHtml()+"\n");else{f.__filter=b;f.isChildrenFiltered=0;if(b){if(!(g=b.onTagName(g)))return;f.tagName=g;g=b.onTag(f);if(!1===g)return;g&&(f=g);if(1!==f.nodeType){f.writeHtml(a,b);return}if(!f.tagName){f._writeChildrenHtml(a);
return}}a.openTag(f);for(var d=f.attributes,c=0;c<d.length;c++){var e=d[c];g=e.name;if(b){if(!(g=b.onAttributeName(g,f)))continue;e.name=g;if(!1===b.onAttribute(e,f))continue}a.attribute(e,f)}a.openTagClose(f);f.isSelfClosed||(f._writeChildrenHtml(a),a.closeTag(f))}},_writeChildrenHtml:function(a){var g=this.isChildrenFiltered?0:this.__filter;b.each(this.childNodes,function(b){b.writeHtml(a,g)})}});return g},{requires:["./Node","./Attribute","../dtd"]});
KISSY.add("htmlparser/nodes/Text",function(b,j){function i(e){b.isString(e)?(this.nodeValue=e,i.superclass.constructor.apply(this,[null,-1,-1])):(i.superclass.constructor.apply(this,arguments),this.nodeValue=this.toHtml());this.nodeType=3;this.nodeName="#text"}b.extend(i,j,{writeHtml:function(b,a){var g;if(!a||!1!==(g=a.onText(this)))g&&this!==g?g.writeHtml(b,a):b.text(this.toHtml())},toHtml:function(){return this.nodeValue?this.nodeValue:i.superclass.toHtml.apply(this,arguments)}});return i},{requires:["./Node"]});
KISSY.add("htmlparser/scanners/CdataScanner",function(){return{scan:function(b,j,i){var i=j.parseCDATA(i.quoteSmart,b.nodeName),e=j.getPosition(),a=j.nextNode();a&&(1!=a.nodeType||!(a.isEndTag()&&a.tagName==b.tagName))&&j.setPosition(e);b.closed=!0;i&&b.appendChild(i)}}});KISSY.add("htmlparser/scanners/QuoteCdataScanner",function(b,j,i,e){var b={scan:function(a,b,e){e=e||{};e.quoteSmart=1;j.scan(a,b,e);e.quoteSmart=0}},a;for(a in i.$cdata)e[a]=b;return b},{requires:["./CdataScanner","../dtd","./SpecialScanners"]});
KISSY.add("htmlparser/scanners/SpecialScanners",function(){return{}});
KISSY.add("htmlparser/scanners/TagScanner",function(b,j,i,e){function a(h,e){function f(){c.childNodes.length&&(c.insertAfter(m),m=c,c=h.clone())}h.closed=1;if(!e.fixByDtd)return 0;var n=1,d=[].concat(h.childNodes);b.each(d,function(a){if(!g(h,a))return n=0,!1});if(n)return 0;for(var c=h.clone(),m=h,s=[],p=0;p<d.length;p++){var o=d[p];if(g(c,o))c.appendChild(o);else if(1==o.nodeType){var t=o.tagName;if(j.$listItem[t]){f();var o=l[o.tagName],r=new i;for(r.nodeName=r.tagName=o;p<d.length;){if(d[p].tagName==
t)r.appendChild(d[p]);else if((3!=d[p].nodeType||b.trim(d[p].toHtml()))&&3==d[p].nodeType)break;p++}r.insertAfter(m);m=r;p--}else f(),o.equals(c)?(o.insertAfter(m),m=o):g(o,c)?(c=h.clone(),b.each(o.childNodes,function(a){c.appendChild(a)}),o.empty(),o.insertAfter(m),m=o,o.appendChild(c),s.push(c),c=h.clone()):(o.insertAfter(m),m=o)}}c.childNodes.length&&c.insertAfter(m);h.parentNode.removeChild(h);b.each(s,function(b){a(b,e)});return 1}function g(a,b){return 9==a.nodeType||8==b.nodeType?1:!!j[a.tagName][b.tagName||
b.nodeName]}var l={li:"ul",dt:"dl",dd:"dl"},n={dd:{dl:1},dt:{dl:1},li:{ul:1,ol:1},option:{select:1},optgroup:{select:1}};return{scan:function(b,g,f){function i(g,c){for(j=g;j>c;j--){var d=l[j];l[j-1].appendChild(d);a(d,f)}b=l[c];l.length=c}function d(a){var b=0,g;if(g=n[a.tagName]){for(var c=l.length-1,d=l[c];d&&!(d.tagName in g);){if(d.tagName==a.tagName){b=1;break}c--;d=l[c]}b&&i(l.length-1,c-1)}return b}var c,j,l;l=f.stack=f.stack||[];do{if(c=g.nextNode())if(1===c.nodeType)if(c.isEndTag()&&c.tagName==
b.tagName)c=null;else if(c.isEndTag()){if(c.isEndTag()){var p=-1;for(j=l.length-1;0<=j;j--)if(l[j].tagName===c.tagName){p=j;break}-1!=p&&(l[l.length-1].appendChild(b),a(b,f),i(l.length-1,p),c=null)}}else e[c.tagName]?(e[c.tagName].scan(c,g,f),b.appendChild(c)):c.isSelfClosed?b.appendChild(c):(l.push(b),d(c)&&l.push(b),b=c);else b.appendChild(c);null==c&&0<l.length&&(c=l[l.length-1],e[c.tagName]?c=null:(l.length-=1,c.appendChild(b),a(b,f),b=c))}while(c);a(b,f)}}},{requires:["../dtd","../nodes/Tag",
"./SpecialScanners"]});KISSY.add("htmlparser/scanners/TextareaScanner",function(b,j,i){return i.textarea={scan:function(b,a,g){g=g||{};j.scan(b,a,g)}}},{requires:["./CdataScanner","./SpecialScanners"]});
KISSY.add("htmlparser/writer/basic",function(){function b(){this.output=[]}b.prototype={append:function(){for(var b=this.output,i=arguments,e,a=0;a<i.length;a++)if(e=i[a],1<e.length)for(var g=0;g<e.length;g++)b.push(e.charAt(g));else b.push(e);return this},openTag:function(b){this.append("<",b.tagName)},openTagClose:function(b){b.isSelfClosed&&this.append(" ","/");this.append(">")},closeTag:function(b){this.append("</",b.tagName,">")},attribute:function(b){this.append(" ",b.name,'="',(""+(b.value||
b.name)).replace(/"/g,"&quote;"),'"')},text:function(b){this.append(b)},cdata:function(b){this.append(b)},comment:function(b){this.append("<\!--"+b+"--\>")},getHtml:function(){return this.output.join("")}};return b});
KISSY.add("htmlparser/writer/beautify",function(b,j,i,e){function a(){a.superclass.constructor.apply(this,arguments);this.inPre=0;this.indentChar="\t";this.allowIndent=this.indentLevel=0;this.rules={};for(var g in b.merge(i.$nonBodyContent,i.$block,i.$listItem,i.$tableContent,{select:1,script:1,style:1}))this.setRules(g,{allowIndent:1,breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:1,breakAfterClose:1});this.setRules("option",{breakBeforeOpen:1});this.setRules("optiongroup",{breakBeforeOpen:1});
this.setRules("br",{breakAfterOpen:1});this.setRules("title",{allowIndent:0,breakBeforeClose:0,breakAfterOpen:0});this.setRules("pre",{allowIndent:0})}b.extend(a,j,{indentation:function(){this.inPre||this.append(Array(this.indentLevel+1).join(this.indentChar));this.allowIndent=0},lineBreak:function(){var a=this.output;if(!this.inPre&&a.length){for(var b=a.length-1;0<=b&&/[\r\n\t ]/.test(a[b]);b--);a.length=b+1;this.append("\n")}this.allowIndent=1},setRules:function(a,e){this.rules[a]||(this.rules[a]=
{});b.mix(this.rules[a],e)},openTag:function(b){var e=this.rules[b.tagName]||{};this.allowIndent?this.indentation():e.breakBeforeOpen&&(this.lineBreak(),this.indentation());a.superclass.openTag.apply(this,arguments)},openTagClose:function(a){var b=a.tagName,e=this.rules[b]||{};a.isSelfClosed?this.append(" />"):(this.append(">"),e.allowIndent&&this.indentLevel++);e.breakAfterOpen&&this.lineBreak();"pre"===b&&(this.inPre=1)},closeTag:function(b){var e=b.tagName,i=this.rules[e]||{};i.allowIndent&&this.indentLevel--;
this.allowIndent?this.indentation():i.breakBeforeClose&&(this.lineBreak(),this.indentation());a.superclass.closeTag.apply(this,arguments);"pre"===e&&(this.inPre=0);i.breakAfterClose&&this.lineBreak()},text:function(a){this.allowIndent&&this.indentation();this.inPre||(a=e.collapseWhitespace(a));this.append(a)},comment:function(a){this.allowIndent&&this.indentation();this.append("<\!--"+a+"--\>")},cdata:function(a){this.allowIndent&&this.indentation();this.append(b.trim(a))}});return a},{requires:["./basic",
"../dtd","../Utils"]});
KISSY.add("htmlparser/writer/filter",function(b){function j(){this.tagNames=[];this.attributeNames=[];this.tags=[];this.comment=[];this.text=[];this.cdata=[];this.attributes=[];this.root=[]}function i(a,g){for(var e=0;a&&e<a.length;e++)b.each(a[e].value,function(a){g=g.replace(a[0],a[1])});return g}function e(a,b,e,i){for(var h=0;a&&h<a.length;h++){var k;if(!1===(k=a[h].value.apply(null,b)))return!1;if(i&&k&&k!=i)return this.onNode(k)}return e}j.prototype={addRules:function(a,b){var b=b||10,e;for(e in a)if(a.hasOwnProperty(e)){var i=
this[e];if(i){var h;a:{for(h=0;i&&h<i.length;h++)if(i[h].priority>b)break a;h=i.length}i.splice(h,0,{value:a[e],priority:b})}}},onTagName:function(a){return i(this.tagNames,a)},onAttributeName:function(a){return i(this.attributeNames,a)},onText:function(a){return e.call(this,this.text,[a.toHtml(),a],a,a)},onCData:function(a){return e.call(this,this.cdata,[a.toHtml(),a],a,a)},onAttribute:function(a,b){var e;a:{e=this.attributes;for(var i=0;e&&i<e.length;i++){var h=e[i].value,k,f=a.name;if(h[f]&&!1===
(k=h[f].call(null,a.value,b))){e=k;break a}"string"==typeof k&&(a.value=k)}e=a}return e},onComment:function(a){return e.call(this,this.comment,[a.toHtml(),a],a,a)},onNode:function(a){var b=a.nodeType;if(1===b)return this.onTag(a);if(3===b)return this.onText(a);if(8===b)return this.onComment(a)},onFragment:function(a){return e.call(this,this.root,[a],a,a)},onTag:function(a){for(var b=["^",a.tagName,"$"],e=this.tags,i,h=0;h<b.length;h++)for(var k=b[h],f=0;f<e.length;f++)if(i=e[f].value,i[k]){if(!1===
(i=i[k](a)))return!1;if(i&&i!=a)return this.onNode(i);if(!a.tagName)return a}return a}};return j});
KISSY.add("htmlparser/writer/minify",function(b,j,i){function e(a){return(""+a).replace(/"/g,"&quote;")}function a(a,b){var e=a.nodeName,d=b.name,c=b.value||"";/^on[a-z]+/.test(d)?c=l(c).replace(/^javascript:[\s\xa0]*/i,"").replace(/[\s\xa0]*;$/,""):"class"===d?c=n(l(c)):/^(?:a|area|link|base)$/.test(e)&&"href"===d||"img"===e&&/^(?:src|longdesc|usemap)$/.test(d)||"object"===e&&/^(?:classid|codebase|data|usemap)$/.test(d)||"q"===e&&"cite"===d||"blockquote"===e&&"cite"===d||("ins"===e||"del"===e)&&
"cite"===d||"form"===e&&"action"===d||"input"===e&&("src"===d||"usemap"===d)||"head"===e&&"profile"===d||"script"===e&&("src"===d||"for"===d)||/^(?:a|area|object|button)$/.test(e)&&"tabindex"===d||"input"===e&&("maxlength"===d||"tabindex"===d)||"select"===e&&("size"===d||"tabindex"===d)||"textarea"===e&&/^(?:rows|cols|tabindex)$/.test(d)||"colgroup"===e&&"span"===d||"col"===e&&"span"===d||("th"===e||"td"==e)&&("rowspan"===d||"colspan"===d)?c=l(c):"style"===d&&(c=l(c).replace(/[\s\xa0]*;[\s\xa0]*$/,
""));return c}function g(){g.superclass.constructor.apply(this,arguments);this.inPre=0}var l=b.trim,n=i.collapseWhitespace,h=RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");b.extend(g,j,{comment:function(a){/\[if[^\]]+\]/.test(a)&&(a=a.replace(/^(\[[^\]]+\]>)[\s\xa0]*/,"$1").replace(/[\s\xa0]*(<!\[endif\])$/,"$1"),g.superclass.comment.call(this,a))},openTag:function(a){"pre"==a.tagName&&(this.inPre=1);g.superclass.openTag.apply(this,
arguments)},closeTag:function(a){"pre"==a.tagName&&(this.inPre=0);g.superclass.closeTag.apply(this,arguments)},cdata:function(a){a=l(a).replace(/^(?:[\s\xa0]*\/\*[\s\xa0]*<!\[CDATA\[[\s\xa0]*\*\/|[\s\xa0]*\/\/[\s\xa0]*<!\[CDATA\[.*)/,"").replace(/(?:\/\*[\s\xa0]*\]\]>[\s\xa0]*\*\/|\/\/[\s\xa0]*\]\]>)[\s\xa0]*$/,"");g.superclass.cdata.call(this,a)},attribute:function(b,f){var g=b.name,d=b.value||"",c;c=b.name;if(c=!(!l(b.value||"")&&("input"===f&&"value"===c||h.test(c)))){c=f.nodeName;var i=b.name,
j=b.value||"",j=l(j.toLowerCase());c=!("script"===c&&"language"===i&&"javascript"===j||"form"===c&&"method"===i&&"get"===j||"input"===c&&"type"===i&&"text"===j||"script"===c&&"type"===i&&"text/javascript"===j||"style"===c&&"type"===i&&"text/css"===j||"area"===c&&"shape"===i&&"rect"===j)}c&&(/^(?:checked|disabled|selected|readonly|defer|multiple|nohref|noshape|nowrap|noresize|compact|ismap)$/i.test(g)?this.append(" ",g):!/[ "'=<>`]/.test(d)?this.append(" ",g,"=",e(a(f,b))):this.append(" ",g,'="',e(a(f,
b)),'"'))},text:function(a){this.inPre||this.append(n(a))}});return g},{requires:["./basic","../Utils"]});
