function changeOn(image) {
  document.getElementById(image).style.zIndex = 0;
}
function changeOff(image) {
  document.getElementById(image).style.zIndex = 7;
}
function popUp_print(pagina){
	pop1 = open(pagina,"","width=845,location=no,menubar=no,statusbar=no,toolbar=no,resizable=yes,scrollbars=yes")
	pop1.focus()  // forces the popup to come to the front if it has already been opened, but not closed
}
function abrirPopUp(url){
	window.open(url, '', 'menubar=no,toolbar=no,status=no,location=no,resizable=no,width=780,height=510');
}
function openPopup(url,wi,hei,scroll){
    
        var width = wi;
        var height = hei;
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;
        var params = 'width=' + width + ', height=' + height;
        params += ', top=' + top + ', left=' + left;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars='+scroll;
        params += ', status=no';
        params += ', toolbar=no';
        
        newwin = window.open(url, 'pop', params);
        if (window.focus) {
            newwin.focus();
        }
        return false;
        
}
function validaCPF (link){ 
	var form = document.getElementById("ib");
	var cpf = new String(form.txtCpf.value);
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
	cpf = cpf.replace("-", "");
	//alert(cpf);
	
	if (cpf.length != 11 
		|| cpf == "00000000000" 
		|| cpf == "11111111111" 
		|| cpf == "22222222222" 
		|| cpf == "33333333333" 
		|| cpf == "44444444444" 
		|| cpf == "55555555555" 
		|| cpf == "66666666666" 
		|| cpf == "77777777777" 
		|| cpf == "88888888888" 
		|| cpf == "99999999999") {
			alert("CPF inválido. Por favor, informe novamente.");
			return false;
	}
	soma = 0;
	for (i=0; i < 9; i ++)
		soma += parseInt(cpf.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(cpf.charAt(9))) {
		alert("CPF inválido. Por favor, informe novamente.");
		return false;
	}
	soma = 0;
	for (i = 0; i < 10; i ++)
		soma += parseInt(cpf.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(cpf.charAt(10))) {
		alert("CPF inválido. Por favor, informe novamente.");
		return false;
	}
	//alert('CPF correto.');
	form.txtCpf.value = cpf;
	form.action = link + cpf;
	form.submit();
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth - 20 ;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
//Resize - Lightbox
function resizeBackgroud(){
	// prep objects
	var objOverlay = document.getElementById('overlay');
	var arrayPageSize = getPageSize();
	
	objOverlay.style.width =  (arrayPageSize[0]  + 'px');
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	
}
window.onresize = function (){
	resizeBackgroud();	
}

//Popup 
function showPopup(visibility,boxPopup){

	$("#popContent").text("");	


	if (visibility == true ){

		display = "block";

		$('embed, object, select').css({ 'visibility' : 'hidden' });

	} else {

		display = "none";

		$('embed, object, select').css({ 'visibility' : 'visible'});

	}


	resizeBackgroud();
	//Esconde os conteudos
	
	$("#overlay").css({'display' : display }); 
	$("#popup").css({'display' : display }); 

	switch (boxPopup) {
		case "termo":
			$("#popContent").load("/web/site/bv/layers/termo_de_uso.jsp");
			break
		case "imprensa":
			$("#popContent").load("/web/site/bv/layers/imprensa.jsp");
			break
		case "politica":
			$("#popContent").load("/web/site/bv/layers/politica.jsp");
			break
		case "resultado":
			$("#popContent").load("/web/site/bv/layers/resultadoFeeder.jsp");
			break
		case "tarifas":
			$("#popContent").load("/web/site/bv/layers/tarifas.jsp");
			break	
		case "seguranca":
			$("#popContent").load("/web/site/bv/layers/seguranca.jsp");
			break	
	}	

}



//Popup 
function showPopup2(visibility){
	if (visibility == true ){
		display = "block";
		$('embed, object, select').css({ 'visibility' : 'hidden' });
	} else {
		display = "none";
		$('embed, object, select').css({ 'visibility' : 'visible'});
	}
	
	resizeBackgroud();
	//Esconde os conteudos
	
	$("#overlay").css({'display' : display }); 
	$("#popup-2").css({'display' : display }); 

}


/*Popup Print*/
function popUp_print(pagina){
	pop1 = open(pagina,"","width=845,location=no,menubar=no,statusbar=no,toolbar=no,resizable=yes,scrollbars=yes")
	pop1.focus()  // forces the popup to come to the front if it has already been opened, but not closed
}

/**/
/**/
function toggleItens(item){
	$('#'+item).toggle();
	if ( $('#'+item).is(':hidden') ){
		$('#img-'+item).attr('src', '/web/site/bv/images/modulo/icnazulexibir.gif');
	} else {
		$('#img-'+item).attr('src', '/web/site/bv/images/modulo/icnazulocultar.gif');
	}
}

function salvarPaginaInicial() {
	document.getElementById("imgCookie").style.display="block";				
}

/*************************************************************************************************************/
/* contato */
function encaminhar() {
	var link;
	var empresaSelecionada = document.getElementById("empresa").options[document.getElementById("empresa").selectedIndex].value; 
	if("Selecione" == empresaSelecionada) {
		//alert("Seleciona alguma coisa né mano !");
	} else {
		if("Banco Votorantim" == empresaSelecionada) {
			//alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=1");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=1"
		} else if("VAM - Votorantim Asset Management" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=9");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=9"
		} else if("Votorantim Corretora" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=8");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=8"	
		} else if("BV Financeira" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=4");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=4"
		} else if("BV Leasing" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=5");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=5"
		} else if("BV Sistemas" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=7");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=7"
		}
		var width = 603;
		var height = 450;
		var left   = (screen.width  - width)/2;
		var top    = (screen.height - height)/2;
		var params = 'width='+width+', height='+height;
		params += ', top='+top+', left='+left;
		params += ', directories=no';
		params += ', location=no';
		params += ', menubar=no';
		params += ', resizable=no';
		params += ', scrollbars=yes';
		params += ', status=no';
		params += ', toolbar=no';
	
		newwin=window.open(link,'trabalhe', params);
		if (window.focus) {newwin.focus();}
		return false;			
	}
}


function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = ""
        return false
    }
    status = ""
    return true
}

var whitespace = " \t\n\r";
function isEmail (s)
{  
	
 if (isEmpty(s)) 
       //if (isEmail.arguments.length == 1) return defaultEmptyOK;
       //else return (isEmail.arguments[1] == true);
   
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

 function VerificarForm()
{
	var flag = 0;
	var flag1 = 0;

	for( i=0; i < document.frmEmail.length; i++ )
	{
		if(document.frmEmail[i].name == undefined){
			continue;
		}
		
		if(document.getElementById("msg_" + document.frmEmail[i].name)){
			var div = document.getElementById("div_" + document.frmEmail[i].name);
			div.style.color="#E10101";
			div = document.getElementById("msgErro");
		}
		
		if( document.frmEmail[i].value == "" && document.getElementById("msg_" + document.frmEmail[i].name) )
		{
			document.getElementById("msg").innerHTML = "<b>Existem campos obrigat&oacute;rios que n&atilde;o est&atilde;o preenchidos!</b>";
			div.style.display="block";
			if (flag1==0) {
				document.frmEmail[i].focus();
				flag1=1;
			}
			flag = 1;
		} else if(flag == 0 &&document.frmEmail[i].name.indexOf("Email") > 0 && !isEmail(document.frmEmail[i].value) && document.getElementById("msg_email_" + document.frmEmail[i].name) ) {
			document.getElementById("msg").innerHTML = "<b>E-mail inv&aacute;lido. Por favor, informe novamente!</b>";
			div.style.display="block";
			document.frmEmail[i].select();
			flag = 1;
				
		}  else if (document.getElementById("msg_" + document.frmEmail[i].name)) {
			var div = document.getElementById("div_" + document.frmEmail[i].name);
			div.style.color="#666666";
		}
	}
	if (flag == 0) {
		div = document.getElementById("msgErro");
		div.style.display="none";
		document.frmEmail.submit();
	}
					
}
/******************************************************************************************************************************************/
/** Carrega Applet **/



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;
}

/******************************************************************************************************************************************/
/** Show Box Acesso Rapido**/


jQuery.noConflict();
var $ = jQuery;

function showHideElement(jElement)
{
	var id = jElement.attr("class").replace(/content/gi,"hide");
	id = (id.indexOf(" ")>-1)?id.substring(id.indexOf("hide")):id;
	id = (id.indexOf(" ")>-1)?id.substring(id.indexOf("hide"),id.indexOf(" ")):id;

	var jImage = $("#" + id).find("img");
		
	if(jElement.css("display") =="none")
	{
		try
		{
			var bgImage = $("#" + id).css("background-image");
			var bgImage = (bgImage.indexOf("acessoacoes") > -1)?bgImage.replace("fechado",""):bgImage;
			$("#" + id).css("background-image",bgImage);
		} catch(e){}
			
		jElement.show();
		jElement.find("*").show();
		
		try
		{
			var newSrc = jImage.attr("src").replace(/Mostra/gi,"Esconde");	
			jImage.attr("src",newSrc);
		} catch(e){}
		
		try
		{
			var jSelect = $("." + jElement.attr("class").replace(/content/gi,"select")).find("select").hide();
		} catch(e){}
		
	}
	else{
		try
		{
			var bgImage = $("#" + id).css("background-image");
			var bgImage = (bgImage.indexOf("acessoacoes") > -1)?bgImage.replace(".gif","fechado.html"):bgImage;
			$("#" + id).css("background-image",bgImage);
			
		} catch(e){}
		
		jElement.hide();
		jElement.find("*").hide();
		
		try
		{
			var newSrc = jImage.attr("src").replace(/Esconde/gi,"Mostra");
			jImage.attr("src",newSrc);

		} catch(e){}	
		
		try
		{
			
			var jSelect = $("." + jElement.attr("class").replace(/content/gi,"select")).find("select").show();
		} catch(e){}			
	}
}

/** Busca Cotacoes **/
// JavaScript Document
var totalAtivosSelecionados = 5;
var VarQ10Ativo1Votorantim;
var VarQ10Ativo2Votorantim;
var VarQ10Ativo3Votorantim;


var varArquivo = "";
var varAcao = "";
var varAtivo = "";
var ie4 = (document.all) ? true : false;
var DHTML = (document.getElementById || document.all || document.layers);
var layerAtivo;
urlFonte = "finansite-a.ae.com.br"; // dominio/ip de onde estar� os XMLs ex: "192.168.2.35" ip do fsclone
varCliente = "votorantim"; // o cliente para montar a url Ex.: http://192.168.2.35/castrolanda/xml/cambio.xml

var tipoJSP = "";
var ehVoltar = false;

//urlBuscarXMLpesquisa = "http://192.168.2.35/finansite2/jsp/buscarHTML.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente!

/*
urlBuscarXMLpesquisa = "http://flavio:8080/votorantimBusca/buscarHTML.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente!
urlBuscarMinhasAcoes = "http://flavio:8080/votorantimBusca/buscarXMLMinhasAcoes.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente!
*/


contexto="/web/site";
urlBuscarXMLpesquisa = contexto + "/bv/feeder/buscarHTMLpesquisa.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente!
urlBuscarMinhasAcoes = contexto + "/bv/feeder/buscarXMLMinhasAcoes.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente!
urlBuscarXMLcotacoes = contexto + "/bv/feeder/buscarXMLcotacoes.jsp"; // caminho onde ficar� o PHP/ASP/JSP no servidor do cliente

function Cotacao(){}

Cotacao.prototype.xmlHttp = undefined;
Cotacao.prototype.xmlDoc = undefined;

Cotacao.prototype.createXMLHttpRequest = function()
{
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
}

Cotacao.prototype.ler_xml = function() 
{
	
	var metodo = "GET";
	var _this = this;
	
	this.xmlHttp = this.createXMLHttpRequest();
	
	if (tipoJSP == "cotacoes")
	{
		urlBuscarXMLchamar = urlBuscarXMLcotacoes + "?fonte=" + urlFonte + "&cliente=" + varCliente + "&arquivo=" + varArquivo;
	}
	else if (tipoJSP == "busca")
	{
		urlBuscarXMLchamar = urlBuscarXMLpesquisa + "?fonte=" + urlFonte + "&cliente=" + varCliente + "&ativo=" + varAtivo;
	}
	else if (tipoJSP == "minhasacoes")
	{
		if (varAcao == "formulario")
		{
			urlBuscarXMLchamar = urlBuscarMinhasAcoes + "?acao=" + varAcao + "&contexto=" + contexto;
		}
		else if (varAcao == "resultado")
		{
			urlBuscarXMLchamar = urlBuscarMinhasAcoes + "?acao=" + varAcao + "&contexto=" + contexto + "&ativo1=" + VarQ10Ativo1Votorantim + "&ativo2=" + VarQ10Ativo2Votorantim + "&ativo3=" +VarQ10Ativo3Votorantim + "&ativo4=" + VarQ10Ativo4Votorantim + "&ativo5=" +VarQ10Ativo5Votorantim;
		}
	}
	url = urlBuscarXMLchamar + "&_xxx_=" + new Date().getTime(); // evitando cache do IE
	
	str_http = url.substr(0, 6);
	if (str_http == "http:/")
	{
		metodo = "POST";	
	}

	//document.write(url);
	this.xmlHttp.onreadystatechange = function(){_this.esperaXML()};
	
	if(window.XMLHttpRequest) 
	{
		this.xmlHttp.open(metodo, url, true);
	}
	else if(window.ActiveXObject) 
	{
		gambi_ie_dt = new Date();
		gambi_ie_dt_hr = gambi_ie_dt.getTime();
		this.xmlHttp.open(metodo, url, true);
	}

	this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	this.xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");

	this.xmlHttp.setRequestHeader("Expires","0");
	this.xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	this.xmlHttp.setRequestHeader("Pragma", "no-cache");

	this.xmlHttp.send(null);
}

Cotacao.prototype.esperaXML = function() 
{
/**
* 0 - N�o iniciado (Uninitialised)
* 1 - Carregando (Loading)
* 2 - Carregado (Loaded)
* 3 - Interativo (Interactive)
* 4 - Completado (Completed)
*/
	
	if (this.xmlHttp.readyState != 4)
	{
		return;
	}
	else
	{
		 if (this.xmlHttp.status == 200)
		 {
			this.xmlDoc = null;
			//this.xmlDoc = this.xmlHttp.responseXML;
			this.xmlDoc = this.xmlHttp.responseText;
			if (tipoJSP == "cotacoes")
			{
				if (varArquivo == "indicadores.xml") {
					escrever_campo("conteudoIndices", this.xmlDoc);
				} else {
					escrever_campo("conteudoBolsas", this.xmlDoc);
				}
			}
			else if (tipoJSP == "busca")
			{
				escrever_campo("escreverConteudo", this.xmlDoc);
			}
			else if (tipoJSP == "minhasacoes")
			{
				escrever_campo("conteudoMinhasAcoes", this.xmlHttp.responseText);
				if (varAcao == "formulario") {
					$('#toggleBorda').removeClass('bordaBottomRed');
					$('#toggleBorda').addClass('bordaBottom');
				} else if (varAcao == "resultado") {
					$('#toggleBorda').removeClass('bordaBottom');
					$('#toggleBorda').addClass('bordaBottomRed');
				}
			}
		}
	}
}

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_campo(id, texto) 
{
	
	
  if (!DHTML) return;
  var x = new pegarDiv(id);
  if (x.obj) 
  {
	  x.obj.innerHTML = texto;
  }
  return;
}

function buscarConteudo(e, parVoltar)
{
	tipoJSP = "busca";
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}

	if (parVoltar == "voltar")
	{
		ehVoltar = true;
		varAtivo = new pegarDiv("txtCotacao");
		varAtivo = varAtivo.obj.value;
		cot_cotacoes = new Cotacao();
		escrever_campo("escreverConteudo", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");

		escrever_campo("voltarID", "&nbsp;");
		setTimeout("cot_cotacoes.ler_xml()", 1000);
	}
	else
	{

		if (keynum == 13 || keynum == 0 || keynum == 1)
		{
			varAtivo = new pegarDiv("txtCotacao");
			varAtivo = varAtivo.obj.value;
			cot_cotacoes = new Cotacao();
			
			showPopup(true,'resultado');

			escrever_campo("escreverConteudo", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");

			escrever_campo("voltarID", "&nbsp;");
			


			setTimeout("cot_cotacoes.ler_xml()", 1000);
		}
	}
}

function abreJanela2(paramAtivo, num)
{
	layerAtivo = num;
	varAtivo = paramAtivo;
	cot_cotacoes = new Cotacao();
	escrever_campo("escreverConteudo", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");

	escrever_campo("voltarID", "&larr; Voltar");
	//mostraLayer("popUpBusca");
	setTimeout("cot_cotacoes.ler_xml()", 1000);	
}

function mostraLayer(layerCandidato)
{
	var Layer = new pegarDiv(layerCandidato);
	var LayerFundo = new pegarDiv("modal");
	var LayerGrafico = new pegarDiv("grafimg");
	var	windowHeight = screen.height;
	var	windowWidth = screen.width;
	
	if (ie4)
	{
		LayerFundo.obj.style.filter = "alpha(opacity=70)";
		LayerFundo.obj.style.width = windowWidth-20;
		LayerFundo.obj.style.height = windowHeight-145;
		varTop = ((windowHeight/2) - 330);
		varLeft = ((windowWidth/2) - 250);
	}
	else
	{
		LayerFundo.obj.style.opacity = "0.7";
		LayerFundo.obj.style.width = (windowWidth-16)+"px";
		LayerFundo.obj.style.height = (windowHeight-210)+"px";
		varTop = ((windowHeight/2) - 330)+"px";
		varLeft = ((windowWidth/2) - 250)+"px";
	}

    if (Layer.obj.style.visibility == 'hidden')
	{
		window.scrollTo(0,0);
		Layer.obj.style.top = varTop;
		Layer.obj.style.left = varLeft;
		LayerFundo.obj.style.display = 'block';
	   	Layer.obj.style.display = 'block';
	   	Layer.obj.style.visibility = 'visible';
	   	LayerGrafico.obj.style.visibility = 'hidden';
	}
	else
	{
		LayerFundo.obj.style.display = 'none';
	   	Layer.obj.style.visibility='hidden';
	   	LayerGrafico.obj.style.visibility = 'visible';
	}
}

/*
* fun��es para verificar cookie e carregar o minhas a��es.
*
*/
var ativo1;
var ativo2;
var ativo3;
var ativo4;
var ativo5;

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function setCookie(name, value, expires, path) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "");
  document.cookie = curCookie;
}

function deleteCookie(name, path, domain) 
{
  if (getCookie(name)) 
  {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function getCookie(name) 
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
	
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

function checa_click(campoCheck)
{
	var cont_check_click = 0;
	if (campoCheck.checked)
	{
		if (document.form_ativos_set.hd_q10_ativo1.value == "")
		{
			document.form_ativos_set.hd_q10_ativo1.value = campoCheck.value;
		}
		else if (document.form_ativos_set.hd_q10_ativo2.value == "")
		{
			document.form_ativos_set.hd_q10_ativo2.value = campoCheck.value;
		}
		else if (document.form_ativos_set.hd_q10_ativo3.value == "")
		{
			document.form_ativos_set.hd_q10_ativo3.value = campoCheck.value;
		}
		else if (document.form_ativos_set.hd_q10_ativo4.value == "")
		{
			document.form_ativos_set.hd_q10_ativo4.value = campoCheck.value;
		}
		else if (document.form_ativos_set.hd_q10_ativo5.value == "")
		{
			document.form_ativos_set.hd_q10_ativo5.value = campoCheck.value;
		}
		else
		{
			campoCheck.checked = false;
			alert("Selecione até " + totalAtivosSelecionados + " indicadores financeiros.");
		}
	}
	else
	{
		if (document.form_ativos_set.hd_q10_ativo1.value == campoCheck.value)
		{
			document.form_ativos_set.hd_q10_ativo1.value = "";
		}
		else if (document.form_ativos_set.hd_q10_ativo2.value == campoCheck.value)
		{
			document.form_ativos_set.hd_q10_ativo2.value = "";
		}
		else if (document.form_ativos_set.hd_q10_ativo3.value == campoCheck.value)
		{
			document.form_ativos_set.hd_q10_ativo3.value = "";
		}
		else if (document.form_ativos_set.hd_q10_ativo4.value == campoCheck.value)
		{
			document.form_ativos_set.hd_q10_ativo4.value = "";
		}
		else if (document.form_ativos_set.hd_q10_ativo5.value == campoCheck.value)
		{
			document.form_ativos_set.hd_q10_ativo5.value = "";
		}
	}
}

function seta_cookie()
{
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

	deleteCookie('q10_ativo1_votorantim');
	deleteCookie('q10_ativo2_votorantim');
	deleteCookie('q10_ativo3_votorantim');
	deleteCookie('q10_ativo4_votorantim');
	deleteCookie('q10_ativo5_votorantim');

	ativo1 = document.form_ativos_set.hd_q10_ativo1.value;
	ativo2 = document.form_ativos_set.hd_q10_ativo2.value;
	ativo3 = document.form_ativos_set.hd_q10_ativo3.value;
	ativo4 = document.form_ativos_set.hd_q10_ativo4.value;
	ativo5 = document.form_ativos_set.hd_q10_ativo5.value;

	ativo1 = (ativo1 == "") ? "-x-" : ativo1;
	ativo2 = (ativo2 == "") ? "-x-" : ativo2;
	ativo3 = (ativo3 == "") ? "-x-" : ativo3;
	ativo4 = (ativo4 == "") ? "-x-" : ativo4;
	ativo5 = (ativo5 == "") ? "-x-" : ativo5;
	
	setCookie("q10_ativo1_votorantim", ativo1, now, "/");
	setCookie("q10_ativo2_votorantim", ativo2, now, "/");
	setCookie("q10_ativo3_votorantim", ativo3, now, "/");
	setCookie("q10_ativo4_votorantim", ativo4, now, "/");
	setCookie("q10_ativo5_votorantim", ativo5, now, "/");
	escrever_campo("conteudoMinhasAcoes", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");
//	escrever_campo("conteudoMinhasAcoes", "<center>Aguarde...</center>");
	checarMinhasAcoes();
}

function checa_ativos()
{
	var selecionado = false;
	var cont_check = totalAtivosSelecionados;

	var default_check = false;
	if(document.form_ativos_set.hd_q10_ativo1.value == "")
	{
		cont_check--;
	}
	
	if(document.form_ativos_set.hd_q10_ativo2.value == "")
	{
		cont_check--;
	}
	
	if(document.form_ativos_set.hd_q10_ativo3.value == "")
	{
		cont_check--;
	}
	
	if (document.form_ativos_set.hd_q10_ativo4.value == "")
	{
		cont_check--;
	}
	
	if (document.form_ativos_set.hd_q10_ativo5.value == "")
	{
		cont_check--;
	}
	
	if(cont_check > totalAtivosSelecionados || cont_check == 0)
	{
		alert("Selecione até " + totalAtivosSelecionados + " indicadores financeiros.");
	} else {



		seta_cookie();
	}
}

function checarMinhasAcoes()
{

	escrever_campo("conteudoMinhasAcoes", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");
//	escrever_campo("conteudoMinhasAcoes", "<center>Aguarde...</center>");
	VarQ10Ativo1Votorantim = getCookie("q10_ativo1_votorantim");
	VarQ10Ativo2Votorantim = getCookie("q10_ativo2_votorantim");
	VarQ10Ativo3Votorantim = getCookie("q10_ativo3_votorantim");
	VarQ10Ativo4Votorantim = getCookie("q10_ativo4_votorantim");
	VarQ10Ativo5Votorantim = getCookie("q10_ativo5_votorantim");
	
	// xmlFonte = http://192.168.2.35/votorantim/xml/votor_cotacoes.xml
	tipoJSP = "minhasacoes";
	cot_cotacoes = new Cotacao();

	if (!VarQ10Ativo1Votorantim)
	{
		varAcao = "formulario";
		setTimeout("cot_cotacoes.ler_xml()", 3000);	
		//alert("n�o possui Cookie busco o formul�rio e mostra.");
		/*
		*	n�o possui Cookie busco o formul�rio e mostra.
		*/
		// BuscarFormularioMinhasAcoes();
		$('#toggleBorda').removeClass('bordaBottomRed');
		$('#toggleBorda').addClass('bordaBottom');

	}
	else
	{
		varAcao = "resultado";
		setTimeout("cot_cotacoes.ler_xml()", 3000);	
		//alert("vou buscar resultado e mostrar.");
		/*
		*	vou buscar resultado e mostrar.
		*/
		// BuscarResultadoMinhasAcoes();
		$('#toggleBorda').removeClass('bordaBottomRed');
		$('#toggleBorda').addClass('bordaBottom');


	}
}

function personalizar()
{
	deleteCookie('q10_ativo1_votorantim');
	deleteCookie('q10_ativo2_votorantim');
	deleteCookie('q10_ativo3_votorantim');
	deleteCookie('q10_ativo4_votorantim');
	deleteCookie('q10_ativo5_votorantim');
	document.form_ativos_set.hd_q10_ativo1.value = "";
	document.form_ativos_set.hd_q10_ativo2.value = "";
	document.form_ativos_set.hd_q10_ativo3.value = "";
	document.form_ativos_set.hd_q10_ativo4.value = "";
	document.form_ativos_set.hd_q10_ativo5.value = "";
	escrever_campo("conteudoMinhasAcoes", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");
//	escrever_campo("conteudoMinhasAcoes", "<center>Aguarde...</center>");
	checarMinhasAcoes();
}

function carregarCotacoes( pArquivo) {
	
	tipoJSP = "cotacoes";
	varArquivo = pArquivo;
	if (varArquivo == "indicadores.xml") {
		escrever_campo("conteudoIndices", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");
	} else {
		escrever_campo("conteudoBolsas", "<center><img src="+contexto+"/bv/images/carregando.gif></center>");
	}
	cot_cotacoes = new Cotacao(1, 0);
	setTimeout("cot_cotacoes.ler_xml()", 3000);
	
}

function mostrarConteudo(element) {

	var avo = element.parentNode.parentNode;
	var itemClicado = false;
	
	try {
	
		for (var i = 0; i < avo.childNodes.length; i++) {
	
			// despreza o primeiro filho pq nao e do tipo abrir/fechar
			if (avo.childNodes[i].nodeName != "#text") {

				var pai = avo.childNodes[i];

				for (var j = 0; j < pai.childNodes.length; j++) {
				
					if (pai.childNodes[j].nodeName != "#text") {
					
						var neto = pai.childNodes[j];
						
						if (neto.className.indexOf("titSecao") >= 0) {
							
							itemClicado = neto.className == element.className;
							
							for (var k = 0; k < neto.childNodes.length; k++) {
								
								if (neto.childNodes[k].nodeName != "#text") {
								
									var imgNode = neto.childNodes[k];
								
									if (imgNode != null && imgNode.nodeName == "IMG") {
									
										var srcImg = imgNode.src;
										if (itemClicado) {
											if (srcImg.indexOf("icoSetaEsconde.gif") > 0) {
												imgNode.src = srcImg.replace("icoSetaEsconde.gif", "icoSetaMostra.gif");
											} else {
												imgNode.src = srcImg.replace("icoSetaMostra.gif", "icoSetaEsconde.gif");
											}
										} else {
											imgNode.src = srcImg.replace("icoSetaEsconde.gif", "icoSetaMostra.gif");
										}
									
									}
									
								}
								
							}
							
						} else {
							
							// elemento clicado
							if (itemClicado) {
								if (neto.style.display == 'block') {
									neto.style.display = 'none';
								} else {
									neto.style.display = 'block';
								}
							} else {
								neto.style.display = 'none';
							}
						
						}
		
					}
					
				}
				
			}
			
		}
	
	} catch (ex) {
		alert(ex);
	}

	var hideAcoes = document.getElementById("hideAcoes");



		if (element.id==hideAcoes.id) {

		if(navigator.appName=="Microsoft Internet Explorer") { 
		



		


			if (hideAcoes.style.background == "url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes1.gif)") {
				hideAcoes.style.background = "url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes.gif)";
			} else { hideAcoes.style.background = "url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes1.gif)"; }
			
		} else {
			if (hideAcoes.style.background == "transparent url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes1.gif) repeat scroll 0% 0%") {
				hideAcoes.style.background = "transparent url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes.gif) repeat scroll 0% 0%";

			} else { hideAcoes.style.background = "transparent url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes1.gif) repeat scroll 0% 0%"; }	

		}

	} else {
		hideAcoes.style.background = "transparent url(/web/export/sites/default/bv/images/modulo/btnacessocotacoes1.gif) repeat scroll 0% 0%";
	}

}
function mostrarMercado(){
	document.getElementById('conteudoMercado').style.display = 'block';
	document.getElementById('conteudoCotasDiarias').style.display = 'none';
	document.getElementById('conteudoProspecto').style.display = 'none';
	document.getElementById('conteudoAcoes').style.display = 'none';
}
function mostrarCotas(){
	document.getElementById('conteudoMercado').style.display = 'none';
	document.getElementById('conteudoCotasDiarias').style.display = 'block';
	document.getElementById('conteudoProspecto').style.display = 'none';
	document.getElementById('conteudoAcoes').style.display = 'none';
}
function mostrarProspecto(){
	document.getElementById('conteudoMercado').style.display = 'none';
	document.getElementById('conteudoCotasDiarias').style.display = 'none';
	document.getElementById('conteudoProspecto').style.display = 'block';
	document.getElementById('conteudoAcoes').style.display = 'none';
}
function mostrarAcoes(){
	document.getElementById('conteudoMercado').style.display = 'none';
	document.getElementById('conteudoCotasDiarias').style.display = 'none';
	document.getElementById('conteudoProspecto').style.display = 'none';
	document.getElementById('conteudoAcoes').style.display = 'block';
}
function mostrarIndices(){
	document.getElementById('boxIndices').style.display = 'block';
	document.getElementById('boxBolsas').style.display = 'none';
	carregarCotacoes('indicadores.xml');
	document.getElementById('boxIBovespa').style.display = 'none';
}
function mostrarBolsas(){
	document.getElementById('boxIndices').style.display = 'none';
	document.getElementById('boxBolsas').style.display = 'block';
	carregarCotacoes('bolsas.xml');
	document.getElementById('boxIBovespa').style.display = 'none';
}
function mostrarIBovespa(){
	document.getElementById('boxIndices').style.display = 'none';
	document.getElementById('boxBolsas').style.display = 'none';
	document.getElementById('boxIBovespa').style.display = 'block';
}