function JumpTo(form)
{
     i = form.elements[0].selectedIndex;
     if (form.elements[0].options[i].value != "")
     { window.open(form.elements[0].options[i].value, '_parent', '')
     } else exit;
}

function verifica(){
	if (document.getElementById("nome").value == ""){
		alert("Informe o seu nome.");
		document.getElementById("nome").focus();
		return false;
	} else
	if (document.getElementById("cidade").value == ""){
		alert("Informe a sua cidade.");
		document.getElementById("cidade").focus();
		return false;
	} else
	if (document.getElementById("email").value == ""){
		alert("Informe o seu email.");
		document.getElementById("email").focus();
		return false;
	} else
	if (document.getElementById("msg").value == ""){
		alert("Digite a mensagem.");
		document.getElementById("msg").focus();
		return false;
	} else
	if (document.getElementById("email").value != ""){
		email = document.getElementById("email").value;
		
		prim = email.indexOf("@");
		pont = email.lastIndexOf(".");
		if(prim < 2) {
			alert("O email informado não está correto. Corrija por favor.");
			document.getElementById("email").focus();
			return false;
		}

		if(prim > pont) {
			alert("O email informado não está correto. Corrija por favor.");
			document.getElementById("email").focus();
			return false;		
		}
		
		if(email.indexOf("@",prim + 1) != -1) {
			alert("O email informado não está correto. Corrija por favor.");
			document.getElementById("email").focus();
			return false;
		}
	
		if(email.indexOf(".") < 1) {
			alert("O email informado não está correto. Corrija por favor.");
			document.getElementById("email").focus();
			return false;
		}
	
		if(email.indexOf(" ") != -1) {
			alert("O email informado não está correto. Corrija por favor.");
			document.getElementById("email").focus();
			return false;
		}

		document.mural.submit();
		return true;
	} 
		
}

function saudacao(){
  var todaydate = new Date();
  var timeis = todaydate.getTime();
  todaydate.setTime(timeis);
  var houris = todaydate.getHours();
  if (houris > 18) display = "Boa Noite.";
  else if (houris > 12) display = "Boa Tarde.";
  else display = "Bom Dia.";
  var welcome = (display);
  document.write(welcome);
}

function data_agora(){
	hoje = new Date();

	dia = hoje.getDate();
	dias = hoje.getDay();
	mes = hoje.getMonth();
	ano = hoje.getYear();
		if (dia < 10)
			dia = "0" + dia

		if (ano < 2000)
			ano = ano + 1900


	function CriaArray (n)
	{
	this.length = n
	}
	NomeDia = new CriaArray(7)
	NomeDia[0] = "domingo"
	NomeDia[1] = "segunda-feira"
	NomeDia[2] = "terça-feira"
	NomeDia[3] = "quarta-feira"
	NomeDia[4] = "quinta-feira"
	NomeDia[5] = "sexta-feira"
	NomeDia[6] = "sábado"

	NomeMes = new CriaArray(12)
	NomeMes[0] = "janeiro"
	NomeMes[1] = "fevereiro"
	NomeMes[2] = "março"
	NomeMes[3] = "abril"
	NomeMes[4] = "maio"
	NomeMes[5] = "junho"
	NomeMes[6] = "julho"
	NomeMes[7] = "agosto"
	NomeMes[8] = "setembro"
	NomeMes[9] = "outubro"
	NomeMes[10] = "novembro"
	NomeMes[11] = "dezembro"


	document.write (NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + ano)

}

function mostraForm(){
	document.getElementById("mural").style.display='block';
	document.getElementById("mural").style.visibility='visible';
	document.getElementById("emoticons").className="normal";
//	document.getElementById("btn_enviar").className="normal";
//	document.getElementById("btn_limpar").className="normal";
	document.getElementById("btn_escrever").innerHTML='<a href="javascript: ocultaForm();"><img src="../midia/8.gif" />Ocultar</a>';
}

function ocultaForm(){
	document.getElementById("mural").style.display='none';
	document.getElementById("mural").style.visibility='hidden';
	document.getElementById("emoticons").className="trans";
//	document.getElementById("btn_enviar").className="trans";
//	document.getElementById("btn_limpar").className="trans";
	document.getElementById("btn_escrever").innerHTML='<a href="javascript: mostraForm();"><img src="../midia/8.gif" />Escrever uma mensagem</a>';
}

function smileys(clique){
	var campo = document.mural.msg;	
	var pos = campo.selectionStart;
	var len = campo.value.length;
	var novotexto = "";

	if (navigator.userAgent.indexOf("MSIE") != -1){ //IE

		novotexto = campo.value +  " "+clique+" ";

	} else { // Outros navegadores
		for(var i=0;i<pos;i++){
			novotexto += campo.value[i];
		}
		
		novotexto += " "+clique+" ";	
		for(i=pos; i<len; i++){
			novotexto += campo.value[i];
		}
	}
	
	campo.value = novotexto;
	campo.focus();
}

function visualizacao(){
	document.getElementById("visualizacao").style.display='block';
}

function visualizacao0(){
	document.getElementById("visualizacao").style.display='none';
}

//*****************************************************//
function muda(texto){
	document.getElementById("msgPronta").innerHTML = codifica(texto);
}

function codifica(texto){
	var num;
	for(i=1; i<=28; i++){
		if(i<10){
			num = '00'+i;
		} else if(i < 100)  {
			num = '0'+i;
		} else {
			num = i;
		}
		var a = '('+num+')';
		texto = texto.replace(a, '<img src="smileys/'+num+'.gif" />');
	}
	
	return texto;
}

function abreMural(){
	window.open('mural.php',"","width=778,height=600,menubar=no, scrollbars=yes, resizable=no") ;
	}
	
	var abaAtual = 'p1';
function voltar(aba){
	if(abaAtual == aba){
		document.getElementById(aba).className='dentro';
	} else {
		document.getElementById(aba).className='normal';
	}
}				
function sobre(aba){
	if(abaAtual != aba)
		document.getElementById(aba).className='abaHover';
}
function normal(p)
{
	document.getElementById("p1").className='dentro';
	document.getElementById("p2").className='dentro';
	document.getElementById("p3").className='dentro';
	document.getElementById("p4").className='dentro';
	document.getElementById("p5").className='dentro';	

	if (p != 'p1') document.getElementById("p1").className='normal';
	if (p != 'p2') document.getElementById("p2").className='normal';
	if (p != 'p3') document.getElementById("p3").className='normal';
	if (p != 'p4') document.getElementById("p4").className='normal';
	if (p != 'p5') document.getElementById("p5").className='normal';

}
function menu(elemento, secao, classe, p){
	document.getElementById(elemento).innerHTML=document.getElementById(secao).innerHTML;
	normal(p);
	abaAtual = p;
//	document.getElementById(p).className=classe;
}
function foto(secao,arquivo){
	document.getElementById("foto_"+secao).src = arquivo;
}
function mudaFotoAlbum(cat, url, data, nFotos ){
	var site = "<? echo $siteroot; ?>";
	document.fotoAlbum.src = site + cat + "/" + url + "/foto.jpg";
	document.getElementById("dataAlbum").innerHTML = data;
	document.getElementById("nFotosAlbum").innerHTML = nFotos + " fotos";
}
function chamaAjax(url,btn){
	function processGetPost(){
		var myajax=ajaxpack.ajaxobj
		if (myajax.readyState == 4){ //if request of file completed
			if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful
				if (myajax.responseText != "") {		
					document.getElementById("mainEnquete").innerHTML = myajax.responseText;
				} else {
					document.getElementById(btn).disabled = true;
				}
			}
		}
	}
	ajaxpack.getAjaxRequest(url, "", processGetPost, "txt");	
}
function votar(id,opcao,btn){
	alert("Seu voto foi computado com sucesso!");
	var url = "atualizaEnquete.php?id=" + id + "&voto=" + opcao;
	chamaAjax(url,btn);
}

function navNotas(id){
	document.getElementById("notas-content").innerHTML = document.getElementById("nota" + id).innerHTML;
	document.getElementById("btNavNotas").innerHTML = document.getElementById("btNavNota" + id).innerHTML;
}
var idNota = 1;

/*
function votarEnquete(opcao){
	alert('Seu voto foi computado com sucesso!');
	votos[opcao] ++;
	var total = 0;
	var perc = new Array();
	
	for (var i=1;i<=5;i++){
		if (votos[i] != null) total += votos[i];
	}

	if (votos[1] != null){
		perc[1] = votos[1] * 100 / total;
		document.getElementById("resultOpcao1").style.width = 	perc[1];
		document.getElementById("resultOpcao1").style.display = 'block';
		document.getElementById("resultOpcao1").innerHTML = perc[1] + "%";
	}	
	
}
*/
/*function WinOpen(url) {
   open(url,"DisplayWindow","toolbar=no,directories=no,menubar=no,status=no,height=400,width=636,scrollbars=yes");
}*/
