var tagAlvo = new Array('p'); //pega todas as tags p//
// Especificando os possiveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '12px','14px','16px','18px','20px','20px','24px' );
var tamanhoInicial = 2;
function mudaTamanho(idAlvo,acao)
{
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  selecionados.style.fontSize = tamanhos[ tamanho ];
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}
$(function(){
    $("li[class^='menos']").click(function(){
		mudaTamanho('texto', -1);
	}); 
    $("li[class^='mais']").click(function(){
		mudaTamanho('texto',1);
	 });
	$('.BTOcontato').click( function(){
        var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		if($('#nome').val() == ''){
	    	alert('Preencha seu nome.');
	    	return false;
		}
		if($('#email').val() == ''){
		    alert('Preencha seu e-mail.');
			return false;
		} else {
		    if(regmail.test($("#email").val())) {
                return true;
			} else {
			   alert("E-mail inválido");
               return false;
			}
		}
	});
	$('#cadastro_promocao').click( function(){
		if($('#iptSenha').val()==''){
			alert('Campo senha vazio.');
		}else{
			if($('#iptSenha').val() != $('#iptConfirma').val()){
				alert('Erro ao confirmar senha.');
				return false;
			}else{
				$.ajax({
					url: '../_script/cad_usuario.php',
					type: 'post',
					dataType:'text',
					cache: false,
					data: {iptNome:$("#iptNome").val(), iptEmail:$("#email").val(), iptTelefone:$("#iptTelefone").val(), iptSenha:$("#iptSenha").val() },
					async: true,  
					error: function(XMLHttpRequest, textStatus, errorThrown){
						alert('Ocorreu um problema, entre em contato com o setor de informática!');
					},
					success: function(response){
						$('.quemFaz').html(response);
					}
				});
			}
		}
	});
	$('.limpaCampo').click( function(){
		$(this).val('');				   
	});	
	$('#novaSenha').click( function(){
								$.ajax({
					url: '../_script/NovaSenha.php',
					type: 'post',
					dataType:'text',
					cache: false,
					data: { iptEmail:$("#email").val()},
					async: true,  
					error: function(XMLHttpRequest, textStatus, errorThrown){
						alert('Ocorreu um problema, entre em contato com o setor de inform�tica!');
					},
					success: function(response){
						$('.quemFaz').html(response);
					}
				});
	});
	 $("div[id^='participar-']").live('click',function(){
		var val = $(this).attr('id').replace('participar-','');
		 val = val.split('_');

		$.ajax({
				url: '../_script/promocao.php',
				type: 'post',
				dataType:'text',
				cache: false,
				data: {id_usuario:val[1],idPromocao:val[0]},
				async: true,  
				error: function(XMLHttpRequest, textStatus, errorThrown){
					alert('Ocorreu um problema, entre em contato com o setor de inform�tica!');
				},
				success: function(response){
					//$('#results').html(response);
					alert(response);
				}
			});
	});
});

$(function(){
	$('.imprimir').click(function(){
	window.print();
	});	   
	$("img[id^='imgId_']").click(function(){
		var variavel =$(this).attr('id').replace('imgId_','');
		
		if($("#id_"+variavel).css('display') =='none'){
			$("#id_"+variavel).show("slow");
			$(this).attr('src','/images/detalhes/minimize.gif');
		}else{
			$("#id_"+variavel).hide("slow").slideUp();
			$(this).attr('src','/images/detalhes/maximize.gif');
	}
	
	}); 

	$("img[id^='mesAgenda_']").click(function(){

		var mes = $(this).attr('id').replace('mesAgenda_','');
		
		if($("#agenda_"+mes).css('display')=='none'){
			$("#agenda_"+mes).show();
			$(this).attr('src','/images/detalhes/minimize.gif');
		} else {
			$("#agenda_"+mes).hide();
			$(this).attr('src','/images/detalhes/maximize.gif');
		}

	/*$("#tr_"+val).css('background-color','#F7C8C5').fadeOut(600,function(){
		  });*/
	});
	
	
		$("div[id^='divlocutor_']").click(function(){

		var id = $(this).attr('id').replace('divlocutor_','');
	//	var img =$(this).attr('id').replace('imGlocutor_','');
		if($("#locutor_"+id).css('display')=='none'){
			$("#locutor_"+id).show();
			$("#imGlocutor_"+id).attr('src','/images/detalhes/minimize.gif');
		} else {
			
			$("#locutor_"+id).hide();
			$("#imGlocutor_"+id).attr('src','/images/detalhes/maximize.gif');
		}

	/*$("#tr_"+val).css('background-color','#F7C8C5').fadeOut(600,function(){
		  });*/
	});
   
   $("#mensagem_locutor").click(function(){
    $('#result_msg').html('');
    if($('#iptNome').val() == ''){
        alert('Preencha seu nome.');
        $('#iptNome').focus();
        return false;
    }
    if($('#iptEmail').val() == ''){
        alert('Preencha seu e-mail.');
        $('#iptEmail').focus();
        return false;
    }
    $(this).attr('readonly','true');
	$.ajax({
		url: '../_script/mensagem.php',
		type: 'post',
		dataType:'text',
		cache: false,
		data: {iptNome:$("#iptNome").val(), iptEmail:$("#iptEmail").val(), iptTelefone:$("#iptTelefone").val(), iptMensagem:$("#iptMensagem").val(), idPessoa:$("#iptLocutor").val() },
		async: true,  
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert('Ocorreu um problema, entre em contato com o setor de informática!');
            $('#mensagem_locutor').attr('readonly','false');
        },
		success: function(response){
			$('#result_msg').html(response);
            $('#iptNome').val('');
            $('#iptTelefone').val('');
            $('#iptEmail').val('');
            $('#iptMensagem').val('');
            $('#mensagem_locutor').attr('readonly','false');
		}
	});	
  });

//INICIO DA ROLETA PAGINA PROMOCOES	
var posicaoImg = 1;

$('#click_esq').click(function(){
//alert(posicaoImg);	
	if(posicaoImg>1){
		var desaparece = posicaoImg + 3;
		var aparecer = posicaoImg -1;
		window.setTimeout(function() {
		$("#idRows_"+aparecer).show("show");
		}, 200);
		$("#idRows_"+desaparece).hide("slideUp");
		posicaoImg--;
	}
			
 });

$('#click_dir').click(function(){
	var limite = $('[id^=idRows_]').size() -4;

	if ( posicaoImg <=  limite){
		var aparecer = posicaoImg + 4;
		$("#idRows_"+posicaoImg).hide("show");
		window.setTimeout(function() {
			$("#idRows_"+aparecer).show("slideUp");
		}, 200);

		posicaoImg++;
	}
 });

	$('.musica_bto').click( function(){

		if($('#PM_nome').val() ==''){
			alert('Campo nome vazio.');
            return false;
		}else{
			if($('#PM_musica').val() == ''){
				alert('Preencha o campo Música.');
				return false;
			}else{
				$.ajax({
					url: '../_script/pedidosMusicas.php',
					type: 'post',
					dataType:'text',
					cache: false,
					data: {nome:$("#PM_nome").val(), email:$("#PM_email").val(), cidade:$("#PM_cidade").val(), musica:$("#PM_musica").val() },
					async: true,
					error: function(XMLHttpRequest, textStatus, errorThrown){
						alert('Ocorreu um problema, entre em contato com o setor de informática!');
					},
					success: function(response){
						$('#musica_formulario').html(response);
					}
				});
			}
		}
	});


//==============================================
});
