function createRequestObject() {
 var ro;
 if (navigator.appName == "Microsoft Internet Explorer") {
  ro = new ActiveXObject("Microsoft.XMLHTTP");
 } else {
  ro = new XMLHttpRequest();
 }
 return ro;
}
var http = createRequestObject();

function mute(blogid) {
 blogName       = blogs[blogid][0];
 blogURL        = blogs[blogid][1];
 blogAuthor     = blogs[blogid][2];
 showDialog('Confirmation', 'Are you sure you want to mute all the posts from ' + blogName + '?<br /><br /><input type=\'button\' value=\'Yes\' onclick=\'muteThem(' + blogid + '); hideDialog()\' /> <input type=\'button\' value=\'No\' onclick=\'hideDialog()\' />', 'prompt');
}

function muteThem(blogid) {
 // Update the cookie
 http.open('get', '/rainbow/cookie.php?hide=' + blogid);
 http.onreadystatechange = handleResponse;
 http.send(null);
 // Change the list of contributors 
 cont           = document.getElementById('contributor-' + blogid);
 cont.className = 'hidden';
 cont.href      = 'javascript:unmute(' + blogid + ')';
 cont.title     = 'Show all posts on ' + blogs[blogid][0];
 // Hide all their posts
 var divs = document.getElementsByTagName('div');
 for(var i = 0; i < divs.length; i++) {                      
  var divname = divs[i].id; 
  if(divname.indexOf('author-' + blogid) == 0) { 
   divs[i].style.display = 'none';
  }
 }
}

function unmute(blogid) {
 blogName       = blogs[blogid][0];
 blogURL        = blogs[blogid][1];
 blogAuthor     = blogs[blogid][2];
 showDialog('Confirmation', 'Are you sure you want to show ' + blogName + '?<br /><br /><input type=\'button\' value=\'Yes\' onclick=\'unmuteThem(' + blogid + '); hideDialog()\' /> <input type=\'button\' value=\'No\' onclick=\'hideDialog()\' /><br /><br />Or did you just want to visit their site<br /><a href=\'' + blogURL + '\'>' + blogURL + '<\/a>?', 'prompt');
}

function unmuteThem(blogid) {
 // Update the cookie
 http.open('get', '/rainbow/cookie.php?show=' + blogid);
 http.onreadystatechange = handleResponse;
 http.send(null);
 // Change the list of contributors
 cont           = document.getElementById('contributor-' + blogid);
 cont.className = 'normal';
 cont.href      = blogs[blogid][1];
 cont.title     = blogs[blogid][0];
 // Show all their posts
 var divs = document.getElementsByTagName('div');
 for(var i = 0; i < divs.length; i++) {                      
  var divname = divs[i].id; 
  if(divname.indexOf('author-' + blogid) == 0) { 
   divs[i].style.display = 'block';
  }
 }
}

function handleResponse() {
 if (http.readyState == 4) {
  //alert(http.responseText);
 }
}