// Responsive DOM
!function(n){"use strict";"function"==typeof define&&define.amd?define(["jquery"],n):n(jQuery)}(function(n){"use strict";n.fn.responsiveDom=function(e){var t=n.extend({appendTo:"body",mediaQuery:"(min-width: 0)",callback:null},e),i=this,o=null,c=!1,u=function(){a(),n(window).on("resize.responsiveDom",d(a,100))},a=function(){if(!c&&matchMedia(t.mediaQuery).matches)s(),c=!0;else{if(!c||matchMedia(t.mediaQuery).matches)return;r(),c=!1}"function"==typeof t.callback&&t.callback(c)},s=function(){(!document.contains||document.contains(i[0]))&&(o=n('<span class="js-responsive-dom-placeholder"/>'),i.after(o),n(t.appendTo).eq(0).append(i))},r=function(){null===o||document.contains&&!document.contains(o[0])||(o.after(i),o.remove(),o=null)},d=function(n,e){var t;return function(){clearTimeout(t),t=setTimeout(function(){n()},e)}};return u(),this}});


// JavaScript Document
$( document ).ready(function() {

 $( "#deadline" ).datepicker({      showOtherMonths: true,      selectOtherMonths: true,	  dateFormat: "yy-mm-dd"    });
  
//Datatables

$('#jobs-module').DataTable( {
        responsive: true,
        paging:   false,    columnDefs:[      {width:70,targets:0},      {width:70,targets:5}    ],				order: [[0,"desc"]],
} );

$('#activejobs-module').DataTable( {
        responsive: true,
        paging:   false,
} );
$('#inactivejobs-module').DataTable( {
        responsive: true,
        paging:   false,
} );

//Initialize carousel
$('.carousel').carousel({
        interval: 8000
 });

// to top
$('#toTop').click(function(){
  $('html, body').animate({ scrollTop: 0 }, "slow");
    return false ;
});


// mobile

$('.dropdown.has_submenu .toggle').click(function(){
     $(this).parent().toggleClass('open');
});

/*
// mobile menu toggle second level
   $('.nav > .has_submenu > a').click(function(e){
       $('.open').not($(this).parent()).removeClass('open');
       $(this).parent().toggleClass('open');
       if ($(window).width() < 767) {
            e.preventDefault();
        }
    });

    // mobile menu toggle third level
    $('.nav > .has_submenu .has_submenu > a').click(function(e){
      $(this).parent().toggleClass('open');
      if ($(window).width() < 767) {
         e.preventDefault();
       }
    });
*/

$(window).scroll(function() {
   var nav = $('#nav');
   var top = 50;
   if ($(window).scrollTop() >= top) {
        nav.addClass('fixed');
   } else {
        nav.removeClass('fixed');
   }
});

$(".navbar-toggle").click( function(){
        $('.navbar-header').toggleClass('open');
});

var $mainNav = $('.top-menu,.special-menu');
$mainNav.responsiveDom({
        appendTo: '.navbar-collapse',
        mediaQuery: '(max-width: 767px)'
});

//Search
    var windowWidth= $( window ).width();
    mobileSize = 767;
    if (windowWidth > mobileSize  )    {
    // Clicking outside the input
        $(document).mouseup(function (e)    {
            if (!$('#indexedsearch').is(e.target) && $('#indexedsearch').has(e.target).length === 0)    {
                $('#inputText').css("display", "none");
                $('#indexedsearch').removeClass("change");
            } else {
                $("#inputText").css("display", "block");
                $('#indexedsearch').addClass("change")
            }
        });
    // Pressing Esc Btn on keyboard
    $( document ).on( 'keydown', function ( e ) {
        if ( e.keyCode === 27 ) {
            $("#inputText").css("display", "none");
            $('#indexedsearch').removeClass("change");
        }
    });
} else { // Mobile Sizes
    $(".navbar-nav .on>a").attr("data-toggle", "collapse");
    $( ".equal-height" ).removeClass( "equal-height" );
}

// Hide Slider Arrows if 1 slide
if($('.carousel-inner .item').is(':only-child')) {
    $('.carousel-control').hide();
    $('.carousel-indicators').hide();
     
}





});

