function revive(uid,post) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","http://www.fcbapp.ch/rotblau/v2/update/pinnwand-request.php?revive=1&uid="+uid+"&post="+post,false);
	xmlhttp.onreadystatechange=function() {
 	}
	xmlhttp.send(null);
}

function remove(uid,post) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","http://www.fcbapp.ch/rotblau/v2/update/pinnwand-request.php?delete=1&uid="+uid+"&post="+post,false);
	xmlhttp.onreadystatechange=function() {
 	}
	xmlhttp.send(null);
}

function like(uid,post) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","http://www.fcbapp.ch/rotblau/v2/update/pinnwand-request.php?like=1&uid="+uid+"&post="+post,false);
 	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			document.getElementById("like"+post).innerHTML="Dir gfallts";
			totalLikes = document.getElementById("totalLikes"+post).innerHTML;
			document.getElementById("totalLikes"+post).innerHTML=parseInt(totalLikes) + 1;
		}
	}
	xmlhttp.send(null);
}

function dislike(uid,post) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","http://www.fcbapp.ch/rotblau/v2/update/pinnwand-request.php?like=-1&uid="+uid+"&post="+post,false);
 	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			document.getElementById("dislike"+post).innerHTML="Dir gfallts nid";
			totalLikes = document.getElementById("totalLikes"+post).innerHTML;
			document.getElementById("totalLikes"+post).innerHTML=parseInt(totalLikes) - 1;
		}
	}
	xmlhttp.send(null);
}

function editForm(id,message) {

	document.getElementById('id').value = id;
	document.getElementById('message').value = message;
	window.scrollTo(0,0);
	
}

function updateData(filePath,idFromFile,reloadInterval) {
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET",filePath,false);
	xmlhttp.onreadystatechange=function() {
  		if (xmlhttp.readyState==4) {
   			if(idFromFile==xmlhttp.responseText) {
 				setTimeout("updateData('"+filePath+"',"+idFromFile+","+reloadInterval+")", reloadInterval);
   			} else {
   				window.location=window.location;
   			}
  		}
 	}
	xmlhttp.send(null);
}

function tickerTime(min,sec) {
	if(sec<0) sec=0; if(min<0) min=0;
	if(sec<10) sec2="0"+sec; else sec2=sec;
	if(min<10) min2="0"+min; else min2=min;
	document.getElementById("timebox").innerHTML = "@ "+min2+":"+sec2;
	sec++;
	if(sec==60) { 
		min++;
		sec=0;
	}
	setTimeout("tickerTime("+min+","+sec+")",1000);
}

function showCalendarDetails(year,month,day) {		
	document.getElementById('calendar').style.opacity = 0.25;
	document.getElementById('details').style.visibility = 'visible'; 
	document.getElementById('calendar').style.zIndex = '1'; 
	document.getElementById('details').style.zIndex = '100'; 
	setTimeout("calendarDetails("+year+","+month+","+day+")",0);
}

function hideCalendarDetails() {
	document.getElementById('details').style.visibility = 'hidden'; 
	document.getElementById('calendar').style.opacity = 1; 
}

function calendarDetails(year,month,day) {

	if(month<10) 	month 	= '0'+month;
	if(day<10)		day		= '0'+day;

	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","http://www.fcbapp.ch/rotblau/v2/update/kalender-request.php?date="+year+"-"+month+"-"+day,false);
	xmlhttp.onreadystatechange=function() {
  		if (xmlhttp.readyState==4) {
			document.getElementById("calendarData").innerHTML=xmlhttp.responseText;
  		}
 	}
	xmlhttp.send(null);
}

var pos_x0 = 140;
var pos_y0 = 70;

function point_it(event){
	pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
	pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;
	
	if(pos_x<0 || pos_x>280 || pos_y<0 || pos_y>280) {
		alert("Ups! Do isch eppis schief gloffe...");
		pos_x = pos_x0;
		pos_y = pos_y0;
	} else {
		pos_x0 = pos_x;
		pos_y0 = pos_y;
	}

	/*alert("Bäng:" + " X: " + pos_x + "Y: " + pos_y);*/
	
	document.getElementById("cross").style.left = (pos_x-2) + "px" ;
	document.getElementById("cross").style.top = (pos_y-2) + "px";
	document.getElementById("cross").style.visibility = "visible" ;
	document.pointform.xCoord.value = pos_x;
	document.pointform.yCoord.value = pos_y;
}

function clickPointInStadium(name) {
	alert('Do isch dr Benutzer mit em Naame '+ name +' yydrait.');
}
