// profil
function profilShowLieblingsspiele(user){
	doHttpRequest2('/core/profilShowLieblingsspiele.inc.php?user='+user, 'lieblingsspiele');
}
function profilShowZuletztGespielt(user){
	doHttpRequest2('/core/profilShowZuletztGespielt.inc.php?user='+user, 'zuletztgespielt');
}
function profilShowKommentare(user){
	doHttpRequest2('/core/profilShowKommentare.inc.php?user='+user, 'kommentare');
}
function profilShowHighscore(user){
	doHttpRequest2('/core/profilShowHighscore.inc.php?user='+user, 'highscore');
}



// spieleseite
function showSpielsteuerung(game){
	doHttpRequest2('/core/spielsteuerung.inc.php?game='+game, 'spielsteuerung');
}
function showKommentare(game, anz){
	if(anz == null) {
		anz = 10;
	}
	doHttpRequest2('/core/kommentare.inc.php?game='+game+'&anz='+anz, 'kommentare');
}
function doKommentar(game){
	var kommentar = document.getElementById('kommentar').value;
	doHttpRequest2('/core/kommentare.inc.php?game='+game+'&kommentar='+kommentar, 'kommentare');
	return false;
}
function adLieblingsspiele(game){
	doHttpRequest2('/core/lieblingsspiele.inc.php?game='+game, 'lieblingsspiele');
}
function showBewertung(game){
	loadScript('/ajaxstarrater/rating.js');
	loadCss('/ajaxstarrater/rating.css');
	doHttpRequest2('/core/bewertung.inc.php?game='+game, 'bewertung');
}
function doBewertung(path, game){
	doHttpRequest2(path, 'bewertung');
	//doHttpRequest2('/core/bewertung.inc.php?game='+game, 'bewertung');
}
function showProfil(user){
	doHttpRequest2('/core/profilAnzeigen.inc.php?user='+user, 'containerLightbox');
	window.scrollTo(0,0);
}
function showProfilSuchen(){
	doHttpRequest2('/forms/profilSuchen.inc.php', 'profilsuchen');
}
function showMultiplayerHighscore(game, anz){
	if(anz == null) {
		anz = 100;
	}
	doHttpRequest2('/multiplayerspiele/highscore.inc.php?game='+game+'&anz='+anz, 'highscore');
}
function showHighscore(game){
	doHttpRequest2('/highscorespiele/highscore.inc.php?game='+game, 'highscore');
}

// diverse
function showMissbrauch(){
	doHttpRequest2('/textez/missbrauchmelden.inc.php', 'missbrauch');
}
function showFairplay(){
	doHttpRequest2('/textez/fairplayit.inc.php', 'fairplayit');
}
function showVorteile(){
	doHttpRequest2('/textez/mitgliedervorteile.inc.php', 'vorteile');
}
function showRegistrieren(){
	doHttpRequest2('/forms/registrierenForm.inc.php', 'registrieren');
}
function closeProfil(){
	document.getElementById('overlay').style.display = 'none';
	document.getElementById('containerLightbox').style.display = 'none';
}

function doHttpRequest2(url, divid) {
	var page_request = false;
		
   	if(window.XMLHttpRequest){  // Mozilla, Safari,...
       		page_request = new XMLHttpRequest();
  	} else if (window.ActiveXObject){ // IE
       		try {
           		page_request = new ActiveXObject("Msxml2.XMLHTTP");
    		}
       		catch (e) {
           		try {
              			page_request = new ActiveXObject("Microsoft.XMLHTTP");
     			}
          		 catch (e) {}
       		}
   	} else {
		return false
	}
      
	page_request.onreadystatechange = function() {
		if(page_request.readyState == 4 && page_request.status == 200) {
			handleHttpResponse2(page_request.responseText, divid);
		} else {
			return false;
		}
	}
	page_request.open('GET', url, true);
	page_request.send(null);
}


function handleHttpResponse2(response, divid) {
	if (divid == 'containerLightbox' && response != ''){
		document.getElementById('overlay').style.display = 'block';
		document.getElementById(divid).style.display = 'block';
		document.getElementById(divid).innerHTML=response;
	} else if (divid == ''){
		
	} else {
		document.getElementById(divid).innerHTML=response;
	}
}

function loadScript(scriptname) {
	var snode = document.createElement('script');
	snode.setAttribute('type','text/javascript');
	snode.setAttribute('src',scriptname);
	document.getElementsByTagName('head')[0].appendChild(snode);
}
function loadCss(scriptname) {
	var snode = document.createElement('link');
	snode.setAttribute('rel','stylesheet');
	snode.setAttribute('type','text/css');
	snode.setAttribute('href',scriptname);
	document.getElementsByTagName('head')[0].appendChild(snode);
}
