(function($){

	"use strict";
	
	// ANIMATIONS
	new WOW().init();
	var municipalidadJS = {
		init: function () {

			// MOBILE MENU
			$('.main-nav').slicknav({
				prependTo:'.header .row',
				label:''
			});
			
			// CUSTOM FORM ELEMENTS
			//$('input[type=radio], input[type=checkbox],input[type=number], select').uniform();
			
			// SEARCH RESULTS 
			$('.information').hide();
			$('.trigger').click(function () {
				$(this).parent().parent().nextAll('.information').slideToggle(500);
			});
			$('.close').click(function () {
			   $('.information').hide(500);
			});	
			
			// FAQS
			$('.faqs dd').hide();
			$('.faqs dt').click(function () {
				$(this).next('.faqs dd').slideToggle(500);
				$(this).toggleClass('expanded');
			});
			
			// CONTACT FORM
			
			// TABS
			$('.tab-content').hide().first().show();
			$('.tabs li:first').addClass('active');

			$('.tabs a').on('click', function (e) {
				e.preventDefault();
				$(this).closest('li').addClass('active').siblings().removeClass('active');
				$($(this).attr('href')).show().siblings('.tab-content').hide();
			});

			var hash = $.trim( window.location.hash );
			if (hash) $('.tabs a[href$="'+hash+'"]').trigger('click');
			
			// SMOOTH ANCHOR SCROLLING
			var $root = $('html, body');
			$('a.anchor').click(function(e) {
				var href = $.attr(this, 'href');
				if (typeof ($(href)) != 'undefined' && $(href).length > 0) {
					var anchor = '';
					
					if(href.indexOf("#") != -1) {
						anchor = href.substring(href.lastIndexOf("#"));
					}
						
					if (anchor.length > 0) {
						console.log($(anchor).offset().top);
						console.log(anchor);
						$root.animate({
							scrollTop: $(anchor).offset().top
						}, 500, function () {
							window.location.hash = anchor;
						});
						e.preventDefault();
					}
				}
			});
		
		},
		load: function () {
			// UNIFY HEIGHT
			var maxHeight = 0;
				
			$('.heightfix').each(function(){
				if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
			});
			$('.heightfix').height(maxHeight);	

			// PRELOADER
			$('.preloader').fadeOut();
		}
	}
	
////////////////////////////////////////////	
	
	$(window).load(function() {
  	function tick(){
	$('#ticker p:first').slideUp( function () { $(this).appendTo($('#ticker')).slideDown(); });	}
	setInterval(function(){ tick () }, 10000);
  
});

/*
HEADER
*/

$(document).ready(function(){
    $("#galeria_miniaturas img").click(function(){
		var imagen=$(this).attr("src");
		var descripcion=$(this).attr("title");
		$("#imgGaleria").attr("src",imagen);
		$("#descGaleria").text(descripcion);
	});
	

	
})

   var nt_title = $('.nt-md').newsTicker({
            row_height: 40,
            max_rows: 1,
            duration: 3000,
            pauseOnHover: 0
            });	


      var nt_title = $('.nt-xs').newsTicker({
            row_height: 40,
            max_rows: 1,
            duration: 3000,
            pauseOnHover: 0
            });	
			

var nt_example1 = $('#idagenda').newsTicker({
    row_height: 142,
    max_rows: 5,
    autostart: 0,
    duration: 5000,
    prevButton: $('#nt-example1-prev'),
    nextButton: $('#nt-example1-next')
});

var nt_enagenda = $('#idagendaenAgenda').newsTicker({
    row_height: 151,
    max_rows: 10,
    autostart: 1,
    duration: 5000,
    prevButton: $('#nt-example1-prev'),
    nextButton: $('#nt-example1-next')
});
	//idagenda		420488
			
    window.onload = function(e){ 
        $(".buscadorTramites").select2({
          placeholder: "Ingresa una palabra relacionada con el trámite.",
          language: "es"
        }).on("select2:select", function (e) { 
            window.location.href=this.value; 
        });
    }			



$(".rslidesGaleria").responsiveSlides({
  auto: true,             // Boolean: Animate automatically, true or false
  speed: 500,            // Integer: Speed of the transition, in milliseconds
  timeout: 9000,          // Integer: Time between slide transitions, in milliseconds
  pager: false,           // Boolean: Show pager, true or false
  nav: true,             // Boolean: Show navigation, true or false
  random: false,          // Boolean: Randomize the order of the slides, true or false
  pause: true,           // Boolean: Pause on hover, true or false
  pauseControls: true,    // Boolean: Pause when hovering controls, true or false
  prevText: " <i class='sli fa fa-arrow-left' aria-hidden='true'></i>",   // String: Text for the "previous" button
  nextText: " <i class='sli fa fa-arrow-right' aria-hidden='true'></i>",  // String: Text for the "next" button
  maxwidth: "",           // Integer: Max-width of the slideshow, in pixels
  navContainer: "",       // Selector: Where controls should be appended to, default is after the 'ul'
  manualControls: "",     // Selector: Declare custom pager navigation
  namespace: "rslidesGaleria",   // String: Change the default namespace used
  before: function(){},   // Function: Before callback
  after: function(){}     // Function: After callback
});



$(".rslides").responsiveSlides({
  auto: true,             // Boolean: Animate automatically, true or false
  speed: 500,            // Integer: Speed of the transition, in milliseconds
  timeout: 8000,          // Integer: Time between slide transitions, in milliseconds
  pager: false,           // Boolean: Show pager, true or false
  nav: true,             // Boolean: Show navigation, true or false
  random: false,          // Boolean: Randomize the order of the slides, true or false
  pause: false,           // Boolean: Pause on hover, true or false
  pauseControls: true,    // Boolean: Pause when hovering controls, true or false
  prevText: " ",   // String: Text for the "previous" button
  nextText: " ",       // String: Text for the "next" button
  maxwidth: "",           // Integer: Max-width of the slideshow, in pixels
  navContainer: "",       // Selector: Where controls should be appended to, default is after the 'ul'
  manualControls: "",     // Selector: Declare custom pager navigation
  namespace: "rslides",   // String: Change the default namespace used
  before: function(){},   // Function: Before callback
  after: function(){}     // Function: After callback
});




var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
	el.flt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8; 
		this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 40);
	}
	return el;
}
	
	$(document).ready(function () {
		municipalidadJS.init();
	});
	
	$(window).load(function () {
		municipalidadJS.load();
	});
	
})(jQuery);





