function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()


function showhide(div,nest,img){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	if(obj.display=='block' || obj.display=='block') obj.display='none'
	else {
		obj.display='block';
		if (img) document.getElementById(img).src=nest;
		else document.getElementById(div).src=nest;
		obj.top  = document.body.scrollTop + 55;
	}
}

function showhide2(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	if(obj.display=='block' || obj.display=='block') obj.display='none'
	else {
		obj.display='block';
		
		obj.height  =  document.body.scrollHeight;
		}
}

function show(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	obj.display='block'
}

function hide(div,nest){
	// Old sjit with checks for msie 4 and ns 4,7
	//obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	// Hide layer if layer exists
	if (document.getElementById(div)) {
		obj = document.getElementById(div).style;
		obj.display='none';
	}
}




/**** SHOW OBJECT INFO ****/

/* Display all the properties of an object
* obj - object, the object u want to have the properties
* expd - boolean default = false, expand proterties which contains objects
* lvl - int default = 0, The level of displayd props that contain objects.
*                        Watch it even 1 level can get realy heavy.
*/
function jsDump (obj,expd,lvl) {
  // Set default values
  if(!lvl) lvl = 0;
  else if (lvl.length == 0) lvl = 0;
  if(!expd) expd = false;
  else if (expd.length == 0) expd = false;
    
  // Open window
  //win = popupWindow('',1000,800);
  //if(win) alert('weg ermee'); win.close();
  win = window.open();

  // Open the main table
  var html = '<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#009900" style="background-color:#97F9A4;font-weight:bold;">';
  html += '<tr>';
  html += '<td onclick="opener.showHideDisplay(0)" style="padding: 5px;vertical-align:top;">' + obj.nodeName + '</td>';
  html += '<td width="99%" id="0" bgcolor="#009900" style="border: 2px solid #009900;">';
  win.document.write(html);  
  
  // Display properties
  dspProps(obj,win,expd,lvl);
  
  //close the main table
  win.document.write('</td></tr></table>');
}


/* Generate html table with property info
* obj - object, the object u want to have the properties
* w - window, the destination new window to write to.
* expd - boolean default = 0, expand proterties which contains objects
* lvl - int default = 0, The level of displayd props that contain objects.
*                        Watch it even 1 level can get realy heavy.
*/
function dspProps(obj,w,expd,lvl) {
  var tableCount = 0;

  var html = '<table width="100%" border="1" bordercolor="#009900" bgcolor="#009900" cellpadding="0" cellspacing="0">';
  w.document.write(html);

  // Loop over the properties of this object
  for(name in obj) {
    tableCount ++;
    // Create unique id
    id = uniqueId();
    html = '<tr><td bgcolor="#97F9A4" onclick="opener.showHideDisplay(\'' + id + '\')" valign="top" style="padding: 5px">';
    html += name + '</td><td bgcolor="#97F9A4" width="99%" id="' + id + '"';
    w.document.write(html);
    

    // Check if property is an object, hmmm can be done nicer i think but it works ;)
    if (typeof(obj[name]) == 'object') {
      // Recusive sjit to show props of objectprops, watch it even 1 level can get realy heavy.
      if (lvl > 0 && false) {
        if (!expd)  html = 'style="display:none">';
        else html = '>';
        w.document.write(html);
        lvl--;
        lvl = dspProps(obj[name],w,expd,lvl);
        lvl++;
        html = "";
      } else {
        // Create unique id
        html = ' style="padding: 5px;"><div style="font-weight:bold;cursor:hand;">[Object]</div>';
      }
    }
    // Just a normal value
    else {
      html = ' style="padding: 5px;">';
      // Don't show real HTML, show HTML code only
      if (/^\w{3}erHTML$/.test(name)) {
        html += obj[name].replace(/<([^>]*)>/g,'&lt;$1&gt;');
      } else {
        html += obj[name];
      }
      
      html += '&nbsp;';
    }
    
    html += '</td></tr>';
    w.document.write(html);
  }

  w.document.write('</table>');
  return lvl; 
} 

function uniqueId() {
  id =  new Date();
  id = id.getTime()*Math.random();
  return id;
}

/**** /SHOW OBJECT INFO ****/
