function cor_borda(alvo,cor) {
	var alvo = document.getElementById(alvo);
	alvo.style.borderColor = cor
}

////////////////////////////////////////////////////////////

function login_blur(){
	var cp_login = document.getElementById('entra_log');
	if(cp_login.value==''){
		cp_login.value='email';
		}
	}

////////////////////////////////////////////////////////////

function login_foco(){
	var cp_login = document.getElementById('entra_log');
	if(cp_login.value=='email'){
		cp_login.value='';
		}
	}

////////////////////////////////////////////////////////////

function cadastro_newsletter(){
	var nome = document.getElementById('newsletter_nome');
	var email = document.getElementById('newsletter_email');
	
	if(nome.value==''){
		alert('Por favor preencha seu nome');
		nome.focus();
		return false
		}
	if(email.value==''){
		alert('Por favor preencha seu email');
		email.focus();
		return false
		}
	
	carregaAjax('php/newsletter_insere.php?nome_insere='+nome.value+'&email_insere='+email.value,dv_newsletter,dv_newsletter_carregando);
	
	}

////////////////////////////////////////////////////////////

function anuncios_mini(id,pos){
	var alvo = document.getElementById('dv_anuncio_mini');
	exibe('dv_anuncio_mini');
	mudaImagem('foto_anuncio_mini','fotos/anuncios_mini/'+id+'_0.jpg');
	var pos_final = buscarPosicao('anuncio_mini_pq_'+pos).x-130;
	alvo.style.left = pos_final+'px';
	
	}

////////////////////////////////////////////////////////////

function navegador(){
	
	var navegador = window.navigator.userAgent;
  	if(navegador.indexOf('Firefox')!=-1){
		return "Firefox";
		}
	if(navegador.indexOf('WebKit')!=-1){
		return "WebKit";
		}
	if(navegador.indexOf('MSIE')!=-1){
		return "IE";
		}

	}

////////////////////////////////////////////////////////////

function enquete_votar(){
	carregaAjax('php/enquete_votar.php',dv_enquete_palco,dv_enquete_carregando);
	}

////////////////////////////////////////////////////////////

function enquete_insere_voto(id,id_opcao){
	carregaAjax('php/enquete_insere_voto.php?id_enquete='+id+'&id_opcao='+id_opcao,dv_enquete_palco,dv_enquete_carregando,enquete_resultado);
	}

////////////////////////////////////////////////////////////

function enquete_resultado(){
	carregaAjax('php/enquete_resultado.php',dv_enquete_palco,dv_enquete_carregando);
	}

////////////////////////////////////////////////////////////

function enviar_indique(cod,id,tab,pag){
	
	var alvo = document.getElementById('dv_indique_'+cod);
	var carregando = document.getElementById('dv_indique_carregando_'+cod);

	var nome_remetente = document.getElementById('nome_remetente_'+cod);
	var email_remetente = document.getElementById('email_remetente_'+cod);
	var nome_destinatario = document.getElementById('nome_destinatario_'+cod);
	var email_destinatario = document.getElementById('email_destinatario_'+cod);
	var mensagem = document.getElementById('msg_indique_'+cod);
	

	if((nome_remetente.value=='') || (nome_remetente.value=='Seu Nome')){
			alert('Preencha seu nome');
			nome_remetente.focus();
			return false;
			}
			
	if((email_remetente.value=='') || (email_remetente.value=='Seu Email')){
			alert('Preencha seu email');
			email_remetente.focus();
			return false;
			}
			
	if((nome_destinatario.value=='') || (nome_destinatario.value=='Nome Destinatário')){
			alert('Preencha o nome do Destinatário');
			nome_destinatario.focus();
			return false;
			}
			
	if((email_destinatario.value=='') || (email_destinatario.value=='Email Destinatário')){
			alert('Preencha o email do Destinatário');
			email_destinatario.focus();
			return false;
			}
			
	if((email_destinatario.value=='') || (email_destinatario.value=='Email Destinatário')){
			alert('Preencha o email do Destinatário');
			email_destinatario.focus();
			return false;
			}
			
	if((mensagem.value=='') || (mensagem.value=='Sua Mensagem')){
			alert('Preencha sua mensagem');
			mensagem.focus();
			return false;
			}
			
	carregaAjax('php/indique_insere.php?id_item='+id+'&tab_busca='+tab+'&pag='+pag+'&nome_remetente='+nome_remetente.value+'&email_remetente='+email_remetente.value+'&nome_destinatario='+nome_destinatario.value+'&email_destinatario='+email_destinatario.value+'&mensagem_indique='+mensagem.value,alvo,carregando);
	
	}

///////////////////////////////////////////////////////////	

function comente_listar(tab,id,pag){

	if(pag==''){ 
					pag = 0; 
					}

	var alvo = document.getElementById('dv_comente_lista_'+tab+'_'+id);
	var carregando = document.getElementById('dv_comente_lista_carregando_'+tab+'_'+id);
	carregaAjax('php/comente_lista.php?id_item='+id+'&tab_busca='+tab+'&pag='+pag,alvo,carregando);
	
	}

///////////////////////////////////////////////////////////	

function comente(tab,id){

	var msg = document.getElementById('cp_comente_'+tab+'_'+id);
	var alvo = document.getElementById('dv_comente_lista_'+tab+'_'+id);
	var carregando = document.getElementById('dv_comente_lista_carregando_'+tab+'_'+id);
	
	if(msg.value==''){
		alert('Preencha seu comentário!');
		} else {
		carregaAjax('php/comente_lista.php?msg='+msg.value+'&id_item='+id+'&tab_busca='+tab,alvo,carregando);
		msg.value='';
		}
	
	}

///////////////////////////////////////////////////////////	

function aval_mudar_img(id_fotos,img1,img2,img3,img4,img5){
	
	var alvo1 = document.getElementById(id_fotos+'1');
	var alvo2 = document.getElementById(id_fotos+'2');
	var alvo3 = document.getElementById(id_fotos+'3');
	var alvo4 = document.getElementById(id_fotos+'4');
	var alvo5 = document.getElementById(id_fotos+'5');
	
	if(img1==0){	alvo1.src='imagens/icones/aval_off.gif';		}
	if(img1==1){	alvo1.src='imagens/icones/aval_desativa.gif';}
	if(img1==2){	alvo1.src='imagens/icones/aval_half.gif';		}
	if(img1==3){	alvo1.src='imagens/icones/aval_ativo.gif';	}
	
	if(img2==0){	alvo2.src='imagens/icones/aval_off.gif';		}
	if(img2==1){	alvo2.src='imagens/icones/aval_desativa.gif';}
	if(img2==2){	alvo2.src='imagens/icones/aval_half.gif';		}
	if(img2==3){	alvo2.src='imagens/icones/aval_ativo.gif';	}
	
	if(img3==0){	alvo3.src='imagens/icones/aval_off.gif';		}
	if(img3==1){	alvo3.src='imagens/icones/aval_desativa.gif';}
	if(img3==2){	alvo3.src='imagens/icones/aval_half.gif';		}
	if(img3==3){	alvo3.src='imagens/icones/aval_ativo.gif';	}

	if(img4==0){	alvo4.src='imagens/icones/aval_off.gif';		}
	if(img4==1){	alvo4.src='imagens/icones/aval_desativa.gif';}
	if(img4==2){	alvo4.src='imagens/icones/aval_half.gif';		}
	if(img4==3){	alvo4.src='imagens/icones/aval_ativo.gif';	}

	if(img5==0){	alvo5.src='imagens/icones/aval_off.gif';		}
	if(img5==1){	alvo5.src='imagens/icones/aval_desativa.gif';}
	if(img5==2){	alvo5.src='imagens/icones/aval_half.gif';		}
	if(img5==3){	alvo5.src='imagens/icones/aval_ativo.gif';	}

	}

///////////////////////////////////////////////////////////	

function abas_programacao(j){
	
	for(i=0;i<7;i++){
			estilo('menu_aba_'+i,'aba_off');
			oculta('dv_semana_'+i);
		}

	estilo('menu_aba_'+j,'aba_on');
	exibe('dv_semana_'+j);
	}	
	
///////////////////////////////////////////////////////////	
	
function lista_videos_over(ID_VIDEO){
	estilo('video_lista_foto_'+ID_VIDEO,'borda_foto_sobre');
	estilo('video_lista_texto_'+ID_VIDEO,'texto_linhas_chamadas_hover');
	mudaImagem('video_lista_icone_'+ID_VIDEO,'imagens/seta_video_lista_over.gif');	
	}
	
////////////////////////////////////////////////////////////////

function lista_videos_out(ID_VIDEO){
	estilo('video_lista_foto_'+ID_VIDEO,'borda_foto');
	estilo('video_lista_texto_'+ID_VIDEO,'texto_linhas_chamadas');
	mudaImagem('video_lista_icone_'+ID_VIDEO,'imagens/seta_video_lista.gif');	
	}
	
////////////////////////////////////////////////////////////////

function buscarPosicao(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {
		 	x:offsetLeft, 
			y:offsetTop
			};
}

///////////////////////////////////////////

function canais(total){
		
		var canais_lista = document.getElementById('dv_canais_click_mix_lista');
		var btn = document.getElementById('btn_canais_click_mix');
		
		var altura = total*30;
		
		if(canais_lista.style.height=='30px'){
			canais_lista.style.height=altura+'px';
			btn.src="imagens/btn_click_mix_aberto.jpg";
			} else {
			canais_lista.style.height='30px';
			btn.src="imagens/btn_click_mix_fechado.jpg";
			}
		
	}

///////////////////////////////////////////

function focoNoEntrar(){
	var login = document.getElementById('entra_log');
	login.focus();
	}

///////////////////////////////////////////

function entrar(){
		var form = document.getElementById('form_login');
		form.submit();
	}

///////////////////////////////////////////

function confereCaractere(char,campo,msg){
	
	var alvo = document.getElementById(campo);
	var conteudo = alvo.value;
	
		if(conteudo.indexOf(char,0) == -1){
			alert(msg);
			alvo.focus();
			alternaEstilo(campo,'borda_erro');
			return false;
			} else {
			alternaEstilo(campo,'');
			}
			
	}

/////////////////////////////////////////////////////

function campos_obrigatorios(lista){
	var array=lista.split(",");
	for(i=0;i<array.length;i++){
		var campo=array[i];
		var alvo = document.getElementById(campo);
		if(alvo.value==""){
			alert('Preencha o campo selecionado!');
			alternaEstilo(campo,'borda_erro');
			alvo.focus();
			return false;
			} else {
			alternaEstilo(campo,'');	
			}
		}
	}

/////////////////////////////////////////////////////

function confirma_url(msg,url){
	if(confirm(msg)){
					document.location.href=url;
				  } 
	
	}

/////////////////////////////////////////////////////

function ampliarConteudo(arquivo){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop=document.body.scrollTop;
	
	exibe("dv_zoom");
	carregaAjax(arquivo,dv_palco_zoom,dv_carregando_zoom);
	}

/////////////////////////////////////////////////////

function ampliarFoto(foto,legenda,credito){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop=document.body.scrollTop;

	exibe("dv_zoom");
	carregaAjax('php/exibe_foto.php?foto='+foto+'&legenda='+legenda+'&credito='+credito,dv_palco_zoom,dv_carregando_zoom);
	}

/////////////////////////////////////////////////////

function fechar_zoom(){
	oculta("dv_zoom");
	}

/////////////////////////////////////////////////////
	
function cookie(name,value,hours){
	var path='/';
	if (hours){
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+escape(value)+expires+"; path="+path;
}

/////////////////////////////////////////////////////

function lerCookie(name){   
	var nameEQ = name + "=";
   var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' '){
			c = c.substring(1,c.length);
			}
      if (c.indexOf(nameEQ) == 0){
   		return unescape(c.substring(nameEQ.length,c.length));
   		}
	}
	return null;
}

/////////////////////////////////////////////////////

function limparCookie(name,path){
	var path = '/';
	var mac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
	if(mac){
		createCookie(name,"",0.001,path);
 	}else{
		createCookie(name,"",-1,path);
	}
}

/////////////////////////////////////////////////////

function carregaAjax(url,alvo,carregando,funcao,vars){

	if(typeof(alvo)=='string'){
		alvo = document.getElementById(alvo);
		}
	if(typeof(carregando)=='string'){
		carregando = document.getElementById(carregando);
		}

	$.ajax(
		{
		  url: url,
		  cache: false,
		  beforeSend: function(){
			  	if((carregando!=undefined) && (carregando!='')){
		  			$(carregando).show();
					}
				if((alvo!=undefined) && (alvo!='')){	
					$(alvo).hide();
					}
		  		},
		  success: function(html){
		  		if((carregando!=undefined) && (carregando!='')){
					$(carregando).hide();
					}
				if((alvo!=undefined) && (alvo!='')){	
					$(alvo).show();
					$(alvo).html(html);
					}
				
				if(funcao!=undefined){
					exec = funcao;
					exec(vars);
					}
				
				}
			}
		);
	}

/////////////////////////////////////////////////////

function mudaImagem(alvo,imagem){
	alvo = document.getElementById(alvo)
	alvo.src=imagem;
	}
	
/////////////////////////////////////////////////////

function alternaImagens(alvo,imagem1,imagem2){
	
	alvo = document.getElementById(alvo);
	if(alvo.src.indexOf(imagem1)!=-1){
		alvo.src=imagem2;
		} else {
		alvo.src=imagem1;
		}
	}
	
/////////////////////////////////////////////////////

function alternaDisplay(alvo,estiloExibe){
	if(estiloExibe==undefined){
		estiloExibe = 'block';
		}
	alvo = document.getElementById(alvo)
	if(alvo.style.display==estiloExibe){
		alvo.style.display="none";
		} else {
		alvo.style.display=estiloExibe;
		}
	}

/////////////////////////////////////////////////////

function alternaEstilo(alvo,estilo1,estilo2){
	alvo = document.getElementById(alvo);
	if(alvo.className==estilo1){
			alvo.className=estilo2;
		} else {
			alvo.className=estilo1;
		}
	}

/////////////////////////////////////////////////////

function estilo(alvo,estilo){
	var alvo = document.getElementById(alvo);
	alvo.className=estilo;
	}
   
/////////////////////////////////////////////////////   

function exibe(alvo){	
	alvo = document.getElementById(alvo)
	alvo.style.display="block"
	}

/////////////////////////////////////////////////////   	

function oculta(alvo){
	alvo = document.getElementById(alvo)
	alvo.style.display="none"
	}
	
/////////////////////////////////////////////////////   	

function mudaTexto(alvo,conteudo){
	document.getElementById(alvo).innerText = conteudo;
	}

///////////////////////////////////////////////////// 

function lerTexto(alvo){
	var retorno = document.getElementById(alvo);
	return retorno.innerText;
	}

///////////////////////////////////////////////////// 
