function doPops(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,565,"POP" ,true);}

function doFale(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,570,570,"POP" ,true);}

function doFaq(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,500,"FAQ" ,true);}



function envie_Amigo(){window.open('/rio2007/jsp/send_friend.jsp?title='+escape(titulo)+'&url='+escape(document.location),'FRIEND','width=480,height=446');}

function do_Friend(titulo){window.open('/rio2007/jsp/send_friend.jsp?title='+escape(titulo)+'&url='+escape(document.location),'FRIEND','width=520,height=500');}



function calendarioF(calendarioId, template, uf, local, site){

//site: http://www.clicrbs.com.br/planeta

var urlSite = site;

var pagina = escape(site+"/jsp/default.jsp?section=1&uf="+uf+"&local="+local+"&calendarioid="+calendarioId+"&template="+template);

document.location.href=site+"/jsp/default.jsp?section=1&uf="+uf+"&local="+local+"&template=1740.dwt&pagina_calendario="+pagina+"&urlSite="+urlSite;



}



function setCookie(sName, sValue)

{

  var date = new Date();

  document.cookie = sName + "=" + escape(sValue) + ";path=/;";

}

function logout(){

  setCookie("cdmuser", "-none");

	document.loginform.op.value = "3";

	document.loginform.action = "/servlet/LogonServlet";

	document.loginform.submit();

}

function update(){

	document.loginform.op.value = "8";

	document.loginform.nextop.value = "31";

	document.loginform.action = "/servlet/SignUpServlet";

	document.loginform.submit();

} 

function signup(){

	document.loginform.op.value = "1";

	document.loginform.nextop.value = "21";

 	document.loginform.action = "/servlet/SignUpServlet";

	document.loginform.submit();

}



function imprimir(){

   if( window.print() ) {

     return true;

   }

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



function newWindow(url){

window.open(url, "itapema","width=700,height=500,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");

}



function enviarAmigo(nome){

//	var dir = "http://www.clicrbs.com.br/atlantidafm/";

	var url = escape(document.URL);

	var site = "rio2007";  //Nome do site ex.: Planeta Atlântida

//	var evento = nome;

	var pagina = "enviar_amigo.jsp?site="+site+"&url="+url+"&title="+nome;

	MM_openBrWindow(pagina,'Calendário','width=514,height=400');

}



	function abre_janela() {

	  var user    = document.clicpapo.user.value;

	  var screen  = document.clicpapo.screen.value;

	  var room    = document.clicpapo.room.value;

	  var chatter = document.clicpapo.chatter.value;

	  user = escape(user);

	  var URL ='http://clicpapo.clicrbs.com.br/cgi-bin/inchat/inchat.pl?login=1&user='+user+'&screen='+screen+'&room='+room+'&chatter='+chatter;

	  window.open(URL,'OpenInchat','width=710,height=525,top=0,left=0');

	  return false;

	}

	

	function VerifyForm() {

	        if (document.clicpapo.user.value.length == 0) {

	               alert ("Por favor, preencha o campo 'Apelido'.");

	               return false;

	        }

		abre_janela();

		return false;

}





//Código do template 2515.dwt

function navigate(start){

   document.lista.start.value = start;

   if (start != "1"){

   	document.lista.otherpage.value="1";

   }else{

   	document.lista.otherpage.value="0";

   }

   document.lista.submit();

  }

  

//Fim do código do template 2515.dwt



//Código do template 2611.dwt

function testeemail(email)

{

posicao = email.indexOf("@");

if (posicao == -1)

	{

		return false;

	}

posicao1 = email.indexOf(".", posicao);

if (posicao1 == -1)

	{

		return false;

	}	

return true;

}



//** monta dinamicamente ano de nascimento para o fale conosco

function marcaOpcao(opcao){

	if(opcao == "1"){document.faleConosco.strTo2.selectedIndex = 0;}

	if(opcao == "2"){document.faleConosco.strTo1.selectedIndex = 0;	}

}

function SelecionaOpcao(opcao){

	if(opcao == "1"){

		marcaOpcao(opcao);

		document.faleConosco.radioEnvia[0].checked=true;

	}

	if(opcao == "2"){

		marcaOpcao(opcao);

		document.faleConosco.radioEnvia[1].checked=true;

	}

}







function birth(){

	d = new Date();

	y = d.getYear();

	document.faleConosco.strAno.length = 100;

	if (y < 2000) y+= 1900;

	for(i=0;i<100;i++) {

		document.faleConosco.strAno.options[i].value = y-i;

		document.faleConosco.strAno.options[i].text = y-i;

	}

}

//** fale com a rbs: teste de validade dos campos

function fale_com_a_rbs() {

	if (document.faleConosco.strTitulo.value=="") {

		alert("ASSUNTO não poder ser vazio!");

		document.faleConosco.strTitulo.focus();

	}

	else if (document.faleConosco.strTexto.value=="") {

		alert("TEXTO não poder ser vazio!");

		document.faleConosco.strTexto.focus();

	}

	else if (document.faleConosco.strNome.value=="") {

		alert("NOME não poder ser vazio!");

		document.faleConosco.strNome.focus();

	}

	else if (!testeemail(document.faleConosco.strEmail.value)) {

		alert("EMAIL não poder ser vazio ou endereço inválido!");

		document.faleConosco.strEmail.focus();

	}

	else if (document.faleConosco.strTo1.selectedIndex==0 && document.faleConosco.strTo2.selectedIndex==0) {

		alert(document.faleConosco.strTo1.selectedIndex);

		alert(document.faleConosco.strTo2.selectedIndex);

		alert("Deve ser selecionado um COLUNISTA");

		document.faleConosco.strTo1.focus();

	}

	else {

		document.faleConosco.submit();

	}

}

//Fim do código do template 2611.dwt	



function testa_form(email) {

testeemail(email);



}



//Código referente ao template 2652.dwt Promoção aberta



function envieAmigo(){

	var url = escape(document.URL);

	var caminho = "http://www.clicrbs.com.br/tvcom/jsp/enviar_amigo_promocoes.jsp?url="+url;

	window.open(caminho,'EnviaR','width=480,height=450');

}



function contadore(total,posicao) {

   if ( document.frm.total_frase.value > 1 ){

	   cont = document.frm.frase[(posicao-1)].value.length;

   }else{

	   cont = document.frm.frase.value.length;

   }

   var Tecla = window.event.keyCode;

   event.cancelBubble = true;

   cont++;

   if( cont >= 0 && cont <= total ){

		event.returnValue = true;

	    if ( document.frm.total_frase.value > 1 ){

			document.frm.limite[(posicao-1)].value=total - cont;

	    }else{

			document.frm.limite.value=total - cont;

	    }

	}else{

		event.returnValue = false;

	}

}



function contadord(total,posicao) {

	if ( document.frm.total_frase.value > 1 ){

		cont = document.frm.frase[(posicao-1)].value.length;

	}else{

		cont = document.frm.frase.value.length;

	}

	var Tecla = window.event.keyCode;

	event.cancelBubble = true;

	if((Tecla == "8" || Tecla == "46")  && cont <= total)	{

		event.returnValue = true;



		if ( document.frm.total_frase.value > 1 ){

			cont = document.frm.frase[(posicao-1)].value.length;

		}else{

			cont = document.frm.frase.value.length;

		}



		if ( document.frm.total_frase.value > 1 ){

			document.frm.limite[(posicao-1)].value=total-cont;

		}else{

			document.frm.limite.value=total-cont;

		}		

		

	}	

}



function mostra(total,posicao) {	

	if ( document.frm.total_frase.value > 1 ){

		cont = document.frm.frase[(posicao-1)].value.length;

	}else{

		cont = document.frm.frase.value.length;

	}	

	if(cont < total){

		if ( document.frm.total_frase.value > 1 ){

			document.frm.limite[(posicao-1)].value= total - cont;

		}else{

			document.frm.limite.value= total - cont;

		}

	}

}



function trimString (str){

  while (str.charAt(0) == ' ')

    str = str.substring(1);

  while (str.charAt(str.length - 1) == ' ')

    str = str.substring(0, str.length - 1);

  return str;

}



function verifica(){

	var i = 0;

	var achou = false;



	if ( document.frm.aceitar.checked == false ){

		alert("Você não está de acordo com o regulamento da promoção.");

		return false;

	}



	if ( document.frm.total_frase.value > 1 ) {

		for ( i = 0; i < document.frm.frase.length; i++ ){

			 if (trimString(document.frm.frase[i].value) == false) {

				alert("A resposta da Frase "+(i+1)+" não preenchida.");

				return false;

			 }

		}

	}



	if ( document.frm.total_frase.value == 1 ) {

		if (trimString(document.frm.frase.value) == false) {

			alert("A resposta da Frase não preenchida.");

			return false;

		}	

	}



	if ( document.frm.total_votacao.value > 1 ) {

		for ( i = 1; i <= document.frm.total_votacao.value; i++ ){

			var radio = eval("document.frm.votacao"+i);

			achou = false;

			for (j=0;j<radio.length;j++){

				if (radio[j].checked){

					achou = true;

				}

			}

			if ( achou == false ){

				alert("Você não marcou nenhuma resposta na votação "+(i)+".");

				return false;

			}

		}

	}



	if ( document.frm.total_votacao.value == 1 ) {

			var radio = eval("document.frm.votacao1");

			achou = false;

			for (j=0;j<radio.length;j++){

				if (radio[j].checked){

					achou = true;

				}

			}

			if ( achou == false ){

				alert("Você não marcou nenhuma resposta na votação.");

				return false;

			}

	}



	if ( document.frm.total_material.value > 1 ) {

		for ( i = 1; i <= document.frm.total_material.value; i++ ){

			var filess = eval("document.frm.material"+i);

			achou = false;

			if ( filess.value != "" ){

				achou = true;

			} 

			if ( achou == false ){

				alert("Você não anexou nenhum arquivo no Envio de Material "+(i)+".");

				return false;

			}

		}

	}





	if ( document.frm.total_material.value == 1 ) {

		var filess = eval("document.frm.material1");

		achou = false;

		if ( filess.value != "" ){

			achou = true;

		} 

		if ( achou == false ){

			alert("Você não anexou nenhum arquivo no Envio de Material.");

			return false;

		}

	

	}



	document.frm.urlError.value = document.URL;

	

	return true;

}

function abrecsPorCanal(nCanal,uf,rev){

	top.location.href = "expanded_sites.jsp?canal="+nCanal+"&uf="+uf+"&rev="+escape(rev);

}

function sinopse( calendarioId, agendaId ){

	var url="http://www.clicrbs.com.br/rio2007/jsp/default.jsp?template=3389.dwt&rootdir=%2Fshared&source=DYNAMIC%2Crbstv.RBSTvDataServer%2CgetSinopse&calendarioid="+calendarioId+"&agendaid="+agendaId;

    MM_openBrWindow(url,'grade','scrollbars=yes,width=350,height=250');

}

function doPopup(url){

	window.open(url,'popup','resizable=yes,scrollbars=yes,location=yes');

}



function abre(video,uf){

        window.open("/rio2007/jsp/player_compact.jsp?nomeVideo="+video+"&uf="+uf,"clicStation","width=250,height=300");

}



function linkAudio1(p_audio,uf){abre('audio/'+p_audio,uf);}



function linkVideo1(p_video,uf){abre('video/'+p_video,uf);}



function linkEncode1(p_video,uf){if(uf==null) uf='RS'; abre(p_video,uf);}



function player_aovivo(uf){

	var nCanal;

	var nomeid;

	var ufOAS;

	var nomePlayer;

	

	if (uf == 1){

		nCanal = "itapemapoa";

		nomeid = 2;

		ufOAS = "RS";

	}

	if (uf == 2){

		nCanal = "itapema";

		nomeid = 1;

		ufOAS = "SC";

	}

	var url = "http://www.clicrbs.com.br/rio2007/jsp/player_expanded.jsp?canal="+nCanal+"&uf="+uf+"&nomeVideo=http://play.rbsonline.com.br/hurl.html%3fpath%3dclicstation/"+nCanal+"%26file%3d"+nCanal+".smil&nomePlayer=m1&ufOAS="+ufOAS+"&nome="+nomeid+"&section=player";

	window.open(url,'Itapema','width=480,height=276');

}

