$(document).ready(function(){
	
	//Botaciones
	
	$('#tot_tit').html($('#total_vot').html());

        $('.verResultados').click(function(){
            $('#capa1').hide('normal');
            $('#capa2').show('normal');
        });

        $('.cerrar_res').click(function(){
            $('#capa2').hide('normal');
            $('#capa1').show('normal');
        });

        $('.cerrar_cap2 , .div_encuesta .titulo').live('click', function(){
            $('.cap_general').toggle('fast');
        });

        $('#btnVotar').click(function(){
			if( $('#slRespuestas').val() != 0 ){
				//var uri = $('#url_abs').val() + 'http://www.perucumbia.pe/operaciones.php';
				var uri = $('#url_abs').val() + '../operaciones.php';
				$.post(uri,{
						agregarVoto: 1,
						id_respuesta: $('#slRespuestas').val()
					},
					function (response) {
					}, 'json'
				);
	
				var subtot = parseInt($('#res_'+$('#slRespuestas').val()).html()) + 1;
				$('#res_'+$('#slRespuestas').val()).html(subtot);
	
				var tot = parseInt($('#total_vot').html()) + 1;
				$('#total_vot').html(tot);
	
				$('#tot_tit').html($('#total_vot').html());
	
				$('#capa1').remove();
				$('.cerrar_res').hide();
				$('#capa2').show('normal');
				$('#capa2').append('<div class="cerrar_cap2">Cerrar</div>');
			}
        });

        if($('#voto').val() == 'voto'){
            $('#capa1').remove();
            $('.cerrar_res').hide();
            $('#capa2').show('normal');
        }else{
            $('#capa1').show('normal');
        }
	
	//Registro	
		$('.div_nosotros').click(function(){
			he_bod = $("body").height()+'px';
			if(he_bod != 'auto'){
				he_bod = he_bod.substring(0,4);
				he_bod = parseInt(he_bod);
				heg = he_bod.toString()+'px';
				$('.background_opaco_programas').css("height",heg);
				$('.img_programacion').css("top",he_bod-600);
			}else{
				$('.background_opaco_programas').css("height","0px");
			}

			$('.background_opaco_programas').show();
			$('.img_programacion').show('normal');
		});

		$('.img_programacion .cerrar').click(function(){
			$('.background_opaco_programas').hide('normal');
			$('.img_programacion').hide('normal');
		});

		$('.div_concursos').click(function(){
			he_bod = $("body").height()+'px';
			if(he_bod != 'auto'){
				he_bod = he_bod.substring(0,4);
				he_bod = parseInt(he_bod);
				heg = he_bod.toString()+'px';
				$('.background_opaco_programas').css("height",heg);
				$('.bloque_de_contenido').css("top",150);
			}else{
				$('.background_opaco_programas').css("height","0px");
			}

			$('.background_opaco_programas').show();
			$('.bloque_de_contenido').show('normal');
		});

		$('.bloque_de_contenido .cerrar').click(function(){
			$('.background_opaco_programas').hide('normal');
			$('.bloque_de_contenido').hide('normal');
		});

	/* registro formulario */
	/*
	$("#cuadro_separacion_bloques").validate({
		rules:{
			TxtNombre: 'required',
			TxtApellidos: 'required',
			TxtEdad: {required: true, number: true, rangelength:[2, 2]},
			TxtDni: {required: true, number: true, rangelength:[8, 8]},
			TextTelef: {required: true, number: true},
			TextEmail: {required: true, email: true}
		},
		messages:{
			TxtNombre: 'Escriba un nombre valido.',
			TxtApellidos: 'Escriba su apellido',
			TxtEdad: {required: 'Escriba su edad.', number: 'Ingresa un n\u00famero valido', rangelength: 'Ingrese n\u00famero de 2 d\u00edgitos'},
			TxtDni: {required: 'Escriba un DNI valido.', number: 'Ingrese un DNI valido', rangelength: 'Ingrese n\u00famero de 8 d\u00edgitos'},
			TextTelef: {required: 'Escriba un n\u00famero valido', number:'Ingrese un n\u00famero valido'},	
			TextEmail: {required: 'Escriba un E-mail valido', email: 'Ingrese un E-mail valido'}
			
		},
		submitHandler: function(form) {
			$.post('http://www.perucumbia.pe/index.php',
			//$.post('../index.php',
				{
					inscripcion: 1,
					TxtNombre: $('#TxtNombre').val(),
					TxtApellidos: $('#TxtApellidos').val(),
					TxtEdad: $('#TxtEdad').val(),
					TxtDni: $('#TxtDni').val(),
					TextTelef: $('#TextTelef').val(),
					TextEmail: $('#TextEmail').val()
				},
				function (response) {
					$('.mensaje_registrado').show();
				}, 'json'
			);
			
			$('#TxtNombre').val('');
			$('#TxtApellidos').val('');
			$('#TxtEdad').val('');
			$('#TxtDni').val('');
			$('#TextTelef').val('');
			$('#TextEmail').val('');
			setTimeout(function(){ 
				$('.mensaje_registrado').hide();
				$('.background_opaco_programas').hide('normal');
				$('.bloque_de_contenido').hide('normal');
			}, 8000 );
		}
	});
*/

	});
