show_comment_box	= function(id) { show_box('comment_box'); setTimeout(function() { get_comments(id) }, 500); }
close_comment_box 	= function() { close_box('comment_box'); }
comment_msg 		= function(msg) { show_msg(msg, 'comment_msg'); }

function get_comments(id) {
	f = function(o) {		
		xmlDoc = create_xml_doc(o.responseText);		

		comments = xmlDoc.getElementsByTagName('comment');		
		if(!comments.length)
			$('comment_list').innerHTML = '<strong>There are no comments for this vendor!</strong>';
		else {
			for(x = 0; x < comments.length; x++) {			
				div = $(document.createElement('div'));
				div.addClassName('comment_item');
				$('comment_list').appendChild(div);		

				text 	= getText(comments[x], 'text');
				title	= getText(comments[x], 'title');
				posted	= getText(comments[x], 'posted');
				by		= getText(comments[x], 'by');
				
				text_box 				= $(document.createElement('div'));			
				text_box.innerHTML 		= text;
				
				title_box 				= $(document.createElement('div'));				
				title_box.innerHTML	 	= title;
				
				posted_box 				= $(document.createElement('div'));				
				posted_box.innerHTML 	= posted;
				
				by_box 					= $(document.createElement('div'));				
				by_box.innerHTML 		= 'Posted By ' + by;
				
				title_box.addClassName('title');
				posted_box.addClassName('posted');
				by_box.addClassName('by');
				
				div.appendChild(title_box);				
				div.appendChild(text_box);
				div.appendChild(posted_box);
				div.appendChild(by_box);
				
			}
		}
		
		setTimeout(function() { loading_div.hide(); }, loader_wait * 1000);
	}	
	
	$('comment_list').innerHTML = '';
	
	loading_div = loader('Loading Comments', 'comment_list');	
	
	new Ajax.Request(comment_file, { postBody: 'id=' + id + '&j=' + ut(), method: 'post', onSuccess: f } ); 		
}

function submit_comment(frm) {	
	f = function(o) {		
		xmlDoc 		= create_xml_doc(o.responseText);
		msg 		= getText(xmlDoc, 'msg');		
		success 	= getText(xmlDoc, 'success');
		
		comment_msg(msg);
		
		if(success == "1") get_comments(frm.elements['id'].value);
	}
	
	new Ajax.Request(comment_file, { postBody: $(frm).serialize() + '&j=' + ut(), method: 'post', onSuccess: f } ); 		
}