// JavaScript Document
function show(menuName) {
var el = document.getElementById(menuName);
el.style.display = 'block';
}

function hide(menuName) {
var el = document.getElementById(menuName);
el.style.display = 'none';
}
 
function AlteraDisplay( whichLayer, display ) {
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  
  if (display==null || display==undefined) {
	  // if the style.display value is blank we try to figure it out here
	  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	  else display = (vis.display==''||vis.display=='block')?'none':'block';
  }
  vis.display = display;
  
}
function swapImage( idName) {
	
	switch (idName.dir) {
	 case "ltr":	   
	   idName.src = "../style/img/ampliar.jpg";
	   idName.dir = "rtl";
	   return(false);
	case "rtl":
	   idName.src = "../style/img/reduzir.jpg";
	   idName.dir = "ltr";
	   return(false);	
	 }
}

function swapImagedark( idName) {
	
	switch (idName.dir) {
	 case "ltr":	   
	   idName.src = "../style/img/ampliar_dark.jpg";
	   idName.dir = "rtl";
	   return(false);
	case "rtl":
	   idName.src = "../style/img/reduzir_dark.jpg";
	   idName.dir = "ltr";
	   return(false);	
	 }
}




function checkMail(mail) {
	return (mail != "" 
		&& mail.indexOf("@") == mail.lastIndexOf("@")
		&& mail.indexOf("@") > 0
		&& mail.lastIndexOf(".") > mail.indexOf("@")
		&& mail.lastIndexOf(" ") == -1
	);
}
function validaSenha(f) {
	var erro="";
	var senha = f.senha.value;
	if (senha != f.senha2.value) erro += "A senha não confere com a confirmação.\n";
	if (senha.length < 5) erro += "A senha deve ter no mínimo 5 caracteres.\n";
	if (senha.length > 15) erro += "A senha deve ter no máximo 15 caracteres.\n";
	return erro;
}

function e_data(str) { // valida data
	var strArr = str.split("/");
	var ret
	return (strArr.length == 3
		&& !isNaN(strArr[0])
		&& Number(strArr[0]) >= 1
		&& Number(strArr[0]) <= 31
		&& !isNaN(strArr[1])
		&& Number(strArr[1]) >= 1
		&& Number(strArr[1]) <= 12
		&& !isNaN(strArr[2])
		&& Number(strArr[2]) >= 1900
		&& Number(strArr[2]) <= 2020 //mudar em 2020
	);
}

function GetEmbedVideo(video_chave, autor){
var url = 'GetVideo.php';
var pars = 'chave=' + video_chave;
var myAjax = new Ajax.Updater(
'youtube_player',
url,
{
method: 'get',
parameters: pars
});
}

function GetEmbedVideoWithAutor(video_chave){
var url = 'GetVideo.php';
var pars = 'autor=sim&chave=' + video_chave;
var myAjax = new Ajax.Updater(
'youtube_player',
url,
{
method: 'get',
parameters: pars
});
}


<!-- JQUERY -->
var J = jQuery.noConflict();
// J passa a ser a função básica do Jquery
J(document).ready(function() {
	
	J(".perfil_subsession h3").click( function() {
		J(this).toggleClass("fechado");
	});
		
	// WMODE NOS VÍDEOS DO YOUTUBE
	J(".video object").prepend("<param name='wmode' value='transparent'>");
	J(".video embed").attr("wmode","transparent");
	
	// ZEBRAR TABELA
	J("#tabela_resultados_interna table tbody tr:odd").addClass("alt");
	
	// MOSTRA/ESCONDE
	var titulos = J(".categorias li h3");
	J(".categorias li h3").click(function() {
        var resposta = J(this).next();
		/*alert(resposta);
        var resposta = J(this).next().attr("id");*/
		if (resposta.is(':visible')) {
			J(titulos).removeClass("aberto");
			J(resposta).slideUp("slow");
		} else {
			//J(".categorias li .lista-escolas").slideUp("slow");
			J(titulos).removeClass("aberto");
			J(resposta).slideDown("slow");
			J(this).addClass("aberto");
		}
     });
		
});


