/**
 * Utility Class Contains set of tools that can be used for gallery.
 *
 * @author: Mulky Sulaiman (mulky.sulaiman@integrasi.com | mulky_sulaiman@yahoo.com)
 */

function toolsGallery(){
	this.baseUrl 		= _http_host + 'gallery/xhr_request.html';
	this.container	= 'comment_';
	this.comCont		= 'comment_content_';
	
	this._extractId = function(callerDOM){
		return callerDOM.id.substring(callerDOM.id.lastIndexOf('_')).replace(/\_/, '');
	}
	
	this.editComment = function(callerDOM){
		if (akedit.length > 0){
			var id		= this._extractId(callerDOM);
			var url		= this.baseUrl + '?act=edit_comment&id=' + id;
			
			akedit(url, this.comCont + id, {
				type: 'textarea',
				name: 'edit_comment',
				id: id,
				submit: 'Kirim',
				cancel: 'Batal'
			});
		}
	}
	
	this.deleteComment = function(callerDOM){
		var id 	= this._extractId(callerDOM);
		var url	= this.baseUrl + '?act=delete_comment&id=' + id;
		var container = $('#' + this.container + id);
		$('#' + this.comCont + id).get(0).style.background = '#f7f7f7';
		
		$.get(url, function(data){
			if (data == 'true')
				container.toggle('blind', { direction: 'vertical' }, 500);
		});
	}
}