// popcharthelp.js
// stuff to help display dynamic popcharts in the help system

  function writeStaticImage(name,title,width,height) {
    document.writeln('<div align="center" class="EmbeddedChart">');
    if (hasSVGSupport == true) {
		  document.writeln('<embed alt="' + title + '" longdesc="images/' + name + '.html" width="'+ width +'" height="' + height + '" type="image/svg-xml" pluginspage="http://www.adobe.com/svg/viewer/install/main.html" src="images/' + name + '.svg"></embed>');
	  } else if (hasFlash3up == true || hasFlash == true) {
		  if (useVBMethod == true && hasFlash4 == true) {
			  document.writeln('<object alt="' + title + '" longdesc="images/' + name + '.html" width="'+ width +'" height="' + height + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0"><param name="MOVIE" value="images/' + name + '.swf"></object>');
		  } else {
			  document.writeln('<embed alt="' + title + '" longdesc="images/' + name + '.html" width="'+ width +'" height="' + height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" src="images/' + name + '.swf"></embed>');
		  }
	  } else {
	  	document.writeln('<img alt="' + title + '" longdesc="images/' + name + '.html" width="'+ width +'" height="' + height + '" border="0" src="images/' + name + '.gif" />');
    }
    document.writeln('<a href="images/' + name + '_d.html" title="Description of chart titled: ' + title + '">d</a>');
    document.writeln('</div>');
  }

  function getJSEmbedder() {
	var ret = '<' + 'script language="JavaScript1.1" src="'+parent.ServerInfo+'/jsEmbedder"><'+'/script>';
        return ret;
  }

  function JSEncode(str) {
     str+=" ";
     split = str.split("<");
     var temp = split[0];
     for (i=1; i<(split.length); i++) temp += "&lt;" + split[i];
     split = temp.split(">");
     temp = split[0];
     for (i=1; i<(split.length); i++) temp += "&gt;" + split[i];
     temp+=" ";
     return temp;
  }

  function popUpDataSource(loc) {
       openWindow(loc,"PopChartDataSource","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,dependent=yes,alwaysRaised=yes,width=480,height=360");
  }

  function openWindow(loc,title,args) {
       newwin = open(loc,title,args);
  }

  
//Stuff to Run automatically
  
  
if (false) {
// Load the JSEmbedder
    document.write(getJSEmbedder());
}
else {
// This code is used to detect the user's browser and the plug-ins that
// are available.  No matter how many PopCharts you have in a page, it
// only needs to run once, so we run it automatically at the end of this
// file.
	var hasSVGSupport = false;
	var hasFlash3up = false;
	var hasFlash = false;
        var hasFlash4 = false;
	var useVBMethod = false;
	var flash_str = "Shockwave Flash";
	if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {
		var numPlugins = navigator.plugins.length;
		for (var i = 0; i < numPlugins; i++) {
			var plugin = navigator.plugins[i];
			var numTypes = plugin.length;
			for (var j = 0; j < numTypes; j++) {
				var mimetype = plugin[j];
				if (mimetype) {
					var enabled = "No";
					var enabledPlugin = mimetype.enabledPlugin;
					if (enabledPlugin && (enabledPlugin.name == plugin.name)) enabled = "Yes";
					if (enabled == "Yes") {
						var svgPos = mimetype.type.indexOf("svg");
						if (svgPos != -1) {
							hasSVGSupport = true;
						}
					}
				}
			}
		}
		if (navigator.plugins[flash_str] != null) {
			var pos = navigator.plugins[flash_str].description.search(/\d/);
			var len = navigator.plugins[flash_str].description.length;
			var ver = parseFloat(navigator.plugins[flash_str].description.slice(pos,len));
			if(ver >= 3) {
				hasFlash3up = true;
			}
		}
	} else {
		useVBMethod = true;
	}

// Use VBScript if in MSIE
  
  if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
     document.writeln('    <script language="VBScript">');
     document.writeln('        <!--');
     document.writeln('	          On Error Resume Next');
     document.writeln('	              If useVBMethod = true Then');
     document.writeln('            		hasSVGSupport = IsObject(CreateObject("Adobe.SVGCtl"))');
     document.writeln('            		hasFlash = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))');
     document.writeln('               hasFlash4 = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))');
     document.writeln('           	End If');
     document.writeln('        //-->');
     document.writeln('    </script>');
  }
}