//////////////////////////////////////////////////////////////////////////////////////////////////////////
function limpa_busca() {
	document.form_busca.palavras.value = ""
	document.form_busca.palavras.bgColor='red';
	}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function chama(div,arquivo,parametro){
	var linhatem = ajax();
	var endereco = '/v3/';
	linhatem.open('GET',endereco+arquivo+'.asp?'+parametro,true);
	
	linhatem.onreadystatechange=function()
		{ if(linhatem.readyState==1){
			//document.getElementById('wait').style.display = 'block';
			}else if(linhatem.readyState==4){
				//document.getElementById('wait').style.display = 'none';
				document.getElementById(div).innerHTML = "<iframe src="+endereco+arquivo+'.asp?'+parametro+" width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	linhatem.send(null);
}

function abre_admin(div,arquivo,parametro){
	var linhatem = ajax();
	var endereco = '/v3/admin/';
	linhatem.open('GET',endereco+arquivo+'.asp?'+parametro,true);
	
	linhatem.onreadystatechange=function()
		{ if(linhatem.readyState==1){
			//document.getElementById('wait').style.display = 'block';
			}else if(linhatem.readyState==4){
				//document.getElementById('wait').style.display = 'none';
				document.getElementById('geral2').style.display = 'none';
				document.getElementById('geral').style.display = 'block';
				document.getElementById(div).innerHTML = "<iframe src="+endereco+arquivo+'.asp?'+parametro+" width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	linhatem.send(null);
}

function fecha_admin(div,arquivo,parametro){
	var linhatem = ajax();
	var endereco = '/v3/admin/';
	linhatem.open('GET',endereco+arquivo+'.asp?'+parametro,true);
	
	linhatem.onreadystatechange=function()
		{ if(linhatem.readyState==1){
			//document.getElementById('wait').style.display = 'block';
			}else if(linhatem.readyState==4){
				//document.getElementById('wait').style.display = 'none';
				document.getElementById('geral2').style.display = 'block';
				document.getElementById('geral').style.display = 'none';
				document.getElementById(div).innerHTML = "<iframe src="+endereco+arquivo+'.asp?'+parametro+" width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	linhatem.send(null);
}

function ReplaceAllTextareas() {
                var allTextAreas = document.getElementsByTagName("textarea");
                for (var i=0; i < allTextAreas.length; i++) {
                var oFCKeditor = new FCKeditor( allTextAreas[i].name ) ;
                oFCKeditor.BasePath = "/v3/FCKeditor/" ;
                oFCKeditor.ReplaceTextarea() ;
                }
        }


function carrega_pag(id_pag){
var ajaxC = ajax();
	ajaxC.open('GET','/v3/pag.asp?pag='+id_pag,true);
	ajaxC.onreadystatechange=function()
		{
			if(ajaxC.readyState==1){
				
			}else if(ajaxC.readyState==4){
				document.getElementById('busca_resulta').innerHTML = "<iframe src='/v3/pag.asp?pag="+id_pag+"' width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	ajaxC.send(null);
}



function carrega_noticia(id_noticia){
var ajaxC = ajax();
	ajaxC.open('GET','/v3/noticia.asp?noti='+id_noticia,true);
	ajaxC.onreadystatechange=function()
		{
			if(ajaxC.readyState==1){
				
			}else if(ajaxC.readyState==4){
				document.getElementById('busca_resulta').innerHTML = ajaxC.responseText;
				texto = ajaxC.responseText;
				funExtraiScript(texto);

			}
		}
	ajaxC.send(null);
}

// Extrai tudo o que estiver entre <script> e executa
function funExtraiScript(vStrTexto){
	var vIntIni = 0;
	while (vIntIni!=-1){
		vIntIni = vStrTexto.indexOf('<script', vIntIni);
		if (vIntIni >=0){
			vIntIni = vStrTexto.indexOf('>', vIntIni) + 1;
			var vIntFim = vStrTexto.indexOf('</script>', vIntIni);
			vStrCodigo = vStrTexto.substring(vIntIni,vIntFim);
			eval(vStrCodigo);
		};
	}
}

function carrega_busca(busca){
var ajaxC = ajax();
	ajaxC.open('GET','/v3/busca_resulta.asp?'+busca,true);
	ajaxC.onreadystatechange=function()
		{
			if(ajaxC.readyState==1){
				
			}else if(ajaxC.readyState==4){
				document.getElementById('busca_resulta').innerHTML = "<iframe src='/v3/busca_resulta.asp?"+busca+"' width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	ajaxC.send(null);
}


function carrega_anuncio(anuncio){
var ajaxC = ajax();
	ajaxC.open('GET','/v3/anuncio.asp?anuncio='+anuncio,true);
	ajaxC.onreadystatechange=function()
		{
			if(ajaxC.readyState==1){
				
			}else if(ajaxC.readyState==4){
				document.getElementById('busca_resulta').innerHTML = "<iframe src='/v3/anuncio.asp?anuncio="+anuncio+"' width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>";
			}
		}
	ajaxC.send(null);
}

jQuery().ready(function() {
	// validate the comment form when it is submitted
	$("#commentForm").validate();
});

jQuery().ready(function() {
	// validate the comment form when it is submitted
	$("#form1").validate();
});
jQuery().ready(function() {
	// validate the comment form when it is submitted
	$("#contatoatibaiatem").validate();
});