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