function comment_quote(c) {
	if (document.getElementById('comment_text').value.length) {
		document.getElementById('comment_text').value+="\n";
	}
	fq=new filter_quote_class(c);
	document.getElementById('comment_text').value+=fq.filter()+"\n";
	window.scroll(0,0);
}

function filter_quote_class(c) {
	this.c=c;
	this.filter = function() {
		if (this.c.hasChildNodes()) {
			if (this.c.id.substr(0,1)=='c') {
				this.comment_id=this.c.id.substr(8,this.c.id.length);
			}
			else if (this.c.id.substr(0,1)=='q') {
				this.comment_id=this.c.id.substr(6,this.c.id.length);
			}
			this.comment_str='[cytat komentarz="'+this.comment_id+'"]'+"\n";
				
			for (this.i=0;this.i<this.c.childNodes.length;this.i++) {
				
				if (this.c.childNodes[this.i].nodeName.toLowerCase()=='p' && this.c.childNodes[this.i].className!="quote_author") {	
					this.comment_str+=this.c.childNodes[this.i].innerHTML.trim();
				}
				
				if (this.c.childNodes[this.i].nodeName.toLowerCase()=='blockquote') {	
					
					this.fq=new filter_quote_class(this.c.childNodes[this.i]);
					this.comment_str+=this.fq.filter();
					
				}
			}
			this.comment_str+="\n"+'[/cytat]'+"\n";
			
			return this.comment_str.replace(/<br>/ig,"\n");
		}
		else {
			return '';
		}
	}
}
