//<![CDATA[
//por antonio augusto andré silveira - gutoasp[em]hotmail.com
//(cc) Conteúdo sob licença Creative Commons
//http://creativecommons.org/licenses/by-sa/2.0/
//PAGINA PUBLICIDADE INICIO
function check_pesquisa(e) {
	var frm = getElementById('frm-pesquisa'), q = frm.elements['ptexto'];
	
	var pesquisar = frm.elements['pesquisar'], cidades   = frm.elements['pcidade'];

	var p = getValue(pesquisar), c = getValue(cidades);
	if (!p) {
		for (var i=0, n=pesquisar.length, s=''; i<n; i++)
			s += '\n- '+ getElementById('label-' + pesquisar[i].id).innerHTML;
		alert('Selecione a lista que voc� quer pesquisar:'+ s);
	}/*
	else if (!c) {
		alert('Selecione uma cidade.');
		cidades.focus();
	}*/
	else if (q.value.length<2) {
		alert('Escreva algo para pesquisar.');
		q.focus();
		return actNo(e);
	}
	else if (q.value.length>50) {
		alert('O texto pesquisado é muito grande.');
		q.focus();
		return actNo(e);
	}
	else return true;//soh pra retornar algo
	return actNo(e);
}
//PAGINA PUBLICIDADE FIM

//PAGINA CONTATO INICIO
function check_contato(e) {
	var frm=getElementById('frm-contato'),
		nome=frm.elements['nome'],
		email=frm.elements['email'],
		telefone=frm.elements['telefone']
		mensagem=frm.elements['mensagem'];

	if (nome.value.length < 2) { alert('O campo NOME não pode ser nulo.'); nome.focus(); }
	else if (!email.value.is_email()) { alert('Digite um e-mail válido!'); email.focus(); }
	else if (telefone.value && (filtra_numeros(telefone.value)).length!=10) { alert('Preencha com seu telefone\nEx.: 5130311011, tudo junto.'); telefone.focus(); }
	else if (mensagem.value.length < 2) { alert('Preencha com sua mensagem!'); mensagem.focus(); return actNo(e); }
	else return true;
	return actNo(e);
}

//PAGINA CONTATO FIM

function ie_update(){
	var o = document.getElementsByTagName("object"), i = 0, n = o.length;
	for (; i<n; i++) o[i].outerHTML = o[i].outerHTML;
}

function geral_load() {
	//if (navigator.userAgent.toLowerCase().indexOf('msie')>-1) ie_update();

	//igualar tamanho das colunas
	equal_height_collumns('esquerda,direita,meio');
	
	//ao cabecalho
	//adicionar evento para o form de pesquisa
	addEvent(getElementById('frm-pesquisa'),"submit",check_pesquisa)

	//a direita
	//adicionar evento para o form de pesquisa
	//addEvent(getElementById('frm-pesquisa'),"submit",check_pesquisa)

	if ( url.match(/(contato|fale\-conosco)\/?$/i) ) {
		//PARA O FORM
		addEvent(getElementById('frm-contato'),"submit",check_contato);		
	}
	
	//PAGINA DE CADASTRO
	if ( url.match(/(cadastro|cadastre\-se|cadastre\-se\-e\-anuncie)\/?$/i) || url.indexOf('cadastro') > -1 ) {
		cadastro_comecar();
	}
}

function geral_unload() {
	//if (url.match(/regex/i)) {}
}
addEvent(window,'DOMContentLoaded',geral_load)
addEvent(window,"unload",geral_unload)
//]]>