function CarregaDados(Url,Query,Objeto,Seq,Form)
{
	if(!Seq)
	{
		Seq=0;	
	}
	
	UrlV=Dencode(Url[Seq]);
	QueryV=Dencode(Query[Seq]);
	ObjetoV=Dencode(Objeto[Seq]);	
	
	if(Form)
	{
		QueryV=CriarQuery(Dencode(Form[Seq]))+"&"+QueryV;
	}

	try
	{
		tXHR=new XMLHttpRequest();
	}
	catch(e)
	{
		try 
		{ 
			tXHR=new ActiveXObject("Msxml2.XMLHTTP"); 
		} //activeX (IE5.5+/MSXML2+)
		catch(e) 
		{
			try
			{ 
				tXHR=new ActiveXObject("Microsoft.XMLHTTP"); 
			} //activeX (IE5+/MSXML1)
			catch(e)
			{
				tXHR=false; 
			} //O navegador não tem suporte
		}
	}

	objetoHTML=document.getElementById(ObjetoV);	
	//objetoHTML.innerHTML="<span class='carregando'>"+"Carregando...</span>"
	objetoHTML.innerHTML="<table width='100%' height='100%' border='0'><tr><td align='center' valign='middle'><p><img src='../img/loading4.gif'/><br />loading</td></tr></table>"

	tXHR.open("POST",UrlV,true);
	
	tXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	tXHR.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	tXHR.setRequestHeader("Pragma", "no-cache");

    tXHR.onreadystatechange=function()
	{	
        if (tXHR.readyState==4)
		{
			retorno=unescape(tXHR.responseText.replace(/\+/g," "));
			retorno=tXHR.responseText;
			objetoHTML.innerHTML=retorno;
			extraiScript(retorno);
			Seq+=1;			
			if(Seq<Query.length)
			{
				CarregaDados(Url,Query,Objeto,Seq,Form);
			}
        }
    }
	
	tXHR.send(QueryV);
}


function CriarQuery(form)
{
    var elements = eval(form+".elements");
    var pairs = new Array();

    for (var i = 0; i < elements.length; i++) {

        if ((name = elements[i].name) && (value = elements[i].value))
            //pairs.push(name + "=" + encodeURIComponent(value));
			pairs.push(name + "=" + escape(value));
    }
    return pairs.join("&");
}

function Encode(s)
{
	encN=1;
	s=escape(s);
	var ta=new Array();
	for(i=0;i<s.length;i++)
	{
		ta[i]=s.charCodeAt(i)+encN;
	}
	return ""+escape(eval("String.fromCharCode("+ta+")"));
}

function Dencode(s)
{
	encN=1;
	d=unescape(s);
	var tad=new Array();
	for(i=0;i<s.length;i++)
	{
		tad[i]=d.charCodeAt(i)-encN;
	}
	return ""+unescape(eval("String.fromCharCode("+tad+")"));
}

function Formulario(Url,Objeto)
{
	Login(Url,Encode(Objeto+"&Funcao=Logar"),Objeto);
	//Verifica=Login(Url,Encode(CriarQuery(Objeto)+"&Funcao=Logar"));
	/*Verifica=Verifica.substr(3,1);
	if(Verifica=='N')
	{
		CarregaDados(Array(Url),Array(Encode("Funcao=Login&MUser=1")),Array(Encode('Login')));
	}
	else
	{
		CarregaDados(Array(Url,Url),Array(Encode("Funcao=Comprar"),Encode("Funcao=Logado&"+CriarQuery(Objeto))),Array(Encode('Conteudo'),Encode('Login')));
		//CarregaDados(Url,Encode("Funcao=Logado&"+CriarQuery(Objeto)),Encode('Login'));
		Id.splice(0,Id.length);
		Qtd.splice(0,Qtd.length);
	}*/
}

function InserirMsg(Objeto,Conteudo)
{
	document.getElementById(Objeto).innerHTML=Conteudo;
}

function Login(Url,Query,Objeto)
{
	Url=Dencode(Url);
	Query=Dencode(Query);
	try
	{
		tXHR=new XMLHttpRequest();
	}
	catch(e)
	{
		try 
		{ 
			tXHR=new ActiveXObject("Msxml2.XMLHTTP"); 
		} //activeX (IE5.5+/MSXML2+)
		catch(e) 
		{
			try
			{ 
				tXHR=new ActiveXObject("Microsoft.XMLHTTP"); 
			} //activeX (IE5+/MSXML1)
			catch(e)
			{
				tXHR=false; 
			} //O navegador não tem suporte
		}
	}

	tXHR.open("POST",Url,true);
	
	tXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	tXHR.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	tXHR.setRequestHeader("Pragma", "no-cache");

    tXHR.onreadystatechange=function()
	{	
        if (tXHR.readyState==4)
		{
			retorno=unescape(tXHR.responseText.replace(" ",""));
			retorno=tXHR.responseText;
			retorno=parseInt(retorno);
			if(retorno>=1)
			{
				CarregaDados(Array(Encode(Url),Encode(Url)),Array(Encode("Funcao=Comprar&CodClienteEcommerce="+retorno+"&"),Encode("Funcao=Logado&"+Objeto)),Array(Encode('Conteudo'),Encode('Login')));																																						 
				Id.splice(0,Id.length);
				Qtd.splice(0,Qtd.length);				
			}
			else
			{
				CarregaDados(Array(Encode(Url)),Array(Encode("Funcao=Login&MUser=1&"+Objeto)),Array(Encode('Login')));
			}
        }
    }
	tXHR.send(Query);
	
}

function AbreJanelaFig(Url,larg,alt){

  altura = screen.height;
  valory = ((altura-alt)/2)-30;
  //altura = altura - 60;


  largura = screen.width;
  valorx = ((largura-larg)/2);
  //valorx = ((largura-760)/2)-15; 
  //largura = largura - 15;
//this.window.resizeTo(1,1);
//this.window.moveBy(-100,-100);
  wind=open(Url,"","top="+valory+",left="+valorx+",type=fullWindow,resizable=no,maximized=yes,screenX="+larg+",screenY="+alt+",scrollbars=1,resizable=0,toolbar=0,statusbar=0,status=0,WIDTH="+(larg+20)+",HEIGHT="+(alt+25)); 
}

var ObjMenu="";
function MenuItem(Objeto)
{
	document.getElementById(Objeto).style.color="#669999";
	document.getElementById(Objeto).style.fontWeight="bold";
	if(ObjMenu)
	{
		document.getElementById(ObjMenu).style.color="#000000";
		document.getElementById(ObjMenu).style.fontWeight="normal";
	}
	ObjMenu=Objeto;
}

function treeview(_parent)
{
	this.id = _parent;
	this.idGen = 0;

	this.add = function(_texto, _link, _target, _nodePai)
	{
		this.idGen++;
		noh = document.createElement("DIV");
		noh.id = this.id + '_divNodes' + this.idGen;
		noh.className = 'node';                

		if (_nodePai == null)
		{
			document.getElementById(this.id).appendChild(noh);
		}
		else
		{
		   nodePai = document.getElementById(_nodePai);
		   nodePai.appendChild(noh);

		   if ((nodePai.className != "nodeFechado") && (nodePai.className != "nodeAberto"))
		   {
			   nodePai.className = "nodeFechado";
		   }

		   var paiIdGen = nodePai.id.substring(this.id.length + 9);
		   nodePaiLk = document.getElementById(this.id + '_divLinks' + paiIdGen);
		   var linkNId = this.id + '_divLinkNodes' + paiIdGen;
		   if (document.getElementById(linkNId) == undefined)
		   {
			   linkN = document.createElement("A");
			   linkN.id = linkNId;
			   linkN.className = "linkAbreFechaNode";
			   linkN.href = "javascript:openNode('" + nodePai.id + "');";
			   nodePai.insertBefore(linkN, nodePaiLk);
		   }
		}

		nohText = document.createElement("A");
		var idLink = this.id + '_divLinks' + this.idGen
		nohText.id = idLink;
		nohText.innerHTML = _texto;

		//nohText.href = _link;

		nohText.target = _target;

		//document.getElementById(noh.id).appendChild(nohText);                

		//------------------------------------------------

		if (document.getElementById(linkNId) == undefined)
		{
				   nohText.href = "javascript:openNode('" + noh.id + "');";
		}
		else
		{
				   nohText.href = _link;
		}
		document.getElementById(noh.id).appendChild(nohText);

		//------------------------------------------------

		adicionaEvento(document.getElementById(nohText.id), function() { ativaNodeClicado(idLink); }, 'click');
		return noh.id;
	}
}



function openNode(_node){

	_noh = document.getElementById(_node);

	if (_noh.className == "nodeAberto"){

				_noh.className = "nodeFechado";

	}else{

				_noh.className = "nodeAberto";

	}

}

 

var nodeAtivo = "";

 

function ativaNodeClicado(objeto){

            if (nodeAtivo != ""){

                        document.getElementById(nodeAtivo).className = "";

                        nodeAtivo = "";

            }

 

            elem = document.getElementById(objeto);

            elem.className = "nodeAtivo";

            nodeAtivo = elem.id;

}

 

function adicionaEvento(objeto, funcao, evento){

            if (window.addEventListener){

                        objeto.addEventListener(evento, funcao, true);

            }else if (window.attachEvent){

                        objeto.attachEvent('on'+evento,funcao);

            }

}

function extraiScript(texto){
    // inicializa o inicio ><
    var ini = 0;
    // loop enquanto achar um script
    while (ini!=-1){
        // procura uma tag de script
        ini = texto.indexOf('<script', ini);
        // se encontrar
        if (ini >=0){
            // define o inicio para depois do fechamento dessa tag
            ini = texto.indexOf('>', ini) + 1;
            // procura o final do script
            var fim = texto.indexOf('</script>', ini);
            // extrai apenas o script
            codigo = texto.substring(ini,fim);
            // executa o script
            eval(codigo);
        }
    }
}

function MenuInterno(VarId)
{
	if(!document.all)
	{
		return;
	}
	if (event.srcElement.id==VarId) 
	{
		var srcIndex = event.srcElement.sourceIndex;
		var nested = document.all[srcIndex+1];
		if (nested.style.display=="none") 
		{
		nested.style.display='';
		event.srcElement.style.listStyleImage="url(../img/pastaa.gif)";
		}
	    else
		{
		nested.style.display="none";
		event.srcElement.style.listStyleImage="url(../img/pastaf.gif)";
    	}
	}
}

IdMenu="";
function Ativa(VarId)
{
	if(VarId)
	{
		document.getElementById(VarId).className="MAtiva";
		if(IdMenu)
		{
			document.getElementById(IdMenu).className="MDesativa";
			IdMenu=VarId;
		}
		else
		{
			IdMenu=VarId;	
		}
	}
}

IdMenuSite="";
function AtivaSite(VarIdSite)
{
	if(VarIdSite)
	{
		document.getElementById(VarIdSite).className="MAtivaSite";
		if(IdMenuSite)
		{
			document.getElementById(IdMenuSite).className="MDesativaSite";
			IdMenuSite=VarIdSite;
		}
		else
		{
			IdMenuSite=VarIdSite;	
		}
	}
}

	function MontaNivel(a,b)
	{
		if(document.getElementById(a).className=="Ativa")
		{
			document.getElementById(a).className="Inativo";
			document.getElementById(b).className="LInativo";
		}
		else
		{
			document.getElementById(a).className="Ativa";
			document.getElementById(b).className="LAtiva";
		}
		/*alert(document.getElementById(a).className);*/
	}

sfHover = function() {
	var sfEls = document.getElementById("lec").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}

function FadeIn(Objeto,Inicio,Fim,Velocidade) 
{ 
	if (Inicio <= Fim) 
	{ 
		Inicio+=Velocidade; 
		document.getElementById(Objeto).style.filter="Alpha(Opacity="+Inicio+")"; 
		setTimeout("FadeIn('"+Objeto+"',"+Inicio+","+Fim+","+Velocidade+")",30);
	} 		
} 
 
function TransicaoIn(Objeto,Inicio,Fim,Velocidade) 
{ 
	if (Inicio <= Fim) 
	{ 
		Inicio+=Velocidade; 
		document.getElementById(Objeto).style.height=Inicio; 
	} 
	setTimeout("TransicaoIn('"+Objeto+"',"+Inicio+","+Fim+","+Velocidade+")",30);
}

function Mouse(codigo) 
{
	if(codigo>1)
	{
		alert("Botão direito desabilitado!!!");
	}
}


