function detailed (id) {
    info_x = document.getElementById('the_info');
    info_x.style.display = "block";

    shutter_x = document.getElementById('shutter');
	 shutter_x.className = "shutter";

    shutter_x.onclick = hideShutter;
	 info_x.className = "info";

    // AJAX stuff
    
    if (getAJAX.readyState == 4 || getAJAX.readyState == 0) {
        getAJAX.open("GET","data.php?id=" + id, true);
        
        getAJAX.onreadystatechange = function () {
			if (getAJAX.readyState == 4)
    	   info_x.innerHTML = getAJAX.responseText;
     }
  	
  	getAJAX.send(null);

    }
    
}


function hideShutter () {
	shutter_x = document.getElementById('shutter');
	info_x = document.getElementById('the_info');
	// clear info
	info_x.innerHTML = "";
	info_x.className = "";
	shutter_x.className = "";
	
	info_x.style.display = "none";
}

function setActiveStyleSheet(title) {
	switcher_x = document.getElementById('switcher');
	 
	if (switcher_x.className == 'compact') {
	 switcher_x.className = "normal";
	 document.getElementById("period").setAttribute('cellspacing', '2');
	 switcher_x.href = "javascript:setActiveStyleSheet('normal');";
	}
	 else {
	 switcher_x.className = "compact";
	 document.getElementById("period").setAttribute('cellspacing','1');
	 switcher_x.href = "javascript:setActiveStyleSheet('compact');";
	}
	
	var i, a, main;   
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	       a.disabled = true;       
			  if(a.getAttribute("title") == title)
			    a.disabled = false;     }
   }
   
}

window.onload =  function () {
    all_tds = document.getElementsByTagName("td");
    for (var n=0; n<all_tds.length; n++) {
        if (!all_tds[n].className || all_tds[n].className == "") {
        
            all_tds[n].onclick = function () {
            	this.className = "";
                // get the id by finding the text within <strong>
                id = this.getElementsByTagName('strong')[0].firstChild.nodeValue;
                detailed(id);
            }

				all_tds[n].onmouseover = function () { this.className = "tdhover"; }
				all_tds[n].onmouseout  = function () { this.className = ""; }

        }
    }
    
    //more onLoad stuff
    
    getAJAX = getHTTPObject();
    
}


//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
