function toggle() {
	var q = this.parentNode.parentNode.firstChild;
	while(q && !q.nodeName.match(/blockquote/i)) {
		q = q.nextSibling;
	}
	if(!q) {
		return false;
	}
	if(q.className.match(/\bcollapsed\b/)) {
		q.className = q.className.replace(/\s*collapsed\b/, '');
		this.textContent = '[Collapse]';
	} else {
		q.className += ' collapsed';
		this.textContent = '[Expand]';
	}
	return false;
}

window.onload = function() {
	var qs = document.getElementsByTagName('blockquote');
	for(var i = 0; i < qs.length; ++i) {
		var q = qs[i];
		if(!q.className.match(/\bcompact\b/)) {
			continue;
		}
		var collapser = document.createElement('a');
		collapser.textContent = '[Expand]';
		collapser.title = 'Toggle the size of this quote in the page';
		collapser.onclick = toggle;
		collapser.href = '';
		collapser.className = 'quote_aedit';
		var parent = q.parentNode;
		var tgt = parent.firstChild;
		while(tgt && !tgt.nodeName.match(/div/i)) {
			tgt = tgt.nextSibling;
		}
		if(tgt) {
			tgt.appendChild(collapser);
		}
	}
}