// JavaScript Document

function debug_panel(msg){
	var w = get_window_size();
	
	if(!document.getElementById("debug_panel")){
		var el = document.createElement("div");
		el.id = "debug_panel";
		el.width = w.width + "px";
		el.height = "300px";
		el.style.overflow = "auto";
		el.style.position = "absolute";
		el.style.bottom = "0px";
		el.style.border = "1px solid #cccccc";
		el.style.background = "#ffffff";
		el.style.padding = "25px";
	} else el = document.getElementById("debug_panel");
	
	msg = "<p>" + msg + "</p>";
	
	el.onclick = function(){ close_debug(el) };
	
	el.innerHTML += msg;
	
	document.body.appendChild(el);
}

function close_debug(el){
	document.body.removeChild(el);
}

function get_window_size(){
	var winW = 630, winH = 460;
	
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	return new Object({"width" : winW, "height" : winH});
}

//debug method to dump object properties
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}