	//#### DECLARAÇÃO DE VARIAVEIS #####################################################################################################################//
	
		statusInfoRap = false;
		nomeAtualInfoRap = '';

	//#### FUNÇÃO GELEM ################################################################################################################################//

		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função tem o objetivo de ser um atalho para o comando window.document.getElementById(id).                                               //
		// Exemplo: gElem(STRING:'ID A SER UTILIZADO');                                                                                                 //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
		function gElem(id){
			var wd = window.document;
			var elemento = wd.getElementById(id);
			return elemento;
		}
		
	//#### FUNÇÃO CHANGCLASS ###########################################################################################################################//
	
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função tem o objetivo de ser um atalho para o comando de troca de Classes de stylo(CSS) via javascript.                                 //
		// Exemplo: changClass(STRING:'ELEMENTO A SER TROCADO', STRING:'CLASSE A SER APLICADA');                                                        //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function changClass(local, style){
			local.className=style;
		}
		
	//#### FUNÇÃO CHANGSTYLE ###########################################################################################################################//
	
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função tem o objetivo de ser um atalho para o comando de troca de Classes de stylo(CSS) via javascript.                                 //
		// Exemplo: changClass(STRING:'ELEMENTO A SER TROCADO', STRING:'CLASSE A SER APLICADA');                                                        //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function changVisibleTrue(id){
			document.getElementById(id).style.visibility = 'visible';
			gElem(id).style.display='';
		}
		
        function changVisibleFalse(id){
			document.getElementById(id).style.visibility = 'hidden';
			gElem(id).style.display='none';
		}

        function changBlockTrue(id){
			document.getElementById(id).style.display = '';
		}
		
		function changBlockFalse(id){
			document.getElementById(is).style.display = 'none';
		}
		
	//#### FUNÇÃO GETPOSELEM ##########################################################################################################################//

		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função captura as posições top e left de um determinado elemento e devolve um objeto com essas duas informações                         //
		// Exemplo: getPosElem(STRING:'ELEMENTO QUE TERA A POSIÇÃO CAPTURADA');                                                                         //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function getPosElem(elemID){
			var offsetTrail = gElem(elemID);
			var i = offsetLeft = offsetTop = 0;    
			while (offsetTrail || i > 1) {    
				offsetLeft += offsetTrail.offsetLeft;  
				offsetTop += offsetTrail.offsetTop;     
				offsetTrail = offsetTrail.offsetParent;   
			}    
			if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
				offsetLeft += document.body.leftMargin;    
				offsetTop += document.body.topMargin;    
			}   
			return {left:offsetLeft, top:offsetTop}; 
		}
		
	//#### FUNÇÃO TXTCBUSCA ############################################################################################################################//
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função tem o objetivo de verificar se o campo de busca não está vazio. Se ele estiver, ele coloca uma mensagem padrão para busca.       //
		// Exemplo: txtCBusca();                                                                                                                        //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function txtCBusca(){
			var msg = 'Para buscar, digite aqui o código do produto ou palavra-chave';
			var campo = gElem('ctl00$TxtBusca');
			if(campo.value.length > 0){
				campo.value = (campo.value == msg) ? '' : campo.value;
			}else{
				campo.value = msg;				
			}
		}



	//#### FUNÇÃO ALTERNARABAS #########################################################################################################################//
	
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função é responsável por alternar Abas.                                                                                                 //
		// Exemplo: alternarAbas(STRING:'ABA CLICADA', STRING:'DIV DO CONTEUDO A SER MOSTRADO', ARRAY:ARRAY DO CONJUNTO DE ABAS);                       //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
		function alternarAbas(menu, conteudo, arAbas){
			for (i=0; i < arAbas.length; i++){
				m = gElem(arAbas[i].menu);
				m.className = 'menu';
				c = gElem(arAbas[i].conteudo);
				c.style.display = 'none';
			}
			m = gElem(menu)
			m.className = 'menuSelec';
			c = gElem(conteudo);
			c.style.display = '';
    }


	//##################################################################################################################################################//	
	//#### FUNÇÃO QUE CONTROLA O CARRINHO ##############################################################################################################//

		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função é responsável pela abertura e o fechamento do carrinho de compras.                                                               //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

			function controlaCarrinho(){
			    if(gElem('carrinho') != null){
				    $('carrinho').addEvents({
					    'mouseenter': function(){
						    this.set('tween', {
							    duration: 500,
							    transition: Fx.Transitions.Sine.easeOut
						    }).tween('height', '317px');
						    gElem('icone').className = 'iconeVerm';
						    //gElem('LMenu').style.display = 'none';
					    },
					    'mouseleave': function(){
						    this.set('tween', {}).tween('height', '26px');
						    gElem('icone').className = 'iconeCinza';
						    //gElem('LMenu').style.display = '';
					    }
				    });
				 }
			}

	//##################################################################################################################################################//	
	//#### FUNÇÕES DE CONTROLE DA SOMBRA ###############################################################################################################//

		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função redimensiona o tamanho da sombra, de acordo com o tamanho da tela.                                                               //
		// Exemplo: redminSombra();                                                                                                                     //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		//#### FUNÇÃO REDMINSOMBRA ##############################################//
	
			function redminSombra(){
				var tamBody = {W:window.document.body.offsetWidth, H:window.document.body.offsetHeight};
				gElem('sombra').style.width = tamBody.W+'px';
				gElem('sombra').style.height = tamBody.H+'px';
			}
		
		//#### FUNÇÃO ABRIRSOMBRA ###############################################//
		
			function abrirSombra(){
				redminSombra();
				var sombra = $('sombra');
				sombra.fade(0.5);
			}
		
		//#### FUNÇÃO FECHARSOMBRA ##############################################//
	
			function fecharSombra(){
				$('sombra').fade(0);
				setTimeout(function(){
					gElem('sombra').style.width = '1px';
					gElem('sombra').style.height = '1px';
				}, 1000);
			}
		
	//##################################################################################################################################################//	
	//#### FUNÇÕES DE CONTROLE DO MENU LATERAL DA HOME #################################################################################################//
	
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função é responsável por ocultar a sombra sobre a tela.                                                                                 //
		// Exemplo: fecharSombra();                                                                                                                     //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		//#### FUNÇÃO ABREMENULAT ###############################################//
		
			function abreMenuLat(elemento){
				var qtd = elemento.childNodes.length;
				for(i=0; i < qtd; i++){
					if(elemento.childNodes[i].tagName == 'A'){
						elemento.childNodes[i].className = 'AOn';
					}
					if(elemento.childNodes[i].tagName == 'DIV'){
						elemento.childNodes[i].style.display='';
						i = qtd;
					}
				}
			}
			
		//#### FUNÇÃO FECHAMENULAT ##############################################//
		
			function fechaMenuLat(elemento){
				var qtd = elemento.childNodes.length;
				for(i=0; i < qtd; i++){
					if(elemento.childNodes[i].tagName == 'A'){
						elemento.childNodes[i].className = 'AOff';
					}
					if(elemento.childNodes[i].tagName == 'DIV'){
						elemento.childNodes[i].style.display='none';
						i = qtd;
					}
				}
			}
		
	/*##################################################################################################################################################//	
	//#### FUNÇÕES DE CONTROLE DO MENU SUPERIOR ########################################################################################################//
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função é responsável por ocultar a sombra sobre a tela.                                                                                 //
		// Exemplo: fecharSombra();                                                                                                                     //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		//#### FUNÇÃO MOSTRAMENUSUP #############################################//

			function abreMenuSup(DvBtID, DvMnnID){
				var tamBody = window.document.body.offsetWidth - 25;
				var tamDiv = 450;
				var distDiv = getPosElem(DvBtID).left;
				if((distDiv + tamDiv) > tamBody){
					gElem(DvMnnID).style.left = ((tamBody - tamDiv) + 25) +'px';
				}else{
					gElem(DvMnnID).style.left = distDiv +'px';
				}
				gElem(DvMnnID).style.display='';
			}
			
		//#### FUNÇÃO OCULTAMENUSUP #############################################//

			function fechaMenuSup(DvMnnID){
			    alert(DvMnnID);
				gElem(DvMnnID).style.display='none';
			}
    
    */
    
    //##################################################################################################################################################//	
    //#### FUNÇÕES DE CONTROLE DO MENU SUPERIOR ########################################################################################################//
    	
	    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    // Esta função é responsável por ocultar a sombra sobre a tela.                                                                                 //
	    // Exemplo: fecharSombra();                                                                                                                     //
	    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	    //#### FUNÇÃO MOSTRAMENUSUP #############################################//

		    function abreMenuSup(DvBt, DvMnnID, cor){
		        DvBt.focus();
			    var DvBtID = DvBt.id;
			    var tamBody = window.document.body.offsetWidth - 25;
			    var tamDiv = 450;
			    var distDiv = getPosElem(DvBtID).left;
			    if((distDiv + tamDiv) > tamBody){
				    gElem(DvMnnID).style.left = ((tamBody - tamDiv) + 25) +'px';
			    }else{
				    gElem(DvMnnID).style.left = distDiv +'px';
			    }
			    gElem(DvMnnID).style.display='';
			    var classe=DvBt.className.split("_");
			    gElem(DvBtID).className = classe[0]+'_On';
    			
		    }
    		
	    //#### FUNÇÃO OCULTAMENUSUP #############################################//

		    function fechaMenuSup(DvBt, DvMnnID, cor){
			    var DvBtID = DvBt.id;
			    gElem(DvMnnID).style.display='none';
			    var classe=DvBt.className.split("_");
			    gElem(DvBtID).className = classe[0]+'_Off';
		    }
    		    
	//##################################################################################################################################################//	
	//#### FUNÇÕES DE CONTROLE DA DIV INFORMAÇÃO RÁPIDA  ###############################################################################################//
	
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Esta função é responsável pelo funcionamento da DIV "Informações Rápidas". Ela controla o posicionamento, abertura e fachemanto da DIV.      //
		// Exemplo: inicInfoRapida(STRING:'ID DO OBJETO CLICADO');                                                                                      //
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		//#### FUNÇÃO POSINFORAPIDA #############################################//
		
			function inicInfoRapida(clicado){
				posInfoRapida(clicado);
				if(statusInfoRap == false){
					abrirSombra();
					abrirInfoRapida();
				}else{
					fecharSombra();
					fecharInfoRapida();
				}
			}
		
		//#### FUNÇÃO POSINFORAPIDA #############################################//
		
			function posInfoRapida(clicado){
				var tamBody = {W:window.document.body.offsetWidth, H:window.document.body.offsetHeight};
				gElem('DvInfoRapida').style.left = ((tamBody.W - 600) / 2) + 'px';
				gElem('DvInfoRapida').style.top = (getPosElem(clicado).top - 200) + 'px';
			}
		
		//#### FUNÇÃO REPOSINFORAPIDA ###########################################//
	
			function rePosInfoRapida(){
				var tamBody = {W:window.document.body.offsetWidth, H:window.document.body.offsetHeight};
				gElem('DvInfoRapida').style.left = ((tamBody.W - 600) / 2) + 'px';
			}

		//#### FUNÇÃO ABRIRINFORAPIDA ###########################################//
		
			function abrirInfoRapida(){
				$('DvInfoRapida').fade(1);
				statusInfoRap = true;
			}
		
		//#### FUNÇÃO FECHARINFORAPIDA ##########################################//
	
			function fecharInfoRapida(){
				$('DvInfoRapida').fade(0);
				statusInfoRap = false;
			}
		
		
	//##################################################################################################################################################//	
		
		
		
		
		
	//#### FUNÇÃO CHANGCLASS ###########################################################################################################################//
		
			function stylePresente(campo){
				
				if(campo.checked == true){
					campo.parentNode.className = 'presenteON';
				}else{
					campo.parentNode.className = 'presenteOFF';
				}

			}
		
	//#### FUNÇÃO CHANGCLASS ###########################################################################################################################//
		function ocultaMsgPresente(radio, DvMsg){
			var radioArray=radio.split(":");
			var checado = false
			
			for(i = 0; i < radioArray.length; i++){
				if(gElem(radioArray[i]).checked == true){
					checado = true;
				}
			}	
			
			gElem(DvMsg).style.display = (checado == true)? '' : 'none';
			
		}
		
	//#### FUNÇÃO CHANGCLASS ###########################################################################################################################//

		function ocultaInfoCartao(campo){	
			var tipo = gElem(campo).value.split(":");
			if(tipo[0] == 'cred'){
				gElem('infoCartao').style.display = '';
			}else{
				gElem('infoCartao').style.display = 'none';
				gElem('dadParcelas').style.display = 'none';
			}
		}
		
		function ocultaInfoParcela(){
			if(gElem('dadParcelas').style.display == 'none'){
				gElem('dadParcelas').style.display = '';
			}else{
				gElem('dadParcelas').style.display = 'none';				
			}	
		}
		
	//#### FUNÇÃO CHANGCLASS ###########################################################################################################################//
		function AbrePagina(Foto, tamx, tamy){
	        window.open(Foto,'popup'+tamx+tamy ,'resizable=no, toolbar=no, status=no, menubar=no, scrollbars=yes, width=' + tamx + ',height=' + tamy);
	    }

	//#################################################################################################################################################//
	/*#### TRASH ######################################################################################################################################//
	/*
	
	//#################################################################################################################################################*/

    //##################################*############################################################################################
	//#### FUNÇÃO LIMITA_NUMBER #####################################################################################################

		function mudaFormResultado(clicado){
			if(clicado == 'tabela'){
				changClass(gElem('tabela'), 'icoTabelaVermelho');
				changClass(gElem('lista'), 'icoListaCinza');
				changClass(gElem('resultBusca'), 'dvProdTabela');
			}else{
				changClass(gElem('lista'), 'icoListaVermelho');
				changClass(gElem('tabela'), 'icoTabelaCinza');
				changClass(gElem('resultBusca'), 'dvProdLista');
			}
		}
        
        
 function mudaComentario(indice)
{
	var comentarioResumido = document.getElementById('divResumido' + indice);
	var comentarioCompleto = document.getElementById('divCompleto' + indice);	
	
	if (comentarioResumido.style.display == 'none'){
		comentarioCompleto.style.display = 'none';
		comentarioResumido.style.display = 'block';				
	} else if (comentarioCompleto.style.display == 'none'){
		comentarioResumido.style.display = 'none';
		comentarioCompleto.style.display = 'block';
	}	
}


function KeyDownHandler(btn)
    {
        
        if (event.keyCode == 13)
        {            
            event.returnValue=false;
            event.cancel = true;           
            btn.click();
        }
    }
    
    function visualiza_boleto(order_id, numloja){

	var queryString = 'orderId=' + order_id + '&merchantid=' + numloja;
	var nomeServidor = 'mup.comercioeletronico.com.br';
	var linkBoletoRet = 'http://' + nomeServidor + '/sepsBoletoRet/' + numloja + "/prepara_pagto.asp?" + queryString;

	var pop = window.open(linkBoletoRet, 'mupboleto', 'width=650, height=500, status=yes, scrollbars=yes, resize=yes');

	return pop;

}

       function closeDivFlash(){
           obj = document.getElementById('divflashpub');
           if(obj){
                          obj.style.visibility = "hidden";
           }
       }
       
       function closeDivFlashNome(nome){
           obj = document.getElementById(nome);
           if(obj){
                          obj.style.visibility = "hidden";
           }
       }

    //###############################################################################################################################
	//#### INSERIR TAGS PARA OS NOSSOS INTERNOS #####################################################################################
    function chamaPagina(pagina, click)
    {
        pageTracker._trackPageview(click);
        window.location.href = pagina;
    }









    //###############################################################################################################################
	//#### MENU BOMFIN INICIO #######################################################################################################


		function mudaAbaMnu()
		{			
			if(gElem('menu01').style.display == 'none')
			{
				gElem('menu00').className = 'rd00Topo';
				gElem('menu01').style.display = '';
				gElem('menu02').style.display = 'none';
			}
			else
			{
				gElem('menu00').className = 'rd01Topo';
				gElem('menu01').style.display = 'none';
				gElem('menu02').style.display = '';
			}
        }
        
		function ExibeMensagem()
		{
		    var msg = 'Iniciais do produto';
		    var campo = gElem('ctl00_ContentPlaceHolder1_MenuLateralHome1_produtoTextBox');

		    if (campo.value.length > 0)
		    {
		        campo.value = (campo.value == msg) ? '' : campo.value;
		    }
		    else
		    {
		        campo.value = msg;
		    }
		}

		function txtCBusca01()
		{
		   var msg = 'Iniciais do produto';
		   var campo = gElem('ctl00_ContentPlaceHolder1_MenuLateralHome1_produtoTextBox');
           if (campo.value.length > 3 || event.keyCode == 8)
                 filtrarProdutos((campo.value == msg) ? '' : campo.value);
        }

    //#### FUNÇÃO FILTRAPRODUTOS ##############################################//
    function filtrarProdutos(valor)
    {
        var params = "{descricao:'" + valor + "'}";
        //Cria o xmlHttpRequest
        var xmlhttp = createHTTPRequst(params, "Services/ProdutoWebService.asmx/ObterProdutos");
        xmlhttp.onreadystatechange =    function()
                                        {
                                            if (xmlhttp.readyState == 4)
                                            {
                                                if(xmlhttp.status == 200)
                                                {
                                                    carregarProdutos(xmlhttp.responseText);

                                                }
                                                else
                                                {
                                                    //alert(params);
                                                    //alert(xmlhttp.responseText);
                                                    //faz algo
                                                }
                                            }
                                        }
        //Envia a requisição
        xmlhttp.send(params);
    }


    //#### FUNÇÃO CAREGAPRODUTOS ##############################################//
    function carregarProdutos(produtos)
    {
        produtos = eval('(' + produtos + ')');
        produtos = eval('(' + produtos + ')');
        
        var html = "<ul class='menu02'>";
       
        for(var indexProduto in produtos)
        {
            if(Number(indexProduto))
            {
                html += "<li><a href='DetalheProduto.aspx?cm=" + produtos[indexProduto].CodigoModelo + "'>" + produtos[indexProduto].Descricao + "</a></li>";
            }
        }
        html += "</ul>";
        gElem("listaProduto").innerHTML = html;
        
    }
    

    //#### FUNÇÃO createHTTPRequst ##############################################//
    function createHTTPRequst(params, url)
    {
        /*XMLHTTP*/
        xmlhttp = false;
        if (window.XMLHttpRequest)
        { // Mozilla, Safari,...
            xmlhttp = new XMLHttpRequest();
            if (xmlhttp.overrideMimeType)
            {
                xmlhttp.overrideMimeType('text/html');
            }
        }
        else if (window.ActiveXObject)
        { // IE
            try
            {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) 
            {
                try
                {   
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e)
                {
                }
            }
        }
        
        /*XMLHTTP*/
        xmlhttp.open("POST", url, true);

        xmlhttp.setRequestHeader("Content-type", "application/json");
        
        xmlhttp.setRequestHeader("Content-length", params.length);

        xmlhttp.setRequestHeader("Connection", "close");

        return xmlhttp;
    }
    //###############################################################################################################################
	//#### MENU BOMFIN FIM ##########################################################################################################