var pagat = 1;
var palavra = "";
function AbrePagina(perfil, tamx, tamy, yn) {
	lf = Math.floor(screen.width/2) - Math.floor(tamx/2);
	tp = Math.floor(screen.height/2) - Math.floor(tamy/2);
	window.open(perfil,"","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=" + yn + ",width=" + tamx + ",height=" + tamy + ", left = " + lf + ", top = " + tp)
}


startSz = 11;
var tgs = new Array( 'div','td','tr','a','p','font','span', 'li');
function fonte(trgt,acao) {
	size = startSz;
	switch(acao) {
		case "+" :
		if(size >= 16) {
			size = 16;
		} else {
			size++;
		}
		break;
		case "-" :
		if(size <= 11) {
			size = 11;
		} else {
			size--;
		}
		break;
	}

	startSz = size;
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	if(!(cEl = d.getElementById(trgt))) cEl = d.getElementsByTagName( trgt )[ 0 ];
	cEl.style.fontSize = size+'px';
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = startSz+'px';
	}

}

function incrementa_foto(id) {
	var lv = new LoadVars();
	lv.iid = id;

	lv.onLoad = function () {
		if(document.getElementById("aguarde")) {
			document.getElementById("aguarde").style.display = "none";
		}
	}

	lv.send("ajax.php?modelo=front_imagem","POST");
	if(document.getElementById("aguarde")) {
		document.getElementById("aguarde").innerHTML = "Aguarde!<br />Carregando Mensagens";
		document.getElementById("aguarde").style.display = "block";
	}
}

function get_flash(arquivo, largura, altura, bgcolor, id, qualidade, alinhamento,transparente) {
	var obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="'+id+'" align="'+alinhamento+'">';
	obj+= '<param name="allowScriptAccess" value="sameDomain" />';
	obj+= '<param name="movie" value="'+arquivo+'" />';
	obj+= '<param name="quality" value="'+qualidade+'" />';
	if(transparente == true) {
		obj+= '<param name="wmode" value="transparent" />';
	}
	obj+= '<param name="bgcolor" value="'+bgcolor+'" />';
	obj+= '<embed src="'+arquivo+'" '+((transparente==true)?'wmode="transparent"':'')+'" quality="'+qualidade+'" bgcolor="'+bgcolor+'" width="'+largura+'" height="'+altura+'" name="'+id+'" align="'+alinhamento+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	obj+= '</object>';
	document.write(obj);
}

function get_video(arquivo, largura, altura) {
	var obj = '<OBJECT id="VIDEO" width="'+largura+'" height="'+altura+'" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">';
	obj+= '<PARAM NAME="URL" VALUE="'+arquivo+'">';
	obj+= '<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">';
	obj+= '<PARAM NAME="AutoStart" VALUE="True">';
	obj+= '<PARAM name="enabled" value="True">';
	obj+= '<PARAM name="uiMode" value="mini">';
	obj+= '<PARAM name="PlayCount" value="9999">';
	obj+= '<embed type="application/x-mplayer2" src="'+arquivo+'" width='+largura+' height='+altura+' align="right"> </embed>';
	obj+= '</OBJECT>';
	document.write(obj);
}


function FV_close() {
	if(document.getElementById("formato5")) {
		document.getElementById("formato5").style.display = "none";
	}
}

function FV_closel() {
	if(document.getElementById("formato5")) {
		document.getElementById("formato5").style.display = "none";
	}
}

function FV_expande(xid,x,y) {
	if(document.getElementById('formato'+xid)) {
		document.getElementById('formato'+xid).style.width = x;
		document.getElementById('formato'+xid).style.height = y;
	}
}

function FV_contrai(xid,x,y) {
	if(document.getElementById('formato'+xid)) {
		document.getElementById('formato'+xid).style.width = x;
		document.getElementById('formato'+xid).style.height = y;
	}
}

function carrega_formato(formato) {
	var lv = new LoadVars();
	lv.formato = formato;

	lv.onLoad = function () {
		document.getElementById("container").innerHTML = lv.content;

		if(document.getElementById("aguarde")) {
			document.getElementById("aguarde").style.display = "none";
		}
	}

	lv.send("ajax.php?modelo=front_anuncie","POST");
	if(document.getElementById("aguarde")) {
		document.getElementById("aguarde").innerHTML = "Aguarde!<br />Carregando Mensagens";
		document.getElementById("aguarde").style.display = "block";
	}

}

function php_unescape() {
	document.body.innerHTML = document.body.innerHTML.replace( /(%u([0-9A-F]{4}))/gi, "&#x$2;");
}

function lista_noticia(pagina) {
	var lv = new LoadVars();
	lv.acao = "lista";
	lv.pagina = pagina;
	lv.cid = categoria;

	lv.onLoad = function () {
		document.getElementById("listanoticia").innerHTML = lv.content;

		if(document.getElementById("aguarde")) {
			document.getElementById("aguarde").style.display = "none";
		}
	}

	lv.send("ajax.php?modelo=front_noticia","POST");
	if(document.getElementById("aguarde")) {
		document.getElementById("aguarde").innerHTML = "Aguarde!<br />Carregando Mensagens";
		document.getElementById("aguarde").style.display = "block";
	}

}

/**
*
* AS FUNCOES ABAIXO DEPENDEM DA BIBLIOTECA LOADVARS
*
*/

function exibe_foto(fsrc, id, legenda) {
	//carrega_form_amigo(id);
	document.getElementById("foto-ampliada").innerHTML = '<img src="'+fsrc+'" name="fotoprin" >';
	document.getElementById("foto-legenda").innerHTML = legenda;

}

function lista_foto(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.acao = "listafoto";
	lv.eid = num_album;
	lv.onLoad = function () {
		document.getElementById("thumb-popup").innerHTML = lv.content;
		//pagina_foto(lv.pagina);
	}

	lv.send("ajax.php?modelo=front_evento","POST");
}

function pagina_foto(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.acao = "pagina_foto";

	lv.onLoad = function () {
		document.getElementById("paginacao").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_evento","POST");
}

function lista_projeto(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.acao = "lista_geral";
	lv.onLoad = function () {
		document.getElementById("listaprojeto").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_projeto","POST");
}

function lista_extensao(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.acao = "lista_extensao";
	lv.onLoad = function () {
		document.getElementById("listaextensao").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_projeto","POST");
}

function lista_noticia(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.acao = "lista_geral";
	lv.onLoad = function () {
		document.getElementById("listanoticia").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_noticia","POST");
}

function expandeMenu(h)
{
	var dmenu = document.getElementById("dmenu");
	dmenu.style.height=h+"px";
	//dmenu.style.height="950px";
}

function contraiMenu()
{
	var dmenu = document.getElementById("dmenu");
	dmenu.style.height="500px";
	//alert("contrai");
}

function lista_busca_curso(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.palavra = palavra;
	lv.local = "curso";
	pagat = pagina;

	lv.onLoad = function () {
		document.getElementById("listacurso").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_busca","POST");
}

function lista_busca_noticia(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.palavra = palavra;
	lv.local = "noticia";
	pagat = pagina;

	lv.onLoad = function () {
		document.getElementById("listanoticia").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_busca","POST");
}

function lista_busca_evento(pagina) {
	var lv = new LoadVars();
	lv.pagina = pagina;
	lv.palavra = palavra;
	lv.local = "evento";
	pagat = pagina;

	lv.onLoad = function () {
		document.getElementById("listaevento").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_busca","POST");
}

function carrega_resultado() {
	var lv = new LoadVars();
	lv.local = "resultado";
	lv.palavra = palavra;

	lv.onLoad = function () {
		document.getElementById("resultado").innerHTML = lv.content;
	}

	lv.send("ajax.php?modelo=front_busca","POST");
}

function resultado() {
	//lista_busca_curso(1);
	lista_busca_noticia(1);
	//lista_busca_evento(1);
	carrega_resultado();
}

function abreInstitucional()
{
	var e = document.getElementById("div_menu_institucional");
	e.style.height = "200px";
}

function fechaInstitucional()
{
	var e = document.getElementById("div_menu_institucional");
	e.style.height = "30px";
}


function carrega_calendario(mes,ano) {
	var lv = new LoadVars();
	lv.mes= mes;
	lv.ano= ano;

	lv.onLoad = function () {
		document.getElementById("calendario").innerHTML = lv.content;
		carrega_evento(lv.mes,lv.ano);
		if(document.getElementById("aguarde")) {
			document.getElementById("aguarde").style.display = "none";
		}
	}

	lv.send("ajax.php?modelo=calendario","POST");
	if(document.getElementById("aguarde")) {
		document.getElementById("aguarde").innerHTML = "Aguarde!<br />Carregando Mensagens";
		document.getElementById("aguarde").style.display = "block";
	}

}

function carrega_evento(mes,ano) {
	var lv = new LoadVars();
	lv.mes= mes;
	lv.ano= ano;

	lv.onLoad = function () {
		document.getElementById("eventos").innerHTML = lv.content.UNhtmlEntities();
		if(document.getElementById("aguarde")) {
			document.getElementById("aguarde").style.display = "none";
		}
	}

	lv.send("ajax.php?modelo=front_agenda","POST");
	if(document.getElementById("aguarde")) {
		document.getElementById("aguarde").innerHTML = "Aguarde!<br />Carregando Mensagens";
		document.getElementById("aguarde").style.display = "block";
	}

}

function limpar() {
	setTimeout('document.logonuser.reset();',1000);
}




function AbreFoto(foto, tamx, tamy) {
	lf = Math.floor(screen.width/2) - Math.floor(tamx/2);
	tp = Math.floor(screen.height/2) - Math.floor(tamy/2);
	w = open(foto,"Foto","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=no,width=" + tamx + ",height=" + tamy + ", left = " + lf + ", top = " + tp)
	w.document.open();
	w.document.write("<html><title>FAESA</title>");
	w.document.write("<body bgcolor=\"#FFFFFF\" topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">");
	w.document.write("<img src=\""+foto+"\">");
	w.document.write("</body></html>");
	w.document.close();
}

function exibe(info) {
	if(document.getElementById('box_'+info)) {
		document.getElementById('box_1').style.display = 'none';
		document.getElementById('box_2').style.display = 'none';
		document.getElementById('box_3').style.display = 'none';
		document.getElementById('box_4').style.display = 'none';

		document.getElementById('box_'+info).style.display = 'block';
	}
}

function ExibeGaleria(id) {
	if( document.getElementById('fotoZoom'+id)) {
		if(document.getElementById('fotoZoom'+id).style.display =='none')  {
			document.getElementById('fotoZoom'+id).style.display = 'block';
			document.getElementById('iframe_galeria'+id).style.display = 'block';
			document.getElementById('sombra-galeria'+id).style.display ='block';
			document.getElementById('tampa-galeria'+id).style.display ='block';
		}else{
			document.getElementById('fotoZoom'+id).style.display = 'none';
			document.getElementById('iframe_galeria'+id).style.display = 'none';
			document.getElementById('sombra-galeria'+id).style.display ='none';
			document.getElementById('tampa-galeria'+id).style.display ='none';
		}
	}
}
function exibe(id) {
	if(document.getElementById('dado'+id)) {
		if(document.getElementById('dado'+id).style.display == 'none') {
			document.getElementById('dado'+id).style.display = 'block';
		} else {
			document.getElementById('dado'+id).style.display = 'none';
		}
	}
}

function testa_parametro(){
	if(document.getElementById('rede_busca').value == ""){
		alert('Favor selecionar a Rede!');
		document.getElementById('rede_busca').focus();
		return false;
	}
	if(document.getElementById('cidades_busca').value == "" && document.getElementById('especialidades_busca').value == "" && document.getElementById('nome_busca').value == "") {
		alert('Favor selecionar Cidade, Especialidade ou Nome!');
		document.getElementById('cidades_busca').focus();
		return false;
	} else {
		document.formulario.submit();
	}
}