/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function navbarCollapse(x) {
    $('.navbar-collapse').toggleClass('collapse');
    $('.dropdown-menu').toggleClass('display-block');
    x.classList.toggle('hamburger-change');
}

function onGovMenuClick() {
    $('div.navbar-government-header-button,.government-menu-close-button').on('click', toggleGov);
}
function toggleGov() {
    $('#government-menu').slideToggle(350, 'linear');
    $('div.navbar-government-header-button span').toggleClass('arrow-up arrow-down');
}

$(document).ready(function() {
    $('li.dropdown').mouseenter(function() {
        $(this).toggleClass('active-dropdown');
    });

    $('li.dropdown').mouseleave(function() {
        $(this).toggleClass('active-dropdown');
    });
});

//Any thing below here isn't common
function toggleBodyMouseover(bodypart) {
    $('#' + bodypart + ' a').addClass('hover');
}
function toggleBodyMouseout(bodypart) {
    $('#' + bodypart + ' a').removeClass('hover');
}

function toggleBodyLinkMouseover(bodypart) {
    $('#dialogForm\\:' + bodypart).addClass('hover');
}
function toggleBodyLinkMouseout(bodypart) {  
    $('#dialogForm\\:' + bodypart).removeClass('hover');
}

$(document).click(function(event) { 
    if(!$(event.target).closest('#findProcPanel').length) {
        if($('#findProcPanel').is(":visible")) {
            PF('findProcPanel').hide();
        }
    }        
});
$(document).click(function(event) { 
    if(!$(event.target).closest('#findProcPanelHome').length) {
        if($('#findProcPanelHome').is(":visible")) {
            PF('findProcPanelHome').hide();
        }
    }        
});
$(document).click(function(event) { 
    if(!$(event.target).closest('#emailDlg').length) {
        if($('#emailDlg').is(":visible")) {
            PF('emailDlg').hide();
        }
    }        
});
$(document).click(function(event) { 
    if(!$(event.target).closest('#trackingInfo').length) {
        if($('#trackingInfo').is(":visible")) {
            PF('trackingInfo').hide();
        }
    }        
});
$(document).click(function(event) { 
    if(!$(event.target).closest('#findProvinces').length) {
        if($('#findProvinces').is(":visible")) {
            PF('findProvinces').hide();
        }
    }        
});
$(document).ready(function() {
    var timeToDisplay = 8000;

    var slideshow = $('#block-views-health-feature-carousel-block #feature-page-item');
    var urls = [
       'resources/images/SWT_01.png',
       'resources/images/SWT_02.png',
       'resources/images/SWT_03.png',
       'resources/images/SWT_04.png'
    ];

    var index = 0;
    var transition = function() {
        var url = urls[index];

        slideshow.css('background-image', 'url(' + url + ')');

        index = index + 1;
        if (index > urls.length - 1) {
            index = 0;
        }
    };

    var run = function() {
        transition();
        slideshow.fadeIn('slow', function() {
            setTimeout(function() {
                slideshow.fadeOut('slow', run);
            }, timeToDisplay);
        });
    };
    run();
});
$(document).ready(function(){
    $('.owl-carousel').owlCarousel({
      rtl: false,
      loop: true,
      margin: 0,
      nav: true,
      scrollPerPage: true,
      navText: [
          '<img src="resources/images/carousel-arrow-back.png"/>',
          '<img src="resources/images/carousel-arrow-next.png"/>'],
      autoHeight: true,
      autoWidth: true,
      responsive: {
          // breakpoint from 0 up
          0: {
              items: 1
          },
          // breakpoint from 768 up
          768: {},
          // breakpoint from 960 up
          960: {},
          1200: {}
      }
    });
});