//FUNCOES PARA REPETIR NO SITE TODO
//valida formulario newsletter
function verificaNews(form,tipo){
	document.getElementById('acao').value = tipo;
	var email = form.email.value;
    if((email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(email == '::Digite seu e-mail::')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
}
function verificaEmail(newsletter,tipo){
	document.getElementById('acao').value = tipo;
	if(newsletter.email.value == ""){
		alert("Atenção!\nO campo EMAIL deve ser preenchido!");
		newsletter.email.focus();
		return false;
	}
	if(newsletter.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nVocê não preencheu o campo EMAIL corretamente!");
		newsletter.email.focus();
		return false;
	}
	return true;
}
//valida busca
function ValidaForm_Login(form){
	if(form.lnome.value.length<=1){
		alert("O campo Login deve estar preenchido corretamente.");
		form.lnome.focus();
		return false;
	}
	if(form.lsenha.value.length<=1){
		alert("O campo Senha deve estar preenchido corretamente.");
		form.lsenha.focus();
		return false;
	}
}
//valida busca
function ValidaForm_Busca(form){
	if(form.tipo_imovel.value.length<=1 && form.preco.value.length<=1 && form.codigo_imovel.value.length<=1 && form.localizacao.value.length<=1){
		alert("O formulário de Busca deve estar com pelo menos um campo preenchido.");
		return false;
	}
}
//FUNCAO PRINCIPAL DE TARGET
function fnTarget(str_target){
	//declaracao de variaveis
	var ch_tag_A, vet_A, int_i;
	var str_titulo;
	//pega todos os <a> da pagina e percorre um por um para achar o rel="external"
    ch_tag_A = document.getElementsByTagName('a');
    for(int_i=0; int_i<ch_tag_A.length; int_i++){
		vet_A = ch_tag_A[int_i];
		if(vet_A.getAttribute("href") && vet_A.getAttribute('rel') != null){
			if(vet_A.getAttribute('rel').substring(0,8) == 'external'){
				vet_A.target = str_target;
				str_titulo = ch_tag_A.title;
				ch_tag_A.title = str_titulo;
			}
		}
	}
}
//Funcao Adiciona a Favoritos
function fnAdicionaFavoritos(){
	str_titulo = ':: L&C Fazendas ::';
	str_url = "http://www.lcfazendas.com.br";
	try{ if(window.external){window.external.AddFavorite(str_url,str_titulo); } }
	catch(e){
		try{ if(window.sidebar){ window.sidebar.addPanel(str_titulo,str_url,""); } }
		catch(ee){ if(window.opera && window.print){ return true; } }
	}
}
//Funcao para Abrir Pop Up
function MM_openBrWindow(theURL,winName,features){
	var myWin = window.open(theURL,winName,features);
	myWin.focus();
}
function fnMostraOculta(pId){
	if(document.getElementById(pId).style.display == 'block'){ document.getElementById(pId).style.display='none'; }
	else{ document.getElementById(pId).style.display='block'; }
}
/*ICONES*/
function linkOn(ico,txt){
	document.getElementById(ico).src = 'imagens/'+ico+'.jpg';
	document.getElementById('padrao').style.display = 'none';
	document.getElementById(txt).style.display = '';
}
function linkOff(ico,txt){
	document.getElementById(ico).src = 'imagens/'+ico+'.jpg';
	document.getElementById(txt).style.display = 'none';
	document.getElementById('padrao').style.display = '';
}
function fnFlash(str_url,int_largura,int_altura){
	document.writeln('<object type="application/x-shockwave-flash" data="'+str_url+'" width="'+int_largura+'" height="'+int_altura+'">');
	document.writeln('<param name="movie" value="'+str_url+'">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}
function mostra(campo){ document.getElementById(campo).style.display=''; }
function oculta(campo){ document.getElementById(campo).style.display='none'; }
//funcao para o (mostrar e ocultar)
function onOff(id){
	esconder = (document.getElementById(id).style.display == 'block');
	/*if ( visivel == "" || visivel == "none" ) { document.getElementById(id).style.display = "block" }
	else{ document.getElementById(id).style.display = "none"; }*/
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if(_div.className == 'titulo'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}