//SETA O HIDDEN VOTO
function setVoto(valor,form){
	form.voto.value = valor;		
}

//RESULTADOS
function estatisticas(id){
	janela = window.open('m_enquetes/inf_estatisticas_enquete.php?id_enquete='+id,'estatistica','top=0,left=0,width=370,height=370,scrollbars=no,toolbars=no,addressbar=no');
}

//VOTA NUMA ENQUETE
function adicionarVoto(id_enquete,id){
	//id = document.fenquete.voto.value;	
	if (id != ''){
		janela = window.open('m_enquetes/inf_votar_enquete.php?id_alternativa='+id+'&id_enquete='+id_enquete,'voto','top=0,left=0,width=370,height=370,scrollbars=no,toolbars=no,addressbar=no');
	}
	else{
		alert('Escolha uma das alternativas antes de votar.');
	}
}
function mark(face,field_color,text_color)
{
	if (document.documentElement); 
	{
		face.style.backgroundColor=field_color;
		face.style.color=text_color;
	}
}
function busca(ds_busca)
{
	if( ds_busca != '' && ds_busca.length >= 3 && ds_busca != 'Palavra%20Chave' )
	{
		//alert(ds_busca);
		//alert(ds_busca.length);
		window.location= 'index.php?module=m_anuncios&pag=inf_anuncios_busca&clearcache=1&ds_busca='+ds_busca;	
	}
	else
	{
		alert('O texto de pesquisa deve conter 3 ou mais caracteres!');
	}
}

varTwo = " ";
varThree = " ";
function spaceSplit(txt){
	varTwo =  txt.value.split(' ');
	varThree = ""+varTwo+",";
	counter = 1

	while (counter <= 50)  {
		varThree =  varThree.replace(/,,/, ',');
		counter ++
	}
	txt.value = varThree.length;
	var longPhrase = (txt.value-1);
	varThree = varThree.slice (0,longPhrase);
	counter2 = 1
	while (counter2 <= 20)  {
		txt.value =  varThree.replace(/,/, ' ')
		varThree =  txt.value
		counter2 ++
	}
}
/**
 * Função que valida a busca feita pelo box de busca 
 *
 */
function validarABusca(){	
	
	var txt = new String(document.abusca.palavra_chave.value);
	
	if(txt.length < 3){
		
		alert('O texto de pesquisa deve conter 3 ou mais caracteres!');
		return false;		
	}	
	else{
		document.abusca.submit();
	}	
}

function modificaEstado(idx){
	if (idx != 1) //Não é Brasil
		document.abusca.ds_uf.disabled = true;
	else
		document.abusca.ds_uf.disabled = false;
}

function modificaUF(idx){
	if (idx != 1) //Não é Brasil
		document.anuncios.ds_uf.disabled = true;
	else
		document.anuncios.ds_uf.disabled = false;
}

function abrirSubCategorias(tipo, endereco){
	if (tipo == 's'){
		this.location = endereco;
	}
	else{
		this.location = endereco;
	}	
}