// Public Monta as LIs de acordo com o aquivo XML.
function montaListaInfo()
{
    var arrInfo = new Array();
    var xmlDoc = loadXMLgeneric("/pj/Empresas/Util/xml/combo.xml")
    var xmlLength = xmlDoc.getElementsByTagName("item").length;
    
    var nome;
    var href;
    var classe;
	
    for(i = 0;i < xmlLength; i++)
    {
       if (document.all) //IE
       {
            nome    = xmlDoc.getElementsByTagName("item")[i].childNodes[0].text;
            href    = xmlDoc.getElementsByTagName("item")[i].childNodes[1].text;
            classe  = xmlDoc.getElementsByTagName("item")[i].childNodes[2].text;
       }
       else //Firefox, Mozilla, Opera, etc.
       {
            nome    = xmlDoc.getElementsByTagName("item")[i].childNodes[1].textContent;
            href    = xmlDoc.getElementsByTagName("item")[i].childNodes[3].textContent;
            classe  = xmlDoc.getElementsByTagName("item")[i].childNodes[5].textContent;
       }
		
       document.write ("<li class=" + classe + "><a href=" + href + "> " + nome + " </a></li> \n");
    }
}


// Private carrega e retorna o XML.
function loadXMLgeneric(XMLURL){

    try {
            if (window.XMLHttpRequest)  //Internet Explorer
            {
              xhttp=new XMLHttpRequest();
            }
            else
            {
              xhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
    }
    catch(e){
            try
            {
                xhttp=document.implementation.createDocument("","",null); //Firefox, Mozilla, Opera, etc.
            }
            catch(e) {alert(e.message)}
    }

    try{
            xhttp.open("GET", XMLURL, false);
            xhttp.send("");
            xmlDocList=xhttp.responseXML;
            return  xmlDocList

    }catch(e) {alert(e.message)}
}

//Public
//Limpa o input e show na Div.
function cleanShowDiv()
{
	document.getElementById('inputBusca').value = '';
	fadeIn('divComboItens');
}


/*Public*/
/*Trata os valores antes de enviar*/
function SubMit()
{
	if (document.Form1.search.value == "" )
	{
		fadeOut('divComboItens');
		document.Form1.search.value = "O que voce procura?"; 
	}
	else if (document.Form1.search.value == "O que voce procura?" )
	{
		cleanShowDiv();
	}
	else  document.Form1.submit();
}


/*  Efeitos jquery para aparecer a div */
function fadeIn(div_idIN) 
{
	$('#'+div_idIN).fadeIn('slow');
}

function fadeOut(div_idIN) 
{
	$('#'+div_idIN).fadeOut('slow');
}

