// HELPERS
	
	// No cache for AJAX
	var noCache = function(uri) {
		return uri.concat(/\?/.test(uri) ? "&" : "?", "noCache=", (new Date).getTime(), ".", Math.random() * 1234567);
	};
	
	// Create XML request
	var createXMLHttpRequest = function() {
	    var ua;
	    if(window.XMLHttpRequest) {
	    	try { ua = new XMLHttpRequest(); } catch(e) { ua = false; }
	    } else if(window.ActiveXObject) {
	    	try { ua = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { ua = false; }
	    }
	    return ua;
	};

	// PHP date() for JavaScript
	eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([59pqvxCEJKQRVX]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('p 17=9(j,h){p m,c=((18(h)==\'undefined\')?x E():(18(h)==\'number\')?x E(h*J):x E(h));p f=9(a,d){q((a=a+"").R<d){5 x Array(++d-a.R).join("0")+a}C{5 a}};p k=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];p i={1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};p l=["","January","February","March","April","May","June","July","August","September","October","November","December"];p b={d:9(){5 f(b.j(),2)},D:9(){p a=b.l();5 a.V(0,3)},j:9(){5 c.getDate()},l:9(){5 k[b.w()]},N:9(){5 b.w()+1},S:9(){5 i[b.j()]?i[b.j()]:\'th\'},w:9(){5 c.16()},z:9(){5(c-x E(c.v()+"/1/1"))/864e5>>0},W:9(){p a=b.z(),d=364+b.L()-a;p e,g=(x E(c.v()+"/1/1").16()||7)-1;q(d<=2&&((c.16()||7)-1)<=2-d){5 1}C{q(a<=2&&g>=4&&a>=(6-g)){e=x E(c.v()-1+"/12/31");5 17("W",X.1b(e.1c()/J))}C{5(1+(g<=3?((a+g)/7):(a-(7-g))/7)>>0)}}},F:9(){5 l[b.n()]},m:9(){5 f(b.n(),2)},M:9(){t=b.F();5 t.V(0,3)},n:9(){5 c.1d()+1},t:9(){p a;q((a=c.1d()+1)==2){5 28+b.L()}C{q(a&1&&a<8||!(a&1)&&a>7){5 31}C{5 30}}},L:9(){p a=b.Y();5(!(a&3)&&(a%1e2||!(a%4e2)))?1:0},o:9(){q(b.n()===12&&b.W()===1){5 c.v()+1}q(b.n()===1&&b.W()>=52){5 c.v()-1}5 c.v()},Y:9(){5 c.v()},y:9(){5(c.v()+"").slice(2)},a:9(){5 c.K()>11?"pm":"am"},A:9(){5 b.a().toUpperCase()},B:9(){p a=(c.10()+Q)*Q;p d=(c.K()*3600)+(c.1e()*Q)+c.1f()+a;p e=X.floor(d/86.4);q(e>J)e-=J;q(e<0)e+=J;q((1g(e)).R==1)e="00"+e;q((1g(e)).R==2)e="0"+e;5 e},g:9(){5 c.K()%12||12},G:9(){5 c.K()},h:9(){5 f(b.g(),2)},H:9(){5 f(c.K(),2)},i:9(){5 f(c.1e(),2)},s:9(){5 f(c.1f(),2)},u:9(){5 f(c.getMilliseconds()*J,6)},I:9(){p a=(x E(c.v(),6,1,0,0,0));a=a.K()-a.1h();p d=c.K()-c.1h();5 d!=a?1:0},O:9(){p a=f(X.abs(c.10()/Q*100),4);q(c.10()>0)a="-"+a;C a="+"+a;5 a},P:9(){p a=b.O();5(a.V(0,3)+":"+a.V(3,2))},Z:9(){p a=-c.10()*Q;5 a},c:9(){5 b.Y()+"-"+b.m()+"-"+b.d()+"T"+b.h()+":"+b.i()+":"+b.s()+b.P()},r:9(){5 b.D()+\', \'+b.d()+\' \'+b.M()+\' \'+b.Y()+\' \'+b.H()+\':\'+b.i()+\':\'+b.s()+\' \'+b.O()},U:9(){5 X.1b(c.1c()/J)}};5 j.replace(/[\\\\]?([a-zA-Z])/g,9(a,d){q(a!=d){13=d}C q(b[d]){13=b[d]()}C{13=d}5 13})};',[],80,'|||||return||||function||||||||||||||||var|if|||||getFullYear||new|||||else||Date|||||1000|getHours||||||60|length||||substr||Math|||getTimezoneOffset|||ret|||getDay|date|typeof|||round|getTime|getMonth|getMinutes|getSeconds|String|getUTCHours'.split('|'),0,{}));
	
	//'
	// PHP htmlspecialchars_decode for JavaScript
	var htmlspecialcharsDecode = function(string, quote_style) {
		string = string.toString();
		string = string.replace(/&amp;/g, '&');
		string = string.replace(/&lt;/g, '<');
		string = string.replace(/&gt;/g, '>');
		
		if(quote_style == 'ENT_QUOTES') {
			string = string.replace(/&quot;/g, '"');
			string = string.replace(/&#039;/g, '\'');
		} else if(quote_style != 'ENT_NOQUOTES') {
			string = string.replace(/&quot;/g, '"');
		}
		
		return string;
	};

// ACTIONS

	// Load comments via AJAX
	var loadComments = function() {
		commentsContainer.innerHTML = '';
		
		if(commentsFormContainer) {
			commentsFormContainer.style.display = 'block';
			if(commentsFormContainer.getElementsByTagName('form')[0]) commentsFormContainer.getElementsByTagName('form')[0].action = top.location.href;
		}
		
		// Add anchor to back link
		if(document.getElementById('comments-back-link') && location.hash) document.getElementById('comments-back-link').onclick = function() { location.reload(true); return false; };
		
		// Send XML file path to form field
		if(document.getElementById('comments_xml_file')) document.getElementById('comments_xml_file').value = commentsXMLfile;
		
	   	// Get comments from XML file
		var XMLcontent = createXMLHttpRequest();
	   	XMLcontent.open('get', noCache(commentsXMLfile), true);
	   	
		XMLcontent.onreadystatechange = function() {
			if(XMLcontent.readyState == 4 && XMLcontent.status == 200) {
				if(XMLcontent.responseXML) {
					var fileNode = XMLcontent.responseXML.getElementsByTagName('file')[0];
					if(fileNode) var commentsNode = fileNode.getElementsByTagName('comments')[0];
					if(commentsNode) showComments(commentsNode);
				}
			}
		};
		
		XMLcontent.send(null);
		
		// Show comments
		var showComments = function(commentsNode) {
			commentsContainer.innerHTML = '';
			var commentNodes = commentsNode.getElementsByTagName('comment');
			
			for(var i = 0; i < commentNodes.length; i++) {
				var name, website = '', timestamp, text;
				
				var nameNode = commentNodes[i].getElementsByTagName('name')[0];
				var websiteNode = commentNodes[i].getElementsByTagName('website')[0];
				var timestampNode = commentNodes[i].getElementsByTagName('timestamp')[0];
				var textNode = commentNodes[i].getElementsByTagName('text')[0];

				if(nameNode.childNodes[0]) name = nameNode.childNodes[0].nodeValue;
				if(websiteNode.childNodes[0]) website = websiteNode.childNodes[0].nodeValue;
				if(timestampNode.childNodes[0]) timestamp = timestampNode.childNodes[0].nodeValue;
				if(textNode.childNodes[0]) text = textNode.childNodes[0].nodeValue;
	
				includeTemplate(i + 1, name, website, date(dateFormat, parseInt(timestamp)), text);
			}
		};
	};
	
	// Close comments
	var closeComments = function() {
		commentsContainer.innerHTML = '';
		if(commentsFormContainer) commentsFormContainer.style.display = 'none';
	};
    
// START
	
	if(typeof commentsXMLfile == 'undefined') var commentsXMLfile = ''; else loadComments();
