function ajax(url) {
	var xmlHttp = null;
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
    	xmlHttp = new XMLHttpRequest();
	}
	if (!xmlHttp) {
    	// Internet Explorer 6 und älter
    	try {
        	xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
   	 	} catch(e) {
       	 	try {
            	xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
            	xmlHttp  = null;
        	}
    	}
	}
	if (xmlHttp) {
    	xmlHttp.open('GET', url, true);
    	xmlHttp.onreadystatechange = function () {
        	if (xmlHttp.readyState == 4) {
            	cb(xmlHttp.responseText);
        	}
    	};
    	xmlHttp.send(null);
	}
}
function cb(t) {
	if(document.all) document.getElementById('vote').style.padding = '6px';
	if(t=='1') document.getElementById('vote').innerHTML = "Stimme wurde gezählt!";
	else document.getElementById('vote').innerHTML = "Du hast schon abgestimmt!";
}

function star(anz,vote) {
	if(vote) {
		ajax('/vote.php?vote=' + anz + '&id=' + gameid);
	}
	else {
		var stars = document.getElementById('vote').getElementsByTagName('img');
		for(var i=0; i<stars.length; i++) {
			if(anz>i) stars[i].src = '/images/star_gold.gif';
			else stars[i].src = '/images/star_grey.gif';
		}
	}
}

function bookmark(a,t,d) {
	open('http://infopirat.com/bookmark-king.php?&url='+a+'&title='+t+'&description='+d,'Bookmark King','modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=730,height=665,left='+(screen.width-730)/2+',top='+(screen.height-665)/2);	
}
window.onload = function() {
	var stars = document.getElementById('vote').getElementsByTagName('img');
	
	for(var i=0; i<stars.length; i++) {
		var e=i+1;
		stars[i].onmouseover = new Function('star(' + e + ',0)')
	}
	for(var i=0; i<stars.length; i++) {
		var e=i+1;
		stars[i].onclick = new Function('star(' + e + ',1)')
	}
	
	document.getElementById('vote').onmouseout = new Function('star(0)')
	document.getElementById('crc').value = crc;
}
