function displayFlash(largura, altura, arquivo){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" />');
	document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" quality="best" width="'+largura+'" height="'+altura+'" name="div" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>');
	document.write('</object>');
}

function abreTopico(stNomeTr, idTr){
	var nmResults;
	nmResults = document.getElementById("nmTotalItens").value;

	if(document.getElementById(stNomeTr+idTr).style.display == ""){
		document.getElementById(stNomeTr+idTr).style.display = "none"
	}else{
		for(i = 0; i < nmResults; i++){
			if(idTr != i){
				document.getElementById(stNomeTr+i).style.display = "none";
			}else{
				document.getElementById(stNomeTr+i).style.display = "";
			}
		}
	}
	i 			= 0
	nmResults	= 0
}

function carregaCidadesAjax(stEstadoCidade){
	if(stEstadoCidade != ""){
		RunAjaxRequest('POST', '../../scripts/xml/xml_cidade_suporte.asp', 'stEstadoCidade='+stEstadoCidade, trataXmlCidade);	
	}else{
		alert("Favor escolher algum estado");	
	}
}

function trataXmlCidade(objXmlRequest){
	if(objXmlRequest.readyState == 4){
		if (objXmlRequest.status == 200){
			var stEstadoCidade;

			nmTotalResults 	= objXmlRequest.responseXML.getElementsByTagName("cidade").length
			objXml 			= objXmlRequest.responseXML
			
			listBoxCidade			 = document.getElementById("idCidadeEstado");
			listBoxCidade.disabled = false;
			listBoxCidade.options.length = 0;

			if(nmTotalResults > 0){
				listBoxCidade.disabled = false;
				listBoxCidade.options[listBoxCidade.options.length] = new Option("Todas as cidades", "");

				for(i = 0 ; i < nmTotalResults ; i++){
					idCidade    	= (objXml.getElementsByTagName("cidade")[i].getElementsByTagName("idCidade")[0].firstChild.nodeValue)
					stNomeCidade   	= (objXml.getElementsByTagName("cidade")[i].getElementsByTagName("stNomeCidade")[0].firstChild.nodeValue)
					
					listBoxCidade.options[listBoxCidade.options.length] = new Option(stNomeCidade, idCidade);
				}
			}else{
				listBoxCidade.disabled = true;
				listBoxCidade.options.length = 0;
				alert("Não existem cidades cadastradas");
			}
		}
	}
}


function fncAbrePopup(vURL, vNomeJanela, vParametros)
{ window.open( vURL, vNomeJanela, vParametros ) } 

function ChangeCountry(objForm){
	var stCountry
	stCountry = objForm.stCountry.value

	if(stCountry != ""){
		document.location.href=(stCountry)
	}
	return false;
}

function GoSearch(objForm){
	if(objForm.stBusca.value == "Buscar" || objForm.stBusca.value == "" || objForm.stBusca.value.length < 1 ){
		alert("Favor preencher o campo Busca corretamente com mais de 3 caracteres.");
		objForm.stBusca.focus();
	}else{
		objForm.action = "../Scripts/Busca/Busca.asp"
		objForm.submit();
	}
}

function ChangeCountry(objForm){
	var stDestiny;
	stDestiny = objForm.stCountry.value
	
	if(stDestiny == ""){
		alert("Favor selecionar o seu destino.");
		objForm.stCountry.focus();
		return false;
	}else{
		parent.location.href=(""+stDestiny+"")
		return false;
	}
}

function Complete(obj, evt){
	if((!obj) || (!evt) || (arrayProdutos.length == 0)){
		return;
	}

	if (obj.value.length == 0){
		return;
	}
	
	var elm = (obj.setSelectionRange) ? evt.which : evt.keyCode;
	
	if ((elm < 32) || (elm >= 33 && elm <= 46) || (elm >= 112 && elm <= 123)) {
		return;
	}
	
	var txt = obj.value.replace(/;/gi, ",");
	
	elm = txt.split(",");
	txt = elm.pop();
	txt = txt.replace(/^\s*/, "");
	
	if (txt.length == 0) {
		return;
	}
	
	if (obj.createTextRange){
		var rng = document.selection.createRange();
		if (rng.parentElement() == obj) {
			elm = rng.text;
			var ini = obj.value.lastIndexOf(elm);
		}
	}else if(obj.setSelectionRange){
		var ini = obj.selectionStart;
	}
	
	for (var i = 0; i < arrayProdutos.length; i++){
		elm = arrayProdutos[i].toString();

		if(elm.toLowerCase().indexOf(txt.toLowerCase()) == 0){
			// document.getElementById("btnBusca").disabled = false;
			obj.value += elm.substring(txt.length, elm.length);
			break;
		}
	}
	
	if(obj.createTextRange){
		rng = obj.createTextRange();
		rng.moveStart("character", ini);
		rng.moveEnd("character", obj.value.length);
		rng.select();
	}else if(obj.setSelectionRange){
		obj.setSelectionRange(ini, obj.value.length);
	}
}

function ChangeCountry(objForm){
	var stCountry
	stCountry = objForm.stCountry.value

	if(stCountry != ""){
		parent.location.href=(stCountry)
	}
	return false;
}