var _app = navigator.appName;

function AppletFinansite() 
{
	this.propriedades = new Array();
	this.nomesParametros = new Array();
}

AppletFinansite.prototype.propriedades = undefined;
AppletFinansite.prototype.nomesParametros = undefined;
AppletFinansite.prototype.indice = 0;
AppletFinansite.prototype.abreTag = '';
AppletFinansite.prototype.fechaTag = '';

AppletFinansite.prototype.setPropriedade = function(nome, valor)
{
	this.propriedades[nome] = valor;
	this.nomesParametros[this.indice] = nome;
	this.indice++;	
}

AppletFinansite.prototype.getPropriedade = function(nome)
{
	return this.propriedades[nome];
}

AppletFinansite.prototype.inicia = function(divID)
{
	var temPlugin = this.temJavaPluginIE();
	this.abreTag = '<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=1,5,0,0" width="'+this.getPropriedade('width')+'" height="'+ this.getPropriedade('height')+'">';
	this.fechaTag = '</OBJECT>';
	if(_app != 'Microsoft Internet Explorer') 
	{
		this.abreTag = '<embed type ="application/x-java-applet;version=1.5" pluginspage="http://java.sun.com/products/plugin/index.html#download"';
		this.fechaTag = '</embed>';
	}
	/*
	else if(!temPlugin)
	{
		this.abreTag = '<applet width="'+this.getPropriedade('width')+'" height="'+ this.getPropriedade('height')+' codebase="'+ this.getPropriedade('codebase') + '" code="' + this.getPropriedade('code') + '" archive="'+this.getPropriedade('archive') + '">';
		this.fechaTag = '</applet>';
	}
	*/
	
	var tagApplet = this.abreTag;
	for(i = 0;i < this.indice;i++)
	{
		if(_app != 'Microsoft Internet Explorer') 
		{
			tagApplet += ' ' + this.nomesParametros[i]+'="' + this.getPropriedade(this.nomesParametros[i]) + '"';
		}
		else
		{
			tagApplet += '<PARAM name='+this.nomesParametros[i]+' value="' + this.getPropriedade(this.nomesParametros[i]) + '">';
		}
	}

	if(_app != 'Microsoft Internet Explorer') 
	{
		tagApplet += '>';
	}	
	tagApplet += this.fechaTag;
	
	if(temPlugin)
	{
  		var d = escrever(divID, tagApplet);
	}
	else
	{
		document.write(tagApplet);
	}
}

AppletFinansite.prototype.temJavaPluginIE = function()
{
//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer	
	
	var agt=navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	var mac = (agt.indexOf("mac")!=-1);
	
	if (ie && win) 
	{	
		pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); 
	}
	if (ns || !win) 
	{
			nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
			pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
	}
	
	pluginlist += navigator.javaEnabled() ? "Java," : "";
	if (pluginlist.length > 0) 
	{
		pluginlist = pluginlist.substring(0,pluginlist.length-1);
	}

	if (pluginlist.indexOf("Java")!=-1)
		return true;
	return false;
}

function detectIE(ClassID,name) 
{ 
	result = false; 
	document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); 
	if (result) 
	{
		return name+','; 
	}
	else
	{
		 return ''; 
	}
}

function detectNS(ClassID,name) 
{ 
	n = ""; 
	if (nse.indexOf(ClassID) != -1) 
	if (navigator.mimeTypes[ClassID].enabledPlugin != null)
	{
		n = name+","; return n; 
	}
}


var DHTML = (document.getElementById || document.all || document.layers);
function pegarDiv(nome)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(nome);
	}
		else if (document.all)
	{
		this.obj = document.all[nome];

	}
		else if (document.layers)
	{
		this.obj = document.layers[nome];
	}
}
function escrever(id,texto) {
  if (!DHTML) return;
  var x = new pegarDiv(id);

  x.obj.innerHTML = texto;
   
  return;
}

