function karma(id, action, path, normstyle, goodstyle, badstyle, admin){
	var xmlHttpReq = false;
    var self = this;
    
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', path + '/ck-processkarma.php', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
	        var text = self.xmlHttpReq.responseText;
		    var response = text.split('|');
		    
		    if(text.indexOf('error') == -1){
		        if(response[1]){
		        	if(admin != 1){
			        	document.getElementById("down-"+response[1]).src        = path + '/images/gray_down.gif';
			            document.getElementById("down-"+response[1]).onclick    = '';
			            document.getElementById("up-"+response[1]).src          = path + '/images/gray_up.gif';
			            document.getElementById("up-"+response[1]).onclick      = '';
					}
		            var karmanumber = response[2];
					if( response[3] == 'BAD' ){
						document.getElementById("comment-" + response[1]).style.display = 'none';
						document.getElementById("comment-hide-" + response[1]).style.display = 'block'; 
						document.getElementById("comment-"+response[1]).className = badstyle; 
					} else if(response[3] == 'OK'){
					    document.getElementById("comment-"+response[1]).style.display='block';  
						document.getElementById("comment-"+response[1]).className = goodstyle;
					} else {
					    document.getElementById("comment-"+response[1]).style.display='block'; 	
						document.getElementById("comment-"+response[1]).className = normstyle;	
					}
				
		            document.getElementById("karma-"+response[1]).innerHTML = karmanumber;
		        } 
		    } else {
		    	alert("Response: " + text);
		    }
            
        }
    }
    
    self.xmlHttpReq.send('id='+ id + '&action=' + action);
}

function showComment(id){
	document.getElementById("comment-hide-" + id).style.display = 'none';   
	document.getElementById("comment-" + id).style.display = 'block';   
}
