function elemento(obj){
	return document.getElementById(obj);
}

function destaqueServicos(id){
	if(elemento(id) != null){
		
		if(id != 'entrada'){
			elemento('entrada').style.display = 'none';
			elemento(id).style.display = 'block';
			
		}else{
			elemento('entrada').style.display = 'block';
			elemento('messenger').style.display = 'none';
			elemento('hotmail').style.display = 'none';
			elemento('spaces').style.display = 'none';
		}

	}
}

function xmlLoader(url){
    if(window.XMLHttpRequest){
        var Loader = new XMLHttpRequest();
        Loader.open("GET", url ,false);
        Loader.send(null);
        return Loader.responseXML;
    }else if(window.ActiveXObject){
        var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0");
        Loader.async = false;
        Loader.load(url);
        return Loader;
    }
}

function criaArray(rows){
	var tipo = rows[0].getElementsByTagName("tipo");
		
	for(i=0; i<tipo.length; i++){
		var aparelho = tipo[i].getElementsByTagName("aparelho");
		
		if((tipo[i].attributes[0].nodeValue).toUpperCase() == 'GSM'){
			for(j=0; j<aparelho.length; j++){
				gsmList.push(aparelho[j].attributes[0].nodeValue);
				gsmListImg.push(aparelho[j].attributes[1].nodeValue);
				gsmListServico.push(aparelho[j].getElementsByTagName("servico")[0].childNodes[0].nodeValue);
			}
		}else{
			for(j=0; j<aparelho.length; j++){
				cdmaList.push(aparelho[j].attributes[0].nodeValue);
				cdmaListImg.push(aparelho[j].attributes[1].nodeValue);
				cdmaListServico.push(aparelho[j].getElementsByTagName("servico")[0].childNodes[0].nodeValue);
			}
		}

	}
}

function montaCombo(){
	var opt_aparelhos = elemento('aparelhosList');
	opt_aparelhos.options.length = 0;
	opt_aparelhos.options[0] = new Option('Selecione...','');
	
	if(elemento('radio_gsm').checked == true){
		for(i=0; i<gsmList.length; i++){
			opt_aparelhos.options[i+1] = new Option(gsmList[i],gsmList[i]);
		}
	}else{
		for(i=0; i<cdmaList.length; i++){
			opt_aparelhos.options[i+1] = new Option(cdmaList[i],cdmaList[i]);
		}
	}
	
	if(elemento('aparelhoDetalhe') != null){
		elemento('aparelhoDetalhe').style.display = 'none';
		elemento('principal').style.display = 'block';
		elemento('xmlImagem').src = '';
	}
}

function aparelhoShow(aparelho){
	
	if(elemento('aparelhoDetalhe') != null && aparelho != ""){
		elemento('aparelhoDetalhe').style.display = 'block';
		elemento('principal').style.display = 'none';
		elemento('xmlImagem').src = '';
	}
	
	if(elemento('radio_gsm').checked == true){
		for(i=0; i<gsmList.length; i++){
			if(gsmList[i] == aparelho.value){
				elemento('xmlImagem').src = 'common/img/aparelhos/'+gsmListImg[i];
				elemento('xmlAparelho').innerHTML = gsmList[i];
				elemento('xmlServicos').innerHTML = gsmListServico[i];
				elemento('xmlImagem').alt = gsmList[i];
			}
		}
	}else{
		for(i=0; i<cdmaList.length; i++){
			if(cdmaList[i] == aparelho.value){
				elemento('xmlImagem').src = 'common/img/aparelhos/'+cdmaListImg[i];
				elemento('xmlAparelho').innerHTML = cdmaList[i];
				elemento('xmlServicos').innerHTML = cdmaListServico[i];
				elemento('xmlImagem').alt = cdmaList[i];
			}
		}
	}
	
	if(aparelho.value == ""){
		elemento('aparelhoDetalhe').style.display = 'none';
		elemento('principal').style.display = 'block';
	}
}

function menuVivo(){
	
	if(elemento('menu_itens') != null){
		if(elemento('menu_itens').style.display != 'block'){
			//elemento('menu_itens').style.display = 'block';
			$('#menu_itens').show('fast');
		}else{
			//elemento('menu_itens').style.display = 'none';
			$('#menu_itens').hide('fast');
		}
	}
}

