/*$(document).ready(function(){ 
    
  // Toggle Elements
  $(".toggleHead").click(function(){
	$(this).next(".toggleContent").slideToggle(400);
  });
  
});
*/
$(document).ready(function() {

	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		//var tip = $(this).attr('title');	
		var tip = $(this).attr('alt');	
		//Remove the title attribute's to avoid the native tooltip from the browser
		//$(this).attr('title','');
		
		//Append the tooltip template and its value
		$("body").append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
		
		//Set the X and Y axis of the tooltip
		$('#tooltip').css('top', e.pageY - 30 );
		$('#tooltip').css('left', e.pageX + 20 );
		
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.8);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY - 30 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		//$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$("body").children('div#tooltip').remove();
		
	});

});







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 closeFrage(id,feedback,nummer){
	//alert("id,feedback,nummer "+id+" / "+feedback+" / "+nummer);
	
	//alert("nummer "+nummer);
	
	$('#quizfrage_'+id).hide('blind');
	//$('.reihenfolge_'+nummer).hide('blind');
	nummer=parseInt(nummer)+1;
	$('.reihenfolge_'+nummer).show('blind');
	$('#quizfrage_beantwortet_'+id).show('blind');
	if(feedback==1){
		$('#quizfrage_beantwortet_'+id+' > .falsch').hide('blind');
	}else if (feedback==0){
		$('#quizfrage_beantwortet_'+id+' > .richtig').hide('blind');
	}else{
		$('#quizfrage_beantwortet_'+id+' > .falsch').hide('blind');
		$('#quizfrage_beantwortet_'+id+' > .richtig').hide('blind');
	}
}

function activateButton(id,crypt){
	//btn_id_{ID}
	//alert("hä "+id+" / "+crypt);
	//document.getElementById("errorMessage").style.display='block';
	document.getElementById('antwort_'+id).value=crypt;	
	$('#btn_id_'+id).show('blind');	
}

function updateScoreJs(score){
	$('#score').html(score);
}


function facebook_publish_feed_story(form_bundle_id, template_data) {
  // Load the feed form
  //alert("facebook_publish_feed_story");
  FB.ensureInit(function() {
          FB.Connect.showFeedDialog(form_bundle_id, template_data);
          //FB.Connect.showFeedDialog(form_bundle_id, template_data, null, null, FB.FeedStorySize.shortStory, FB.RequireConnect.promptConnect);

      // hide the "Loading feed story ..." div
     // ge('feed_loading').style.visibility = "hidden";
  });
}

function feedBackWindow(msg){
	window.scrollTo(0,0);
	//alert("ich bin feedbackwindow");
	$('#feedbackContent').html(msg);
	$('#feedbackContainer').show();
}
function feedBackClose(){
	$('#feedbackContainer').hide();
	
}