/*
 * @require jade.js
 * @require jade/Schedular.js
 * @require jade/Dimension.js
 */
jade.HTMLUtils=function(){};
jade.HTMLUtils.hasClassName=function(a,b){var c,d,e;if(!a||!a.className)return!1;c=a.className.split(" ");for(d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1};
jade.HTMLUtils.getElementsByClassName=function(a,b,c){var d,e,f,h,i,g;if(c===void 0)c=-1;else if(c>=0&&(c--,c<0))return[];f=a.childNodes;i=[];for(d=0,e=f.length;d<e;d++)if(h=f[d])jade.HTMLUtils.hasClassName(h,b)&&i.push(h),g=jade.HTMLUtils.getElementsByClassName(h,b,c),g.length>0&&(i=i.concat(g));return i};
jade.HTMLUtils.getElementByClassName=function(a,b,c){var d;d=jade.HTMLUtils.getElementsByClassName(a,b,c);return d.length>0?d[0]:null};
jade.HTMLUtils.removeClassName=function(a,b){var c,d,e,f;if(!a)throw Error("element must be set");if(!a.className)return!1;c=a.className.split(" ");f=!1;for(d=0,e=c.length;d<e;d++)c[d]==b&&(c.splice(d,1),d--,f=!0);a.className=c.join(" ");return f};
jade.HTMLUtils.addClassName=function(a,b){if(!a)throw Error("element must be set");if(jade.HTMLUtils.hasClassName(a,b))return!1;a.className?a.className+=" "+b:a.className=b;return!0};
jade.HTMLUtils.replaceClassName=function(a,b,c){jade.HTMLUtils.removeClassName(a,b);jade.HTMLUtils.addClassName(a,c)};
jade.HTMLUtils.getParentByClassName=function(a,b){var c;if(typeof a.parentNode===void 0)return null;c=a;do if(c=c.parentNode,jade.HTMLUtils.hasClassName(c,b))return c;while(c.parentNode!==null);return null};
jade.HTMLUtils.getSiblingByTagName=function(a,b,c){c=c===void 0?"forward":c;for(a=c=="forward"?a.nextSibling:a.previousSibling;a!==null;){if(a.tagName==b.toUpperCase())return a;a=c=="forward"?a.nextSibling:a.previousSibling}return null};
jade.HTMLUtils.getClassNames=function(a){var b,c,d,e;c=[];if(!a||!a.className)return c;d=a.className.split(" ");for(b=0,e=d.length;b<e;b++)c.push(d[b]);return c};
jade.HTMLUtils.removeChildren=function(a){for(var b=a.childNodes.length-1;b>=0;b--)a.removeChild(a.childNodes[b])};
jade.HTMLUtils.autoSizeFileUpload=function(a,b){var c,d,e,f;if(a!==null){a.style.visibility="hidden";if(b!==null&&b.scrollWidth){e=b.scrollWidth;b.style.overflow="hidden";for(c=1,d=15;c<d;c++)if(a.size=c,f=b.scrollWidth,f>e){a.size=c>1?c-1:1;break}}a.style.visibility="visible"}};
jade.HTMLUtils.getDocumentOffset=function(a){var b,c;for(c=b=0;a!==null;)b+=a.offsetLeft?a.offsetLeft:0,c+=a.offsetTop?a.offsetTop:0,a=a.offsetParent;return{x:b,y:c}};
jade.HTMLUtils.changeCSS=function(a,b,c){var d,e,f,h,i,g,j;f=document.styleSheets;for(d=0,e=f.length;d<e;d++){g=f[d].cssRules||f[d].rules;for(h=0,i=g.length;h<i;h++)j=g[h],j.selectorText==a&&(j.style[b]=c)}};
jade.HTMLUtils.measureElement=function(a,b,c,d){var e,f,h,i;f=document.body;if(!f)return jade.Schedular.schedule(25,jade.HTMLUtils.measureElement,jade.Schedular,a,b,c,d),!1;h=document.createElement("div");i=h.style;i.position="absolute";i.overflow="visible";i.visibility="hidden";if(b)i.width=Math.max(0,b)+"px";e=a.cloneNode(!0);i=e.style;i.width="auto";i.height="auto";i.position="relative";h.appendChild(e);f.appendChild(h);c.call(d,e.offsetWidth,e.offsetHeight,a);f.removeChild(h);return!0};
jade.HTMLUtils.getElementSize=function(a,b){var c=0,d=0;return!jade.HTMLUtils.measureElement(a,b!=null?b:null,function(a,b){c=a;d=b},
window)?null:new jade.Dimension(c,d)};
jade.HTMLUtils.createElement=function(a){var b=document.createElement(a);b.ondragstart=function(){return!1};
b.onselectstart=function(){return!1};
return b};
