var contador = 0;
function rnd(){
	time = 5000;
	var imagens = 
		new Array(
			"../img/bannerGospelGoods.jpg", //primeira imagem
			"../img/banner_Brisa_YouTube.jpg",
			"../img/banner_melhordogospel.jpg",
			"../img/banner_plantaoGospel.jpg",
			"../img/banner_buscaMP3.jpg",
			"../img/banner_gospelcifras.jpg",
			"../img/banner_Brisa_YouTube.jpg"
			
		);
	var url = 
		new Array(
			"http://www.gospelgoods.com.br/produto.php?prod=28", //link da primeira imagem
			"http://www.youtube.com/watch?v=0BrlU99Yv0Q",
			"http://www.omelhordogospel.com/Entrevistas/supernovavida_050607.htm",
			"http://www.redegenesis.com.br",
			"http://www.buscamp3.com.br/artists_profile_homebr.asp?id=12139",
			"http://www.gospelcifras.com",
			"http://www.youtube.com/watch?v=0BrlU99Yv0Q"
		);
		
	if (contador == imagens.length){
		contador = 0;
	}
	
	document.getElementById("imagem").innerHTML = "<a href='" + url[contador] + "' target='_blank'><img src='" + imagens[contador] + "' alt='SUPERNOVAVIDA' border='0'/></a>";
	contador++;
	setTimeout("rnd()", time);
}

function mostraFlash(nome,largura,altura,endereco){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+largura+'" height="'+altura+'" id="'+nome+'" align="top">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="allowFullScreen" value="false" />');
		document.write('<param name="movie" value="'+endereco+nome+'.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="scale" value="noborder" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="bgcolor" value="#000000" />');
		document.write('<embed src="'+endereco+nome+'" quality="high" scale="noborder" wmode="transparent" bgcolor="#000000" width="'+largura+'" height="'+altura+'" name="'+nome+'" align="top" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

// mostra detalhamento agenda
function detalheAgenda(id, arq){
	var urlDet = arq+".jsp";
	if(window.ActiveXObject) // IE 
		req = new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest) // nao IE
		req = new XMLHttpRequest();
		
	req.onreadystatechange = function() {
		if(req.readyState == 1){
			document.getElementById(id).innerHTML = "<img src='../img/spinner.gif' border='0'/> carregando...";
		}
		if(req.readyState == 4){
			var detalheImg = document.getElementById(id);
			detalheImg.innerHTML  = req.responseText;
			detalheImg.style.display='';
		}
	}
										
	req.open("POST", urlDet, true);
	req.send(null);
}

// mostra conteudo arquivo
function abrirDetalhe(img, id){
	var urlDet = "detalheImagem.jsp?img="+img;
	if(window.ActiveXObject) // IE 
		req = new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest) // nao IE
		req = new XMLHttpRequest();
		
		req.onreadystatechange = function() {
			if(req.readyState == 1){
				document.getElementById(id).innerHTML = "<img src='../img/spinner.gif' border='0'/> carregando...";
			}
			if(req.readyState == 4){
				var detalheImg = document.getElementById(id);
				detalheImg.innerHTML  = req.responseText;
				detalheImg.style.display='';
			}
		}											
	req.open("POST", urlDet, true);
	req.send(null);
}
// esconder conteudo arquivo
function fecharDetalhe(id){
	var detalheImg = document.getElementById(id);
	detalheImg.innerHTML  = req.responseText;
	detalheImg.style.display='none';
}

// Mostrar ou esconder elementos ID - substitui a função mostraOculta
function ShowHide( ref, idImg, imagemOriginal, imagemNova ) {
   	var expand = document.getElementById(ref);
   	//var inner = document.getElementById('x'+ref);
	
   	if (expand.style.display =='none') {
      //inner.innerHTML = '<b>Esconder</b>';
      document.getElementById(idImg).src = imagemNova;		      
      expand.style.display ='';
   	}else{
      //inner.innerHTML = '<b>Mostrar</b>';
      document.getElementById(idImg).src = imagemOriginal;
      expand.style.display ='none';
   }   
}

function SaltaCampo(campo,campo2,tammax){
	var vr = document.forms[formulario].elements[campo].value;
	var tam = vr.length;	
	if ( tam == tammax ){
		document.forms[formulario].elements[campo2].focus();
	}
}

function abrir(URL) {
	var width = 500;
	var height = 300;

	var left = 200;
	var top = 200;

	window.openc(URL,'Aguarde', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function popupCenter(url,largura,altura,scroll) {
	var Objetos = new Object();
	
	var w=screen.width, h=screen.height;
	if (document.all) {
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var left = Math.round((w-largura)/2), top = Math.round((h-altura)/2);
	window.open(url,"info","left=" + left + ",top=" + top + ",width=" + largura + ",height=" + altura + ",scrollbars="+scroll+",resizable=no");
}


function openCenter(URL, S, W, H) { // abrir janela popup centralizada
	// URL --> seta o popup a ser aberto
	// W = width --> seta a largura do popup
	// H = height --> seta a altura do popup
	// S = Scrollbars --> parâmetros auto, yes, no
	var URL, W, H, S;
	if (document.all)
	var xMax = screen.width, yMax = screen.height;
		else
	if (document.layers)
		var xMax = window.outerWidth, yMax = window.outerHeight;
		else
	var xMax = 640, yMax = 480;
	var xOffset = (xMax - 200)/3, yOffset = (yMax - 200)/3;
	window.open(URL, 'windowbis', 'scrollbars=' + S + ',width=' + W + ',height='+ H +',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function fechar(){
	window.close();
}

function chamaLink(url){
	document.getElementById("moldura").src=url;
}

// função que o select redireciona um link para uma determinada página
function menu(formulario, campo){
	var selecao = document.forms[formulario].elements[campo]; 
	if (selecao.selectedIndex != 0){
		var result = (selecao.options[selecao.selectedIndex].value);
		self.location.href = result;
	}  
}

function validaValor(formulario, campo, id, msg){			
	valor = document.forms[formulario].elements[campo].value;
	if (valor != ""){
		document.getElementById(id).innerText=valor;
		mostraOculta('pesqNum', true);
		return true;
	}else{
		alert(msg);
		return false;
	}
}

function enviaDados(formulario, url) {
	document.forms[formulario].action=url;
	document.forms[formulario].submit();
}

function mover(select1, select2){ // transporte de valores de um select multiplo para outro
	index = select1.selectedIndex;
	if(index >= 0){
		var valor = select1.options[index].value;
		var descricao = select1.options[index].text;
		select2.options[select2.length] = new Option(descricao, valor, false, false);
		select1.options[index] = null;
	}else
		alert("Mensagem !!!");
}

var mostrar = false;

function mostraOculta(id, condicao){
	if (id != null && id != ""){
		if (condicao != null){
			if(condicao){
				mostrar = true;
			}else{
				mostrar = false;
			}
		}else{
			if(mostrar){
				mostrar = false;
			}else{
				mostrar = true;
			}
		}
		document.getElementById(id).style.display = mostrar ? '' : 'none';
	}
}

function validaCampo(formulario, campo, url, msg) {
	if (document.forms[formulario].elements[campo].value != ""){
		document.forms[formulario].action=url;
		return true;
	}else{
		alert(msg);
		return false;
	}
}

function opcoes(formulario, campo, id) {
	if (document.forms[formulario].elements[campo][0].checked){
		mostraOculta(id, true);
	}else{
		mostraOculta(id, false);
	}
}

function carregaDados(formulario, campo, id) {
	var valor = document.forms[formulario].elements[campo].value;
	if (valor != ""){
		opener.document.getElementById(id).style.display='';
		opener.document.forms["formOutraPagina"].elements["inputOutraPagina"].value=valor; // abre as informacoes digitadas na outra página
		window.close();
		return true;
	}else{
		alert('Favor digitar uma descrição!');
		return false;
	}
}

function ImgRand() {
	var now = new Date();
	var seg = now.getSeconds();
	var str = "";
	var url = "";
	var strings = 
		new Array(
			"/pre/FotosPremiacao_Abr2004/158x87/14.jpg", //primeira imagem
			"/pre/FotosPremiacao_Abr2004/158x87/18.jpg"
		);
		
	var stringsUrl = 
		new Array(
			"/APPS/pre/premiacao.jsp", //link da primeira imagem
			"/APPS/pre/premiacao.jsp"
		);

	var qtdTotal = strings.length;
	var qtd = seg % qtdTotal;

	for(i = 0; i < strings.length; i++){
		if(qtd == i){
			str=strings[i];
			url=stringsUrl[i];
		}
	}

	document.write('<a  href=\"' + url + '\" class="" target="_self"><img src="'+str+'" width="158" height="87" align="left" border="0" alt="Fotos Randômicas de determidado evento"></a>');
}

function mostraObj(){
	var args = new Array();
	args = mostraOcultaObjeto.arguments;
	if (args.length > 2){
		for (i = 0;  i < args.length; i++) {
			if (((i+1) % 2) == 0)
				if (eval(args[i]))
					document.getElementById(args[i -1]).style.display = '';
				else
					document.getElementById(args[i -1]).style.display = 'none';
		}
	}else {
		if (eval(args[1]))
			document.getElementById(args[0]).style.display = '';
		else
			document.getElementById(args[0]).style.display = 'none';
	}
}

function mostraOpcao(formulario, campo){
	var valor = document.forms[formulario].elements[campo].value;
	if (valor == 1)
		mostraOcultaObjeto('status', 'false', 'numero', 'false', 'dataInicial', 'false', 'gerencia', 'false');
	if (valor == 2)
		mostraOcultaObjeto('status', 'true', 'numero', 'false', 'dataInicial', 'false', 'gerencia', 'false');
	if (valor == 3)
		mostraOcultaObjeto('status', 'false', 'numero', 'true', 'dataInicial', 'false', 'gerencia', 'false');
	if (valor == 4)
		mostraOcultaObjeto('status', 'false', 'numero', 'false', 'dataInicial', 'true', 'gerencia', 'false');
	if (valor == 5)
		mostraOcultaObjeto('status', 'false', 'numero', 'false', 'dataInicial', 'false', 'gerencia', 'true');
}		

function enviaValor(formulario, campo, id, msg){			
	valor = document.forms[formulario].elements[campo].value;
	if (valor != ""){
		document.getElementById(id).innerText=valor;
		mostraOculta('pesqNum', true);
		return true;
	}else{
		alert(msg);
		return false;
	}
}

function enviaDados(formulario, url) {
	document.forms[formulario].action=url;
	document.forms[formulario].submit();
}

<!--===== Opcoes para se carregar select ==========================-->

function carregaSelect(array, formulario, select2){

	var ger = new Array();
	ger[0] = "Selecione";
	ger[1] = "DITEC-TECNOLOGIA";
	ger[2] = "DITEC/EPROJ";
	ger[3] = "DITEC/GBASE";
	ger[4] = "DITEC/GEARQ";
	ger[5] = "DITEC/GEATE";
	ger[6] = "DITEC/GEATI";
	ger[7] = "DITEC/GECAN";
	ger[8] = "DITEC/GECON";
	ger[9] = "DITEC/GEINF";
	ger[10] = "DITEC/GEPLA";
	ger[11] = "DITEC/GEPRO";
	ger[12] = "DITEC/GESIC";
	ger[13] = "DITEC/GESIN I";
	
	var div = new Array();
	div[0] = "Selecione";
	div[1] = "Planejamento e Controle";
	div[2] = "Suporte a Sistemas, N&uacute;cleos e Rede";
	div[3] = "Servi&ccedil;os e Homologa&ccedil;&atilde;o";
	div[4] = "Gerenciamento";
	div[5] = "Segmento de Consultoria";
	div[6] = "Log&iacute;stica";
	div[7] = "Gerenciamento de Produtos B&aacute;sicos I";
	div[8] = "Gerenciamento de Produtos B&aacute;sicos II";
	div[9] = "Gerenciamento de Servi&ccedil;os de Neg&oacute;cios";
	div[10] = "Ger. Serv.. Corp. Internet, Intranet, Extranet";
	div[11] = "Ger. de Servi&ccedil;os e Bases Corporativaso";
	
	var nucleo = new Array();
	nucleo[0] = "Dispositivos de Rede";
	nucleo[1] = "Gerenciamento e Intercâmbio";
	nucleo[2] = "Suporte e Monitoração a Cent.";
	nucleo[3] = "Telecom e Telefonia";

	document.forms[formulario].elements[select2].options.length=0;
	index = 0;
	if(array == 1)
		for (i=0; i < ger.length; i++){
			document.forms[formulario].elements[select2].options[index] = new Option(ger[index], index);
			index++;
		}
	if(array == 11)
		for (i=0; i < div.length; i++){
			document.forms[formulario].elements[select2].options[index] = new Option(div[index], index);
			index++;
		}
	if(array == 8)
		for (i=0; i < nucleo.length; i++){
			document.forms[formulario].elements[select2].options[index] = new Option(nucleo[index], index);
			index++;
		}

}

function mover(select1, select2){
	index = select1.selectedIndex;
	if(index >= 0){
		var valor = select1.options[index].value;
		var descricao = select1.options[index].text;
		select2.options[select2.length] = new Option(descricao, valor, false, false);
		select1.options[index] = null;
	}else
		alert("Selecione um núcleo.");
}

function enviarValores(){
	//document.forms[formulario].elements[select2];
	var x = document.forms["teste"].elements["nucleo2"];
	var nucleos = "";
	for (i=0; i<x.length; i++){
		nucleos += x.options[i].text + "\n";
	}
	alert(nucleos)
}

<!--===== Fim opcoes para se carregar select ==========================-->

function Menu(form, elemento){
	if (form.elements[elemento].selectedIndex !=0){
		var result=(form.elements[elemento].options[form.elements[elemento].selectedIndex].value);
		self.location.href=result;
	}  
}

/* Funcionamento da função Menu()
<form name="masc" method="POST" action="qualquer.jsp">
	<select size="1" name="D1" class="equipes" onChange="Menu(masc, 'D1')">
		<option>escolha aqui</option>
		<option value="discografia.htm">Discografia</option>
		<option value="agenda.htm">Agenda</option>
	</select>
</form>
*/

<!-- Funcões para visualização de álbum de fotografias -->
	function popup(imgSmall, path1, path2 ) {
			
			var path1, path2;
			var src = imgSmall.src.replace(".jpg", ".jpg");
			src = src.replace(path1, path2);
			
			document.all['imgPopupDiv'].innerHTML = '<img id="imgPopup" src="' + src + '">';
			
			setTimeout('openImage()', 2000);
		}
		
		function openImage() {
			var img = document.images['imgPopup'];
			var html = 'javascript: document.write(\'' +
				'<html>' + 
					'<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">' + 
						'<img src="' + img.src + '" onclick="window.close()" style="cursor:hand" alt="Clique na foto para fechar.">' + 
					'</body>' + 
				'</html>\')';
			
			openCenter(html, img.width, img.height);
		}
		
		function openCenter(url, W, H) { // abrir janela popup centralizada
			var W , 
				H, 
				S = 'no';
			
			if (document.all)
			var xMax = screen.width, yMax = screen.height;
				else
			if (document.layers)
				var xMax = window.outerWidth, yMax = window.outerHeight;
				else
			var xMax = 640, yMax = 480;
			var xOffset = (xMax - 200)/3, yOffset = (yMax - 200)/3;
			window.open(url, 'Popup', 'scrollbars=' + S + ',width=' + W + ',height='+ H +',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
		}
<!-- Funcões para visualização de álbum de fotografias -->		

function enviaValor(id, idFonte, txt){	
	if (txt != ""){
		document.getElementById(id).innerText=txt;
		mostraOculta(idFonte, true);
		return true;
	}else{
		alert('Pan !!!');
		return false;
	}
}
