// JavaScript Document
var Ajax = false;
			
function AjaxRequest() {
	Ajax = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		Ajax = new XMLHttpRequest();
		if (Ajax.overrideMimeType) {
      	Ajax.overrideMimeType('text/xml');
      }
		
	} else if (window.ActiveXObject) { // IE
		try {
			Ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				Ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}		
}


function numeros(e) {
	try // Internet Explorer
	{
		var tecla = e.keyCode;
	}
	catch(y) // Nestcape
	{
		var tecla = e.which;
	}
	
	//alert(tecla);
	
	if ((tecla > 47 && tecla < 58) || (tecla > 95 && tecla < 106) || tecla == 9) // numeros de 0 a 9
	{
		return true;
	}
	else
	{
		if (tecla != 8) // backspace
		{
			//event.keyCode = 0;
			return false;
		}
		else
		{
			return true;
		}
	}
}


function numeros2(campo) {
	var pesquisa = /\D/;
	
	var valorCampo = document.getElementById(campo);
	
	if (valorCampo.value.match(pesquisa)) {
		//alert("Não use caracteres nem acentuação!");	
		valorCampo.value = "";
		valorCampo.focus();
	}
}

function testaCampoNumerico(campo) {
	
	var pesquisa = /\D/;
	
	var oCampo = document.getElementById(campo);
	
	if (oCampo.value == "") {
		oCampo.className = "fundoCampo";
		oCampo.value = "";
		return true;
	
	} else if (oCampo.value.match(pesquisa)) {
		oCampo.className = "fundoCampo";
		oCampo.value = "";
		return true;
		
	} else {
		return false;
		
	}
}		
		

function testaCampo(campo) {
	
	var oCampo = document.getElementById(campo);
	
	if (oCampo.value == "") {
		oCampo.className = "fundoCampo";
		return true;
	
	} else {
		return false;
		
	}
}


function voltaCampo(campo) {
	var oCampo = document.getElementById(campo);
	oCampo.className = "box";
}


function voltaCampo2(campo) {
	var oCampo = document.getElementById(campo);
	oCampo.className = "inputEdita";
}

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
window.attachEvent("onload", correctPNG);


function incMusica(idMusica) {
	var winMus = window.open("/bandas/discografia/openMus.asp?idMusica="+idMusica, "winMus", "width=1,height=1");
}



function excluiAgenda() {
	
	document.getElementById("acaoAG").value = "exclui";
	document.formAgenda.submit();
	
}


function abreNovoAgenda() {

	document.getElementById("txtNomeAG").value = "";
	document.getElementById("txtDiaAG").value = "";
	document.getElementById("txtMesAG").value = "";
	document.getElementById("txtAnoAG").value = "";
	document.getElementById("txtTextoAG").value = "";
	
	document.getElementById("editaAgenda").style.display = "inline";
	document.getElementById("btnExcluirAG").style.display = "none";
	document.getElementById("acaoAG").value = "cadastra";
	
}


function abreEditAgenda(idAgenda) {
	
	document.getElementById("txtNomeAG").value = "";
	document.getElementById("txtDiaAG").value = "";
	document.getElementById("txtMesAG").value = "";
	document.getElementById("txtAnoAG").value = "";
	document.getElementById("txtTextoAG").value = "";
	
	document.getElementById("editaAgenda").style.display = "inline";
	document.getElementById("btnExcluirAG").style.display = "inline";
	document.getElementById("idAgenda").value = idAgenda;
	document.getElementById("acaoAG").value = "atualiza";
	
	AjaxRequest();	
	Ajax.onreadystatechange = abreEditAgendaResposta;
	Ajax.open('GET', 'agendaAjax.asp?id='+idAgenda, true);
	Ajax.send(null);

}


function abreEditAgendaResposta() {
	var nome = document.getElementById("txtNomeAG");
	var dia = document.getElementById("txtDiaAG");
	var mes = document.getElementById("txtMesAG");
	var ano = document.getElementById("txtAnoAG");
	var texto = document.getElementById("txtTextoAG");

	if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
			var resp = Ajax.responseText;
			
			resp = resp.split(";");
			
			nome.value = resp[0];
			texto.value = resp[1];

			var data = resp[2];
			data = data.split("/");
			
			dia.value = data[0];
			mes.value = data[1];
			ano.value = data[2];
			
		} else {
			nome.value = "Erro";
		}	
	}
}


function abreFotoGrande(foto) {
	
	document.getElementById("fotoGrande").innerHTML = "<img src='/bandas/fotos/"+foto+"' />";
	document.getElementById("fotoGrande").style.display = "inline";
	document.getElementById("fecharFoto").style.display = "inline";
		
}

function fechaFotoGrande() {
	
	document.getElementById("fotoGrande").innerHTML = "";
	document.getElementById("fotoGrande").style.display = "none";
	document.getElementById("fecharFoto").style.display = "none";
		
}



var popRadio = null;

function abreRadio()
{

	if (popRadio != null) {
		if (popRadio.closed) {
			popRadio = window.open("/radio.html","radio","width=320,height=170, menubar=no,toolbar=no, resizable=no, scrollbars=no, status=no");
			
		if (popRadio == null) {
			alert("Seu navegador bloqueou o PopUp desta página! \nDesative o bloqueador de PopUps ou verifique como habilitar PopUps para esta página.");
		}
		
		} else {
			popRadio.focus();
		}		
	
	} else {
		
		popRadio = window.open("/radio.html","radio","width=320,height=170, menubar=no,toolbar=no, resizable=no, scrollbars=no, status=no");
		
		if (popRadio == null) {
			alert("Seu navegador bloqueou o PopUp desta página! \nDesative o bloqueador de PopUps ou verifique como habilitar PopUps para esta página.");
		}

		popRadio.focus();
	}
}



var popMp3 = null;

function abreMp3(id)
{

	if (popMp3 != null) {
		if (popMp3.closed) {
			popMp3 = window.open("/bandas/player.asp?id="+id,"popMp3","width=320,height=170, menubar=no,toolbar=no, resizable=no, scrollbars=no, status=no");
			
		if (popMp3 == null) {
			alert("Seu navegador bloqueou o PopUp desta página! \nDesative o bloqueador de PopUps ou verifique como habilitar PopUps para esta página.");
		}
		
		} else {
			popMp3.focus();
		}		
	
	} else {
		
		popMp3 = window.open("/bandas/player.asp?id="+id,"popMp3","width=320,height=170, menubar=no,toolbar=no, resizable=no, scrollbars=no, status=no");
		
		if (popMp3 == null) {
			alert("Seu navegador bloqueou o PopUp desta página! \nDesative o bloqueador de PopUps ou verifique como habilitar PopUps para esta página.");
		}

		popMp3.focus();
	}
}


function abreFoto(area, id) {
	var janela = window.open("/bandas/areaFoto.asp?area="+area+"&id="+id, "areaFoto", "width=300, height=250");
	janela.focus();	
}


function adicionarMp3(area, id) {
	var janela = window.open("/bandas/addMp3.asp?area="+area+"&id="+id, "addMp3", "width=300, height=250");
	janela.focus();	
}


function caracteres(e, c, n) {
	if (document.all) // Internet Explorer
	{
		var tecla = event.keyCode;
	}
	else if(document.layers) // Nestcape
	{
		var tecla = e.which;
	}
	
	
	var campo = document.getElementById(c);
	
	if (campo.value.length > n){
		if (tecla == 8 || tecla == 46) // backspace
		{
			return true;
		
		} else {
			event.keyCode = 0;
			return false;
			
		}

	} else {
		return true;
	}
}


function verificaNumAgenda() {
	
	if (document.getElementById("txtTextoAG").value.length > 101) {
		alert("Você pode digitar no máximo 100 caracteres no texto da agenda!");
	
	} else {
		document.formAgenda.submit();
	}
}