var shoutbox = null;
function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function readtag() {
	var shoutbox = createXHR();
	shoutbox.onreadystatechange  = function() { 
         if(shoutbox.readyState  == 4) {
              if(shoutbox.status  == 200) {
                  div = document.getElementById("tagboard");
				  div.innerHTML = shoutbox.responseText;  }
              else {
                 div = document.getElementById("tagboard");
				  div.innerHTML = "Errore "+ shoutbox.status;  }
         }
    }; 
	shoutbox.open("GET","shoutbox.php?action=read");
    shoutbox.send(null);
}
function posttag() {
	document.getElementById('tagbutton').disabled = true;
	setTimeout('document.getElementById(\'tagbutton\').disabled = \'\';', 10000);
	var shoutbox = createXHR();
	shoutbox.onreadystatechange  = function() { 
         if(shoutbox.readyState  == 4) {
              if(shoutbox.status  == 200) {
                  alert(shoutbox.responseText); }
              else {
                 div.innerHTML = alert("Errore "+ shoutbox.status);  }
         }
    }; 
	var data = "tag="+ encodeURIComponent(document.form.tag.value) +"&color="+ document.form.color.value;
	shoutbox.open("POST", "shoutbox.php?action=write", true); 
	shoutbox.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	shoutbox.send(data);
}
function deletepost(num) {
var shoutbox = createXHR();
shoutbox.onreadystatechange  = function() { 
 if(shoutbox.readyState  == 4) {
	  if(shoutbox.status  == 200) {
		  alert(shoutbox.responseText);  }
	  else {
alert("Errore "+ shoutbox.status);  }
 }
}; 
shoutbox.open("GET","shoutbox.php?action=delete&id="+ num);
shoutbox.send(null);

}