var http_requestaddComment = false;
var URL
function makeRequestaddComment(URL, alertFunction) {
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_requestaddComment = new XMLHttpRequest()
    } else if (window.ActiveXObject) { // IE
        try {
            http_requestaddComment = new ActiveXObject("Msxml2.XMLHTTP")
        } catch (e) {
            try {
                http_requestaddComment = new ActiveXObject("Microsoft.XMLHTTP")
            } catch (e) {}
        }
    }
    if (!http_requestaddComment) {
        alert('Giving up :( Cannot create an XMLHTTP instance')
        return false
    }
    http_requestaddComment.onreadystatechange = function() {alertFunction(http_requestaddComment)}
    http_requestaddComment.open('GET', URL, true)
    http_requestaddComment.send(null)
    return true
}

var alertContentsaddComment = function (http_local_requestaddComment) {
    if ( (http_local_requestaddComment.readyState == 4)||(http_local_requestaddComment.readyState=="complete") ) {
        if (http_local_requestaddComment.status == 200) {
    		document.getElementById('add_comment').innerHTML = http_local_requestaddComment.responseText
        } else {
            alert('There was a problem with the request: '+URL+', '+http_local_requestaddComment.status)
    	}
    }
}
function addComment(video_id,cat) {
	var theliste_comment = document.getElementById('add_comment'); // the UL
	
	// switch UL with a loading div
	theliste_comment.innerHTML = '<div class="loading"></div>';
	x = makeRequestaddComment('ajax_add_comment.php?video_id='+escape(video_id)+'&cat='+escape(cat), alertContentsaddComment)
	// On return, call alertContent() to display returned value
}