

function openPopUp(url,width,height) {
w = window.open(url, '_new', 'scrollbars=yes,toolbar=yes,location=yes,directories=no,menubar=no,resizable=yes,width=' + width + ',height=' + height);
}


var ihavevoted = 0;

function makeRequest(url,value,article) {
	var http_request = false;

	if(! ihavevoted++){
		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			http_request = new XMLHttpRequest();
			//if (http_request.overrideMimeType) {
				//http_request.overrideMimeType('text/xml');
				// See note below about this line
			//}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	
		if (!http_request) {
			alert('Giving up :( Cannot create an XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = function() { alertContents(http_request); };
		http_request.open('POST', url, true);
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send("score=" + value + "&article=" + article);
	}
}

function alertContents(http_request) {


	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var xmldoc = http_request.responseXML;
			var score_node = xmldoc.getElementsByTagName('score').item(0);

			var img_on = "/images/data/IMG/img/000/000/35-1.GIF";
			var img_off = "/images/data/IMG/img/000/000/34-1.GIF";
			var img_half = "/images/data/IMG/img/000/000/36-1.GIF";			
	
			var score = score_node.firstChild.data;
			
			for(i = 1; i < 7; i++){
				if(score >= 1){
					document.getElementById('star_' + i).src = img_on;
					score = score -1;
				}
				else{
					if(score == 0){
						document.getElementById('star_' + i).src = img_off;
					}
					else{
						document.getElementById('star_' + i).src = img_half;
						score = 0;
					}
				}
			}
			
		} else {
			alert('There was a problem with the request.');
		}
	}

}

var saveStarSrc = null;

function overStar(id) {
	var theStar = document.getElementById(id);
	saveStarSrc = theStar.src;
	theStar.src = '/images/data/IMG/img/000/000/37-1.GIF';
}

function outStar(id) {
	var theStar = document.getElementById(id);
	theStar.src = saveStarSrc;
}

function swapImage(imgName, src) {
	document[imgName].src = src;
}

function openLoginPane() {
	document.getElementById('loginpane').style.top = '210';
	document.getElementById('loginpane').style.left = '80';
	document.getElementById('loginpane').style.visibility = 'visible';
}
function closeLoginPane() {
	document.getElementById('loginpane').style.visibility = 'hidden';
}