﻿// �2006 - R�dio Alegria- Desenvolvido por Morphe Design



// Carregamento de p�ginas

function LoadPagina(pagina, alvo, funcao)

{

	jah(pagina, alvo, funcao, 'Aguarde, carregando...');

}



function getTopo()

{

	void(document.body.scrollTop = 400);

}



// "PopUp" de DIV autom�tico na abertura do site

function showPopCapa()

{

	document.getElementById('divPopUpCapa').style.display = '';

	jah('pop_capa.php','c_div_popup_capa','','');	

}



function hidePopUpCapa()

{

	document.getElementById('divPopUpCapa').style.display = 'none';

}



// Alertas (mensagens)

function alerta(msg, obj, foco, topo)

{

	alert(msg);

	if (!foco)

		obj.focus();

	if (topo)

		document.location = '#' + topo;

	return false;

}



// Valida��o do Depoimento

function validaDepoimento()

{

	dom=document.frmDepoimento;

	

	if (dom.nome.value=="" || dom.nome.value.length<5)

	{

		alert("Preencha corretamente o campo NOME.");

		dom.nome.focus();

		return false;

	}

	

	if (dom.email.value=="")

	{

		alert("Preencha o campo EMAIL.");

		dom.email.focus();

		return false;

	}

	else

	{

		if (dom.email.value.indexOf('@')==-1)

		{

			alert("Preencha o campo EMAIL corretamente.");

			dom.email.focus();

			return false;

		}

		if (dom.email.value.indexOf('.')==-1)

		{

			alert("Preencha o campo EMAIL corretamente.");

			dom.email.focus();

			return false;

		}

	}

	

	if (dom.cidade.value=="" || dom.cidade.value.length<3)

	{

		alert("Preencha o campo CIDADE corretamente.");

		dom.cidade.focus();

		return false;

	}

	

	if (dom.estado.value==0)

	{

		alert("Selecione um ESTADO.");

		dom.estado.focus();

		return false;

	}

	

	if (dom.mensagem.value=="")

	{

		alert("Digite a sua MENSAGEM.");

		dom.estado.focus();

		return false;

	}

return true;

}



// RollBar do DIV Dias

function move(px)

{

	if (document.getElementById('dias').scrollLeft != 0)

	{

		valor=document.getElementById('dias').scrollLeft;

	}

	else

	{

		valor=0;

	}

	total=valor+px;

	document.getElementById('dias').scrollLeft = total;

}



// Contato

function enviaContato()

{

	with(document.formContato)

	{

		if (nome.value == '')

			return alerta("Informe o seu nome.", nome);

		else

		if (email.value == '')

			return alerta("Informe o seu e-mail.", email);

		else

		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)

			return alerta('Informe um e-mail v�lido.', email);

		else

		if (cidade.value == '')

			return alerta("Informe a sua cidade.", cidade);

		else

		if (estado.value == '0')

			return alerta("Selecione o seu estado.", estado, "N");

		else

		if (pais.value == '')

			return alerta("Informe o seu pa�s.", pais);

		else

		if (mensagem.value == '')

			return alerta("Preencha a mensagem.", mensagem);

		else

			return true;

	}

}



// Cadastro na promo��o

function enviaCadastroPromocao()

{

	with(document.formPromocao)

	{

		if (nome.value == '')

			return alerta("Informe o seu nome.", nome);

		else

		if (email.value == '')

			return alerta("Informe o seu e-mail.", email);

		else

		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)

			return alerta('Informe um e-mail v�lido.', email);

		else

		if (cidade.value == '')

			return alerta("Informe a sua cidade.", cidade);

		else

		if (estado.value == '')

			return alerta("Selecione o seu estado.", estado, "N");

		else

		if (endereco.value == '')

			return alerta("Informe o seu endere�o.", endereco);

		else

		if (ddd.value == '' || fone.value == '')

			return alerta("Informe o DDD e o telefone corretamente.", ddd, "N");

		else

		if (mensagem.value == '')

			return alerta("Preencha a mensagem.", mensagem);

		else

			return true;

	}

}



// Amigos da Alegria

function enviaAmigo()

{

	with(document.formAmigo)

	{

		if (nome.value == '')

			return alerta("Informe o seu nome.", nome);

		else

		if (email.value == '')

			return alerta("Informe o seu e-mail.", email);

		else

		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)

			return alerta('Informe um e-mail v�lido.', email);

		else

		if (dados_pessoais.value == '')

			return alerta("Informe seus dados pessoais.", dados_pessoais);

		else

			return true;

	}

}



// Pedidos Musicais e Recados

function enviaPedRec()

{

	with(document.formPedRec)

	{

		if (regiao[0].checked == false && regiao[1].checked == false && regiao[2].checked == false)

			return alerta("Selecione a regi�o para envio da mensagem.", regiao, "N");

		else

		if (nome.value == '')

			return alerta("Informe o seu nome.", nome);

		else

		if (email.value == '')

			return alerta("Informe o seu e-mail.", email);

		else

		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)

			return alerta('Informe um e-mail v�lido.', email);

		else

		if (cidade.value == '')

			return alerta("Informe a sua cidade.", cidade);

		else

		if (estado.value == '0')

			return alerta("Selecione o seu estado.", estado, "N");

		else

		if (pais.value == '')

			return alerta("Informe o seu pa�s.", pais);

		else

		if (mensagem.value == '')

			return alerta("Preencha a mensagem.", mensagem);

		else

			return true;

	}

}



// M�sicas + Pedidas (Top 10)

function setaPeriodoMaisPedidas(idperiodo)

{

	if (idperiodo != "0")

	{

		LoadPagina('mais_pedidas.php?idperiodo='+idperiodo,'divConteudos','getTopo');

	}

}



// Super Parada da Alegria

function setaArtistaSuperParada(numero, idartista)

{

	a1 = document.getElementById('idArtista1').value;		

	a2 = document.getElementById('idArtista2').value;		

	a3 = document.getElementById('idArtista3').value;

	m1 = document.getElementById('idMusica1').value;		

	m2 = document.getElementById('idMusica2').value;		

	m3 = document.getElementById('idMusica3').value;



	nomecampo = new String("idArtista"+numero);



	if (idartista != "0")

	{

		if (idartista == a1 || idartista == a2 || idartista == a3)

		{

			nomecombo = new String("artista"+numero);

			

			alert('Voc� j� selecionou este artista.');

			document.getElementById(nomecampo).value = '0';		

			document.getElementById(nomecombo).selectedIndex = 0;

		}

		else

		{

			document.getElementById(nomecampo).value = idartista;

			LoadPagina('super_parada_combo_musicas.php?n='+numero+'&artista='+idartista+'&m1='+m1+'&m2='+m2+'&m3='+m3,'divComboMusicas'+numero,'');

		}

	}

	else

	{

		nomecampoartista = new String("idArtista"+numero);

		nomecampomusica = new String("idMusica"+numero);

		document.getElementById(nomecampoartista).value = '0';		

		document.getElementById(nomecampomusica).value = '0';		

		

		LoadPagina('super_parada_combo_musicas.php?n='+numero+'&artista=&m1=&m2=&m3=','divComboMusicas'+numero,'');		

	}

}



function setaMusicaSuperParada(numero, idmusica)

{

	nomecampo = new String("idMusica"+numero);

	

	if (idmusica != "0")

	{

		m1 = document.getElementById('idMusica1').value;		

		m2 = document.getElementById('idMusica2').value;		

		m3 = document.getElementById('idMusica3').value;

		

		if (idmusica == m1 || idmusica == m2 || idmusica == m3)

		{

			nomecombo = new String("musica"+numero);

			

			alert('Voc� j� selecionou esta m�sica.');

			document.getElementById(nomecampo).value = '0';		

			document.getElementById(nomecombo).selectedIndex = 0;

		}

		else

		{

			document.getElementById(nomecampo).value = idmusica;

		}

	}

	else

	{

		document.getElementById(nomecampo).value = '0';		

		LoadPagina('super_parada_combo_artistas.php?n='+numero,'divComboArtistas'+numero,'');

		LoadPagina('super_parada_combo_musicas.php?n='+numero+'&artista=&m1=&m2=&m3=','divComboMusicas'+numero,'');		

	}

}



function enviaSuperParada()

{

	with(document.formSuperParada)

	{

		if (idMusica1.value == '0' || idMusica2.value == '0' || idMusica3.value == '0')

			return alerta("Voc� deve selecionar 3 m�sicas.", idMusica1, "N");

		else

		if (nome.value == '')

			return alerta("Informe o seu nome.", nome);

		else

		if (email.value == '')

			return alerta("Informe o seu e-mail.", email);

		else

		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)

			return alerta('Informe um e-mail v�lido.', email);

		else

		if (cidade.value == '')

			return alerta("Informe a sua cidade.", cidade);

		else

		if (estado.value == '0')

			return alerta("Selecione o seu estado.", estado, "N");

		else

			return true;

	}

}



//Aniversariantes

function enviaAniver()

{

	var erro = 0;

	with(document.formAniver)

	{

		if ((nome.value == "" || email.value == "" || selDia.value == "0" ||

		     selMes.value == "0" || selAno.value == "0" ||

			 cidade.value == "" || selEstado.value == "0") && erro == 0)

		{

			alert('Todos os campos s�o obrigat�rios.');

			erro = 1;

		}

		else

		if (erro == 0)

		{

			submit();

			reset();

		}

	}

}



// Not�cias - Busca

function buscarNoticias()

{

	var mes = document.getElementById('sel_mes_noticias').value;

	var ano = document.getElementById('sel_ano_noticias').value;

	

	if (mes != "" && ano != "")

	{

		LoadPagina('ultimas_noticias.php?mes='+mes+'&ano='+ano,'divConteudos','getTopo');

	}

	else

	{

		alert('Selecione o per�odo corretamente.');

	}

}



// Vou Te Contar - Busca

function buscarCuriosidades()

{

	var mes = document.getElementById('sel_mes_cur').value;

	var ano = document.getElementById('sel_ano_cur').value;

	

	if (mes != "" && ano != "")

	{

		LoadPagina('vou_te_contar.php?mes='+mes+'&ano='+ano,'divConteudos','getTopo');

	}

	else

	{

		alert('Selecione o per�odo corretamente.');

	}

}



//Limita��o de texto escrito em um lugar espec�fico

function tamanhoTexto(objeto, id, tamanhomax)

{

	if (new String(objeto.value).length > tamanhomax)

	{

		objeto.value = new String(objeto.value).substr(0, tamanhomax);

	}

	

	var restante = tamanhomax - (new String(objeto.value).length);

	document.getElementById('tdcont').innerHTML = restante+' caracteres restantes&nbsp;&nbsp;';

}



//Acessos dos Banners

function doBanner(strLink, nomeBanner)

{

	window.open('addBanner.php?nome_banner=' + escape(nomeBanner), 'iframeposts', '');

	

	if(strLink != "")

	{

		window.open(strLink, '_blank', '');

	}

}


//Valida o Envio do Form de Franquias
function enviaFranquia(){
	if(document.getElementById("strNome").value==''){
		alert('Informe o nome!');
		document.getElementById("strNome").focus();
		return false;
	}
	if(document.getElementById("strEmail").value==''){
		alert('Informe o e-mail!');
		document.getElementById("strEmail").focus();
		return false;
	}
	if(document.getElementById("strEndereco").value==''){
		alert('Informe o endere�o postal!');
		document.getElementById("strEndereco").focus();
		return false;
	}
	if(document.getElementById("intDDD").value==''){
		alert('Informe o DDD!');
		document.getElementById("intDDD").focus();
		return false;
	}
	if(document.getElementById("intTelefone").value==''){
		alert('Informe o telefone!');
		document.getElementById("intTelefone").focus();
		return false;
	}
	if(document.getElementById("strCidade").value==''){
		alert('Informe a cidade ou regi�o de interesse!');
		document.getElementById("strCidade").focus();
		return false;
	}			
}

//abre rádio aonline
	function player() {
	    var navegador = navigator.userAgent;
	    if(navegador.search("Chrome") > 0 && navegador.search("Windows NT 6")>0){
	        var altura = 231;
	    } else {
	        var altura = 211;
	    }
	    var and = "&";
	 window.open("http://streaming.fabricahost.com.br/APKBarra/player.php?cliente=radioalegria","player","height="+altura+",width=320,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
	}