// JavaScript Document
var contactShown = false;
var tweetsShown = false;

function showContact (){
	if (!contactShown){
		document.getElementById('contact_form').style.display = "block";
		document.getElementById('contact').style.left = "400px";
		contactShown = true;
	} else {
		document.getElementById('contact_form').style.display = "none";
		document.getElementById('contact').style.left = "0px";	
		contactShown = false;
	}
}

function showAllTweets (){
	if (!tweetsShown){
		document.getElementById('tweets').style.display = "block";
		document.getElementById('tweets_label').style.left = "500px";
		tweetsShown = true;
	} else {
		document.getElementById('tweets').style.display = "none";
		document.getElementById('tweets_label').style.left = "0px";	
		tweetsShown = false;
	}
}



function getContents (content){
	
	// show loader
	document.getElementById('main_tekst').innerHTML = "<table width='100%' height='400px'><tr><td align='center' valign='middle'><img src='images/loader.gif' /></td></tr></table>";
	
	var xmlHttp;
	try{
 	 xmlHttp=new XMLHttpRequest();
  	}
	catch (e) {
 	 	try {
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		}
  		catch (e){
    			try {
      				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     			}
    			catch (e) {
     				alert("Your browser does not support AJAX!");
      				return false;
      			}
    		}
  	}
	xmlHttp.onreadystatechange=function(){
   		 if(xmlHttp.readyState==4){
     		 	document.getElementById('main_tekst').innerHTML = xmlHttp.responseText;
      		}
    	}
  	xmlHttp.open("GET", "php/getcontent.php?type="+content, true);
 	xmlHttp.send(null);
}

function saveReaction(blogID){
	
	document.getElementById('reactions_'+blogID).innerHTML = "<img src='images/loader.gif' />";
	var name = document.getElementById('r_naam'+blogID).value;
	var tekst = document.getElementById('r_tekst'+blogID).value;
	
	document.getElementById('r_naam'+blogID).value = "";
	document.getElementById('r_tekst'+blogID).value = "";
	
	var xmlHttp;
	try{
 	 xmlHttp=new XMLHttpRequest();
  	}
	catch (e) {
 	 	try {
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		}
  		catch (e){
    			try {
      				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     			}
    			catch (e) {
     				alert("Your browser does not support AJAX!");
      				return false;
      			}
    		}
  	}
	xmlHttp.onreadystatechange=function(){
   		 if(xmlHttp.readyState==4){
     		 	document.getElementById('reactions_'+blogID).innerHTML = xmlHttp.responseText;
      		}
    	}
  	xmlHttp.open("GET", "php/update_reaction.php?blog_id="+blogID+"&name="+name+"&tekst="+tekst, true);
 	xmlHttp.send(null);
}