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

var alertContentsrating_bar = function (http_local_requestrating_bar) {
    if ( (http_local_requestrating_bar.readyState == 4)||(http_local_requestrating_bar.readyState=="complete") ) {
        if (http_local_requestrating_bar.status == 200) {
    		document.getElementById('rating_script').innerHTML = http_local_requestrating_bar.responseText
        } else {
            alert('There was a problem with the request: '+URL+', '+http_local_requestrating_bar.status)
    	}
    }
}
function addrating_bar(video_id) {
	var theliste_rating_bar = document.getElementById('rating_script'); // the UL
	
	// switch UL with a loading div
	theliste_rating_bar.innerHTML = '<div class="loading"></div>';
	x = makeRequestrating_bar('_drawrating1.php?video_id='+escape(video_id), alertContentsrating_bar)
	// On return, call alertContent() to display returned value
}