
var flashVersion = new Array();
var platform;
var plugin;

platform = window.navigator.platform.toLowerCase();
if ((document.all) && (platform.indexOf('mac') == -1)) {
	
	var tmp;

	try {	// flash 4
	    tmp = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.4"); flashVersion[4] = true;
	} catch (e) { flashVersion[4] = false; }
	try {	// flash 5
	    tmp = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5"); flashVersion[5] = true;
	} catch (e) { flashVersion[5] = false; }
	try {	// flash 6
	    tmp = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); flashVersion[6] = true;
	} catch (e) { flashVersion[6] = false; }
	try {	// flash 7
	    tmp = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); flashVersion[7] = true;
	} catch (e) { flashVersion[7] = false; }

} else {
	plugin = navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	if (plugin) {
		var plugindescwords = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i=0; i<plugindescwords.length; ++i) {
			if (isNaN(parseInt(plugindescwords[i]))) continue;
			var pluginVersion = plugindescwords[i]; 
		}

        flashVersion[4] = pluginVersion >= 4;
		flashVersion[5] = pluginVersion >= 5;
		flashVersion[6] = pluginVersion >= 6;
	    flashVersion[7] = pluginVersion >= 7;
	}
}


// return a string version of a thing, without name. 
// calls recursive function to actually traverse content. 
function dump(content) { 
  return dumpRecur(content,0,true) + "\n"; 
} 

// put content into an alert box
function dumpAlert(label,content) { 
  alert(label+"\n"+dump(content)); 
} 

function dumpConfirm(label,content) { 
  confirm(label+"\n"+dump(content)); 
} 

// recursive function traverses content, returns string version of thing
// content: what to dump. 
// indent: how far to indent. 
// neednl: true if need newline, false if not
function dumpRecur(content,indent,neednl) { 
  var out = ""; 
  if (typeof(content) == 'function') return 'function'; 
  else if (dumpIsArray(content)) { 	// handle real arrays in brackets
    if (neednl) out += "\n"+dumpSpaces(indent); 
    out+="[ "; 
    var inside = false; 
    for (var i=0; i<content.length; i++) { 
      if (inside) 
	out+=",\n"+dumpSpaces(indent+1); 
      else 
	inside=true; 
      out+=dumpRecur(content[i],indent+1,false); 
    } 
    out+="\n"+dumpSpaces(indent)+"]"; 
  } else if (dumpIsObject(content)) { 	// handle objects by association 
    if (neednl) out+="\n"+dumpSpaces(indent); 
    out+="{ "; 
    var inside = false; 
    for (var i in content) { 
      if (inside) 
	out+=",\n"+dumpSpaces(indent+1); 
      else 
	inside = true; 
      out+="'" + i + "':"
	 + dumpRecur(content[i],indent+1,true); 
    } 
    out+="\n"+dumpSpaces(indent)+"}"; 
  } else if (typeof(content) == 'string') { 
    out+="'" + content + "'"; 
  } else { 
    out+=content; 
  } 
  return out; 
} 

// print n groups of two spaces for indent
function dumpSpaces (n) { 
  var out = ''; 
  for (var i=0; i<n; i++) out += '  '; 
  return out; 
} 

// Naive way to tell an array from an object: 
// it's an array if it has a defined length
function dumpIsArray (thing) { 
  if (typeof(thing) != 'object') return false; 
  if (typeof(thing.length) == 'undefined') return false; 
  return true; 
} 

// Naive way to tell an array from an object: 
// it's an array if it has a defined length
function dumpIsObject (thing) { 
  if (typeof(thing) != 'object') return false; 
  if (typeof(thing.length) != 'undefined') return false; 
  return true; 
} 
