// JavaScript Document

$(document).ready(function() {
	$(".log_content").hide();
	updateScoreJs();
});





function showErrorMessage(sTitle, sErrorMsg){
	window.scrollTo(0,0);

	var sData="";
	sData+="<h1>"+sTitle+"</h1>";
	sData+=sErrorMsg;
	sData+="<p>&nbsp;</p>";
	sData+="<p>&nbsp;</p>";
	sData+="	<div id='errorMessageClose'>";
	sData+="	<a href='#' onClick='closeErrorMessage();return null;'>Fenster schliessen</a>"
	sData+="	</div>";	
	//var newDiv = document.createElement("div");
//var dataNode = document.createTextNode(sData);
	document.getElementById("errorMessage").innerHTML=sData;
	document.getElementById("errorMessage").style.display='block';
}

function closeErrorMessage(){
	document.getElementById("errorMessage").style.display='none';
}



function updateScoreJs(){
	$('#punkte').load('/php/punkteControl.php',{}, function(data) {
	});
}



function feedBackWindow(msg){
	window.scrollTo(0,0);
	//alert("ich bin feedbackwindow");
	$('#feedbackContent').html(msg);
	$('#feedbackContainer').show();
}
function feedBackClose(){
	$('#feedbackContainer').hide();
	
}
function updateLog(itemId,currentLevel){
	//alert('Load will performe: '+itemId+" / "+currentLevel);
	$('#log_content_'+currentLevel).load('/php/itemControl.php',{"itemId":itemId,"level":currentLevel}, function(data) {
		//alert('Load was performed.'+data);
	});
}
function updateMoney(itemId, level){
	removeMarker(itemId);
	$('#log_content_'+currentLevel).load('/php/itemControl.php',{"itemId":itemId,"level":currentLevel}, function(data) {
		//alert('update Money');
		updateScoreJs();
	});
	
}

function initLog(){
	$('#log_content_1').load('/php/itemControl.php',{"itemId":"0","level":"1"});
	$('#log_content_2').load('/php/itemControl.php',{"itemId":"0","level":"2"});
	$('#log_content_3').load('/php/itemControl.php',{"itemId":"0","level":"3"});
	$('#log_content_4').load('/php/itemControl.php',{"itemId":"0","level":"4"});
	$('#log_content_5').load('/php/itemControl.php',{"itemId":"0","level":"5"});
}


function showInfoWindow(toShow){
	$('#infoWindow').empty();
	$('#infoWindow').load('/php/infoWindow.php',{"toShow":toShow});	
	$('#infoWindow').show();
	$('#map').hide();
	$('#miniMap').hide();
}

function infoWindowClose(){
	$('#infoWindow').empty();
	if(currentLevel=="6"){
		showInfoWindow('overview');
	}else{
		$('#infoWindow').hide();
		$('#map').show();
		$('#miniMap').show();
	}
	
}


function checkUMusic(){
	$.getJSON("http://www.unheilig-grossefreiheit.com/php/checkFreeCodes.php",function(data) {
		//alert("hallo");
		if(data.uMusic =="ja"){
			showMarker("1000");
		}
		
	});
	//alert("data "+data);
	//showMarker("1000");
	
}
function checkBravado(){
	//alert("hallo aussen");
	$.getJSON("http://www.unheilig-grossefreiheit.com/php/checkFreeCodes.php",function(data) {
		//alert("hallo innen");
		if(data.bravado =="ja"){
			showMarker("30000");
		}
	});
}	