var $p,pure;$p=pure={find:function(){this.msg("library_needed")},getRuntime:function(){var c=["var $p, pure;$p = pure = {","$outAtt:",this.$outAtt.toString(),",","$c:",this.$c.toString(),",","render:",this.render.toString(),",","compiledFunctions:[], msg:"+this.msg.toString()+"};"];for(var b in this.compiledFunctions){if(this.compiledFunctions.hasOwnProperty(b)){var a="$p.compiledFunctions['"+b+"']";c.push(a+"={};"+a+".compiled=");c.push(this.compiledFunctions[b].compiled.toString()+";");for(var e in this.compiledFunctions[b]){if(e!="compiled"){c.push("$p.compiledFunctions['"+b+"']."+e+"="+this.compiledFunctions[b][e].toString()+";")}}}}var d=document.getElementById("pureMsg");if(d){d.value=c.join("");d.select()}else{this.msg("place_runtime_container")}},$f:{cnt:0},$c:function(d,f,a){if(f=="context"){return d}if(typeof d=="object"){var c=f.split(/\./);var e=d[c[0]];for(var b=1;b<c.length;b++){if(!e){break}e=e[c[b]]}}if(!e&&e!=0){e=a?null:""}return e},render:function(){var d,c,b,e=arguments[2];if(typeof arguments[1]==="string"){c=arguments[1];b=arguments[0]}else{c=arguments[0];b=arguments[1]}if(typeof c!="string"){var a=e?this.map(e,c):c.cloneNode(true);d=this.compiledFunctions.length||0;this.compile(a,d,b,false)}else{d=c}if(this.compiledFunctions[d]){return this.compiledFunctions[d].compiled(b)}else{this.msg("HTML_does_not_exist",d)}},autoRender:function(b,a,c){if(typeof b!="string"){if(!b){this.msg("wrong_html_source");return false}b.setAttribute(this.utils.AUTO,"true")}return this.render(b,a,c)},compiledFunctions:{},$outAtt:function(b){var a=b.join("");return(/\=\"\"/.test(a))?"":a},utils:{CLASSNAME:/MSIE\s+(6|7)/.test(navigator.userAgent)?"className":"class",NS:/MSIE/.test(navigator.userAgent)?"pure_":"pure:",PURECLASS:/MSIE/.test(navigator.userAgent)?"pure_class":"pure:class",AUTO:/MSIE/.test(navigator.userAgent)?"pure_autoRender":"pure:autoRender",REPEAT:/MSIE/.test(navigator.userAgent)?"pure_repeat":"pure:repeat",NODEVALUE:/MSIE/.test(navigator.userAgent)?"pure_nodeValue":"pure:nodeValue",nodeValues:[],repeats:[],autoRenderAtts:[],isTypeOfArray:function(a){return typeof a.length==="number"&&!(a.propertyIsEnumerable("length"))&&typeof a.splice==="function"},autoMap:function(e,b,d,q){var c,h,l,m,f,a,p,i;if(b=="true"){p=e.getAttribute(this.CLASSNAME);if(p){c=p.replace(/^\d|\s\d/g,"").split(/\s+/);for(l=0;l<c.length;l++){f="";i=this.ap_check(c[l]);m=i.clean.split(/@/);if(q.length>0){for(h=q.length-1;h>=0;h--){a=q[h]=="context"?d[0][m[0]]:$p.$c(d[q[h]][0],m[0],true);if(a||a==0){f=q[h];break}}}if(!a){a=m[0]!="context"?$p.$c(d,m[0],true):!(/context/).test(q.join(""))?d:true}if(a||a==0){if(typeof a.length==="number"&&!(a.propertyIsEnumerable("length"))&&typeof a.splice==="function"){q.push(m[0]);e.setAttribute(this.REPEAT,m[0]+"<-"+m[0])}else{if(f!==""){m[0]=f+"['"+m[0]+"']"}if(!m[1]){m.push("nodeValue")}if(i.type){m[0]=this.ap_format(m[0],m[1],e,i.type)}if(m[1]!="nodeValue"){this.removeAtt(e,m[1])}if(!e.getAttribute(this.NS+m[1])){e.setAttribute(this.NS+m[1],m[0])}}}}if(e.getAttribute(this.PURECLASS)&&e.getAttribute(this.CLASSNAME)){e.removeAttribute(this.CLASSNAME)}}}var g=e.getAttribute(this.NODEVALUE);if(g){this.nodeValues.push(e)}var o=e.getAttribute(this.REPEAT);if(o){this.repeats.push(e)}},nodeWalk:function(p,b){var g=this.AUTO;this.repeats=[];this.nodeValues=[];var d=p.getAttribute(g);p.removeAttribute(g);var t=[];var u=p,m=null;do{if(u.nodeType==1){this.autoMap(u,d,b,t)}m=u.firstChild;if(m===null){m=u.nextSibling}var v=u;if(m===null){v=u;do{m=v.parentNode?v.parentNode:p;if(m==p){break}v=m;m=m.nextSibling}while(m===null)}u=m}while(u!=p);var f,w,a,k,o=false;for(var q=this.nodeValues.length-1;q>=0;q--){try{m=this.nodeValues[q];k=m.getAttribute(this.NODEVALUE);if(k){var l=k.match(/\|(a|p)\|/);if(l){if(l[1]=="a"){m.innerHTML+=this.NODEVALUE+'="'+k.substring(l.index+3)+'"'}else{m.innerHTML=this.NODEVALUE+'="'+k.substring(l.index+3)+'"'+m.innerHTML}}else{m.innerHTML=this.NODEVALUE+'="'+k+'"'}m.removeAttribute(this.NODEVALUE)}}catch(s){}}for(var r=this.repeats.length-1;r>=0;r--){m=this.repeats[r];try{a=m.getAttribute(this.REPEAT);if(a){f=m.cloneNode(true);f.removeAttribute(this.REPEAT);w=document.createElement(this.REPEAT);w.appendChild(f);w.setAttribute("source",""+a);if(p==m){o=this.outerHTML(w)}else{m.parentNode.replaceChild(w,m)}}}catch(h){}}return(o)?o:false},ap_format:function(d,f,e,c){if(c){if(!f){f="nodeValue"}var a=f=="class"?this.CLASSNAME:f;var b=e.getAttribute(a)||("nodeValue"==f?"nodeValue":null);if(b){return b+"|"+c+"|"+d}}return d},ap_check:function(c){var b,a;c=(b=/^\+/.test(c))?c.slice(1):(a=/\+$/.test(c))?c.slice(0,-1):c;return{type:(a)?"a":(b)?"p":false,clean:c}},removeAtt:function(b,a){if(a=="class"){a=this.CLASSNAME}try{b[a]="";b.removeAttribute(a)}catch(c){}},out:function(a){return["output.push(",a,");"].join("")},strOut:function(a){return["output.push(","'",a,"');"].join("")},outputFn:function(a,b){if(b){return a+"({context:context, items:"+b+",pos:"+b+"Index=='0'?0:parseInt("+b+"Index)||"+b+"Index, item:"+b+"["+b+"Index=='0'?0:parseInt("+b+"Index)||"+b+"Index]})"}else{return a+"({context:context})"}},contextOut:function(a){return"$p.$c(context, "+a+")"},isArray:function(b,c){var d=/\[[^\]]*\]/.test(b);var a=b.replace(/(")|(')/g,"").split(/\./);return d||c[a[0]]?true:false},arrayName:function(a){var c=a.match(/\w*/)[0]||"";var b=a.substring(c.length).replace(/\[\s*\]/,"");if(/\./.test(b)){b=b.replace(/^\./,"['").replace(/\./g,"']['")+"']"}return c+"["+c+"Index]"+b.replace(/\\\'/g,"'")},domCleaningRules:[{what:window?new RegExp(window.location.toString().substring(0,window.location.toString().indexOf(window.location.pathname)),"g"):"",by:""},{what:/\>\s+</g,by:"> <"},{what:/\r|\n/g,by:""},{what:/\\\'|\'/g,by:"\\'"},{what:/\svalue=\"\"/ig,by:""},{what:/^\s+/,by:""}],outerHTML:function(a){return a.outerHTML||(function(c){var b=document.createElement("div");b.appendChild(c);return b.innerHTML})(a)},html2str:function(c,b){var f=c[0]&&!c.nodeType?c[0].cloneNode(true):c.cloneNode(true);var e=this.nodeWalk(f,b);if(!e){e=this.outerHTML(f)}e=e.replace(new RegExp("</?:?"+this.REPEAT,"gi"),this.REPEAT);var d=this.domCleaningRules;for(var a=0;a<d.length;a++){e=e.replace(d[a].what||"",d[a].by)}return e.split(this.NS)}},autoCompile:function(b,c,a,d){b.setAttribute(this.utils.AUTO,"true");return this.compile(b,c,a,d)},compile:function(m,f,d,g){var l=this.utils.html2str(m,d);if(!f&&typeof f!="number"){this.msg("no_HTML_name_set_for_parsing",l.join(""),m);return false}var v,G,i=false,r,t=[],z=1,p="",C,y,u,c,k,o,B,F,H,h,D="",b="",s=[],A,n;this.compiledFunctions[f]={};var a=["{var output = [];"];if(l[0]!==""){a.push(this.utils.strOut(l[0]))}for(var x=1;x<l.length;x++){G=l[x];if(/^repeat[^\>]*\>/i.test(G)){i=G.match(/^repeat[^\>]*>/i);r=i[0].match(/"[^"]*"/);if(r){r=r[0].replace(/&lt;/,"<").replace(/"/g,"").replace(/\s/g,"");p=r.split(/<-/);k=p[0];A=p[1]||"";if(this.utils.isArray(A,t)){a.push("var "+k+"="+this.utils.arrayName(A)+";")}else{if(/context/i.test(A)||A.length==0){if(!(/context/i).test(k)){a.push("var "+k+"= context;")}}else{a.push("var "+k+'= $p.$c(context, "'+A+'");')}}a.push("for(var "+k+"Index in "+k+"){if ("+k+".hasOwnProperty("+k+"Index)){");a.push(this.utils.strOut(G.substring(i[0].length)));t[k]=z++}else{a.push("}}");delete t[k];B=0;for(H in t){if(t.hasOwnProperty(H)){F=t[H];if(F>B){B=F;k=H}}}a.push(this.utils.strOut(G.substring(i[0].length,G.length)))}i=false;continue}else{D=G.substring(0,G.indexOf("="));b=G.match(/\=""?[^"]*""?/)[0].substr(2).replace(/"$/,"");h=D.length+b.length+3;if(/&quot;/.test(b)){b=b.replace(/&quot;/g,'"');G=G.replace(/&quot;/,'"').replace(/&quot;/,'"')}o=/^nodeValue/i.test(G);n=o?[]:["'"+D+"=\"'"];y=b.match(/\|(a|p)\|/);c="";u=o?"":" ";if(y){if(y[1]=="a"){n.push("'"+b.substring(0,y.index)+u+"'")}else{c=b.substring(0,y.index)}b=b.substring(y.index+3)}if(/\$f\[(f[0-9]+)\]/.test(b)){C=b.match(/\[(f[0-9]+)/)[1];this.compiledFunctions[f]["$"+C]=this.$f[C];delete this.$f[C];this.$f.cnt--;n.push(this.utils.outputFn("this.$"+C,k));if(c!==""){n.push("'"+u+c+"'")}}else{if(/^\\\'|&quot;/.test(b)){n.push("'"+b.replace(/^\\\'|\\\'$/g,"")+"'");if(c!==""){n.push("'"+u+c+"'")}}else{if(!(/MSIE/).test(navigator.userAgent)){s=b.split(/(#\{[^\}]*\})/g)}else{var q=b.match(/#\{[^\}]*\}/);s=q?[]:[b];while(q){if(q.index>0){s.push(b.substring(0,q.index))}s.push(q[0]);b=b.substring(q.lastIndex);q=b.match(/#\{[^\}]*\}/);if(!q&&b!==""){s.push(b)}}}for(var w=0;w<s.length;w++){b=s[w];if(/\#\{/.test(b)||s.length==1){b=b.replace(/^\#\{/,"").replace(/\}$/,"");if(this.utils.isArray(b,t)){n.push(this.utils.arrayName(b))}else{n.push(this.utils.contextOut("'"+b+"'"))}}else{if(b!==""){n.push("'"+b+"'")}}if(c!==""){n.push("'"+u+c+"'")}}}}if(!o){n.push("'\"'")}}a.push(this.utils.out(n.length>1?"$p.$outAtt(["+n.join(",")+"])":n[0]));G=G.substr(h);if(G!==""){a.push(this.utils.strOut(G))}}a.push('return output.join("");}');v=a.join("");if(!g){try{this.compiledFunctions[f].compiled=new Function("context",v)}catch(E){this.msg("parsing_error",[E.message,v]);return false}}return v},map:function(h,m,b){if(!m[0]&&m.length==0){this.msg("no_HTML_selected");return false}var o,k=[],c,q,j,d,p,n,r,g,f,l,a,e=[];if(b){q=m[0]&&!m.nodeType?m[0]:m}else{q=m[0]&&!m.nodeType?m[0].cloneNode(true):m.cloneNode(true)}a=q.getAttribute(this.utils.AUTO)||false;for(f in h){if(h.hasOwnProperty(f)){c=h[f];if(this.utils.isTypeOfArray(c)){k=c}else{k=[];k.push(c)}for(l=0;l<k.length;l++){c=k[l];j=this.utils.ap_check(f);f=j.clean;d=f.match(/\[[^\]]*\]/);if(/^\[|^\.$/.test(f)){p=q}else{p=this.find(f,q);if(!p&&d){p=this.find(f.substr(0,d.index),q)}}if(p){if(typeof c=="function"){o="f"+this.$f.cnt++;this.$f[o]=c;c="$f["+o+"]"}n="nodeValue";r=-1;if(d){n=f.substring(d.index+1,d[0].length+d.index-1);if(n.indexOf(this.utils.NS)>-1){n=n.substring(this.utils.NS.length)}}else{r=c.search(/w*<-w*/);if(r>-1){n="repeat"}}c=c.replace(/^"|"$|\'|\\\'/g,"\\'");c=this.utils.ap_format(c,n,p,j.type);p.setAttribute(this.utils.NS+n,c);if(d){if(n!="class"){this.utils.removeAtt(p,n)}else{if(a!="true"){e.push(p)}}}}else{g=[q.nodeName];if(q.id!==""){g.push("#"+q.id)}if(q.className!==""){g.push("#"+q.className)}this.msg("element_to_map_not_found",[f,g.join("")],q)}}}}if(e.length>0){for(l=0;l<e.length;l++){this.utils.removeAtt(e[l],"class")}}return q},messages:{wrong_html_source:"The source HTML provided to autoRender does not exist. Check your selector syntax.",element_to_map_not_found:'PURE - Cannot find the element "&" in "&"',place_runtime_container:'To collect the PURE runtime, place a <textarea id="pureMsg"></textarea> somewhere in your document.',no_HTML_selected:"The map function didn't receive a valid HTML element",no_HTML_name_set_for_parsing:"A name is needed when parsing the HTML: &",HTML_does_not_exist:"The HTML: & does not exist or is not yet compiled",library_needed:"In order to run PURE, you need a JS library such as: dojo, domAssistant, jQuery, mootools, prototype,...",parsing_error:'Parsing error: "&" in: &'},msg:function(e,d,a){var f=this.messages[e]||e;var c=/&/,b;if(f!=e&&d){if(typeof d=="string"){f=f.replace(c,d)}else{for(b=0;b<d.length;b++){f=f.replace(c,d[b])}}}var g=document.getElementById("pureMsg");if(g){g.innerHTML=[f,"\n",g.innerHTML].join("")}else{alert(f)}},libs:{mapDirective:function(b,a){return $p.map(a,b)},compile:function(e,c,d,b){var a=e;if(d){a=$p.map(d,e)}if(b){a.setAttribute($p.utils.AUTO,"true")}return $p.compile(a,c,b||false,false)},render:function(f,b,d,a,e){var c=f;if(typeof a!=="undefined"){c=typeof a!=="string"&&a[0]||a}else{if(typeof d!=="undefined"&&(d.jquery||d.cssSelect||d.nodeType||typeof d==="string")){c=(d.jquery||d.cssSelect)?d[0]:d;d=null}}return this.replaceWithAndReturnNew(f,e===true?$p.autoRender(c,b,d):$p.render(c,b,d))},replaceWithAndReturnNew:function(h,b){var g=document.createElement("div");var d=h;var c=d.parentNode;c.insertBefore(g,d);g.innerHTML=b;var f=g.childNodes;var e=[];for(var a=f.length-1;a>=0;a--){e.push(d.parentNode.insertBefore(f[a],d.nextSibling))}c.removeChild(d);c.removeChild(g);return e.length>1?e:e[0]}}};if(typeof jQuery!=="undefined"&&$==jQuery){if(jQuery.parse){jQuery.parse[0]=/^(\[) *@?([\w:\-]+) *([!*$\^~=]*) *('?"?)(.*?)\4 *\]/}$p.utils.domCleaningRules.push({what:/\s?jQuery[^\s]+\=\"null\"/gi,by:""});$p.find=function(a,b){var c=jQuery.find(a,b);return c[0]||false};jQuery.fn.mapDirective=function(a){return jQuery($p.libs.mapDirective(this[0],a))};jQuery.fn.compile=function(b,c,a){$p.libs.compile(this[0],b,c,a);return this};jQuery.fn.render=function(b,c,a){return jQuery($p.libs.render(this[0],b,c,a))};jQuery.fn.autoRender=function(b,c,a){return jQuery($p.libs.render(this[0],b,c,a,true))}}else{if(typeof DOMAssistant!=="undefined"){$p.find=function(a,b){var c=$(b).cssSelect(a);return c[0]||false};DOMAssistant.attach({publicMethods:["mapDirective","compile","render","autoRender"],mapDirective:function(a){return $($p.libs.mapDirective(this,a))},compile:function(b,c,a){$p.libs.compile(this,b,c,a);return this},render:function(b,c,a){return $($p.libs.render(this,b,c,a))},autoRender:function(b,c,a){return $($p.libs.render(this,b,c,a,true))}})}else{if(typeof MooTools!=="undefined"){$p.find=function(a,b){var c=$(b).getElement(a);return c||false};Element.implement({mapDirective:function(a){return $($p.libs.mapDirective(this,a))},compile:function(b,c,a){$p.libs.compile(this,b,c,a);return this},render:function(b,c,a){return $($p.libs.render(this,b,c,a))},autoRender:function(b,c,a){return $($p.libs.render(this,b,c,a,true))}})}else{if(typeof Prototype!=="undefined"){$p.find=function(a,d){var f=$(d).select(a);if(!f||f===""){var h=a.indexOf("#");if(h>-1){var g=a.substr(h+1);var c=d.getElementsByTagName("*");for(var b=0,e;e=c[b];b++){if(e.id==g){return e}}}}return f[0]||false};Element.addMethods({mapDirective:function(a,b){return $($p.libs.mapDirective(a,b))},compile:function(b,c,d,a){$p.libs.compile(b,c,d,a);return this},render:function(c,b,d,a){return $($p.libs.render(c,b,d,a))},autoRender:function(c,b,d,a){return $($p.libs.render(c,b,d,a,true))}})}else{if(typeof Sizzle!=="undefined"){$p.find=function(a,b){var c=Sizzle(a,b);return c[0]||false};$p.sizzle=function(a,c){a=a||document;var b=a.nodeType?[a]:Sizzle(a,c);var d=b;d.mapDirective=function(e){d[0]=$p.libs.mapDirective(d[0],e);return d};d.compile=function(f,g,e){$p.libs.compile(d[0],f,g,e);return d};d.render=function(f,g,e){d[0]=$p.libs.render(d[0],f,g,e);return d};d.autoRender=function(f,g,e){d[0]=$p.libs.render(d[0],f,g,e,true);return d};return d}}}}}};