$(document).ready(function() {
			
		//ACORDEÓN HOME	
		//Set default open/close settings
		$('.info_noticia_home').hide(); //Hide/close all containers
		$('.titulo_noticia:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
		 
		//On Click
		$('.titulo_noticia').click(function(){
			if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
				$('.titulo_noticia').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
				$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
			}
			return false; //Prevent the browser jump to the link anchor
		});
		
		//Rollover js
		$('.rollover_js').children().hover(function() {
			$(this).siblings().stop().fadeTo(300,0.4);
		}, function() {
			$(this).siblings().stop().fadeTo(250,1);
		});
		
		
		//ACORDEON VOTACIONES
			$('.opinion_div').hide(); //Hide/close all containers
			$('.opinion_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
		
			$('.opinion_trigger').click(function(){
				if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
					$('.opinion_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
					$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
				}
				return false;
			});

		
		/* FUNCIONES PROPIAS */
			// abrir buscador
			$('#mostrar_buscador').click(function() {
				$('#buscador_div').show('fast');
				return false;
			});  
			$('#ocultar_buscador').click(function() {
				$('#buscador_div').hide('fast');
				return false;
			});
			
			// calendario
			function calAnt() {
				$('#agenda_cont').html('cargando...');
				$('#agenda_cont').load(
					'home/cambiocalendario',
					{ 'query': 'anterior' },
					function() {
						Cufon.replace('h3', { fontFamily: 'Gotham Medium' });
						Cufon.replace('h4', { fontFamily: 'Gotham Book' }); 
						Cufon.now();
						$('#agenda_cont .anterior').click(calAnt);
						$('#agenda_cont .siguiente').click(calSig);
					}
				);
			}
			function calSig() {
				$('#agenda_cont').html('cargando...');
				$('#agenda_cont').load(
					'home/cambiocalendario',
					{ 'query': 'siguiente' },
					function() {
						Cufon.replace('h3', { fontFamily: 'Gotham Medium' });
						Cufon.replace('h4', { fontFamily: 'Gotham Book' }); 
						Cufon.now();
						$('#agenda_cont .anterior').click(calAnt);
						$('#agenda_cont .siguiente').click(calSig);
					}
				);
			}
			$('#agenda_cont .anterior').click(calAnt);
			$('#agenda_cont .siguiente').click(calSig);
			
			// encuestas
			function abrirEncuesta(obj) {
				var elem = getsElementByClassName('element_abierto','div');
				for(i=0; i<elem.length; i++) {
					if(elem[i].style.display == 'block') {
						elem[i].style.display = 'none';
						var nId = elem[i].id.replace('Abierta','Cerrada');
						document.getElementById(nId).style.display = 'block';
					}
				}
				document.getElementById('encuestaCerrada'+obj).style.display = 'none';
				document.getElementById('encuestaAbierta'+obj).style.display = 'block';
			}
			function votarEncuesta() {
				var opc = $('input[name=encuestaOpc]:checked').attr('value');
				$('#divCencuesta').load(
					'home/votarEncuesta',
					{ 'opcion' : opc }
				);
			}

});    //Fin de document.ready


//NIVOSLIDER
	$(window).load(function() {
	    $('#slider').nivoSlider({
	       borderRadius: 0,
	        //effect:'boxRain', // Specify sets like: 'fold,fade,sliceDown'
	        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
	        slices:15, // For slice animations
	        boxCols: 8, // For box animations
	        boxRows: 4, // For box animations
	        animSpeed:400, // Slide transition speed
	        pauseTime:8000, // How long each slide will show
	        startSlide:0, // Set starting Slide (0 index)
	        directionNav:true, // Next & Prev navigation
	        directionNavHide:true, // Only show on hover
	        controlNav:false, // 1,2,3... navigation
	        controlNavThumbs:false, // Use thumbnails for Control Nav
	        controlNavThumbsFromRel:false, // Use image rel for thumbs
	        controlNavThumbsSearch: '.jpg', // Replace this with...
	        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
	        keyboardNav:false, // Use left & right arrows
	        pauseOnHover:false, // Stop animation while hovering
	        manualAdvance:false, // Force manual transitions
	        captionOpacity:0.8, // Universal caption opacity
	        prevText: 'Prev', // Prev directionNav text
	        nextText: 'Next', // Next directionNav text
	        beforeChange: function(){}, // Triggers before a slide transition
	        afterChange: function(){}, // Triggers after a slide transition
	        slideshowEnd: function(){}, // Triggers after all slides have been shown
	        lastSlide: function(){}, // Triggers when last slide is shown
	        afterLoad: function(){}, // Triggers when slider has loaded
	         customChange: function(){
                Cufon.replace('.nivo-caption');
            }
	    });
	});
