/*****************************************************************************************************/
/*                                                                                                   */
/*                                   'COMMENTS UTILITY PANEL' CLASS                                  */          
/*                                                                                                   */
/*****************************************************************************************************/

function UTILITY_GINFO(parent){
	var JSObject = this;
	this.type = "Comment Utility"; 
	
	var container = "comment_utility_";
	this.comments = [];
	this.no_comments = 0;
	
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                         FUNCTION INIT                                             */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.init = function(no_comments){
		
		this.no_comments = no_comments;
		
		for (var i=0; i<this.no_comments; i++){
			var comment = new Object();
			
			comment.id = document.getElementById("commentId_"+(i+1)).value;
			comment.index = i;
			comment.container = document.getElementById(container+(i+1));
			
			for (var j=0; j<comment.container.getElementsByTagName("a").length; j++){
				if (comment.container.getElementsByTagName("a")[j].title.toUpperCase() == ("Raporteaza acest comentariu ca injurios!").toUpperCase()){
					comment.abuse = comment.container.getElementsByTagName("a")[j];
					break;
				}
			}
			
			
			if (comment.abuse){
				comment.abuse.index = comment.index;
				comment.abuse._id = comment.id;
				
				
				//click ABUSE
				comment.abuse.onclick = function(){
					var conf = confirm("Esti sigur ca doresti sa raportezi acest comentariu ca fiind injurios?");
					
					if (!(conf)) return false;
					
					//alert(LOCALPATH+"comment_alert.php?"+'comment_id='+this._id);
					var index = this.index;
					www.post(LOCALPATH+"comment_alert.php",
						 'comment_id='+this._id,
						 function(response) {
							//alert(response)
							JSObject.changeAbuse(index);
						 }
						 );		
				}
			}
			else{
				comment.abuse = null;
			}
			
			this.comments.push(comment);
		}
	}
	
	
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                         FUNCTION CHANGE ABUSE                                     */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	//schimbam statusul de abuz al unui comentariu
	this.changeAbuse = function(index){
		var comment = this.comments[index];
		
		comment.abuse.parentNode.innerHTML = '<span class="header_date"><b>Iti multumim pentru semnalarea facuta!</b></span>';	
		
	}
	
}