$(document).ready(function(){
    $(document).keydown(function(event) {
        if (event.ctrlKey==true && (event.which == '118')) {
            event.preventDefault();
         }
    });
  
	$(".oculto").click(function(e){
		$.confirm({
		    title: 'Confirmação',
		    boxWidth: '30%',
		    useBootstrap: false,
		    content: '' +
		    '<h2>Tem certeza que deseja executaro o job?</h2><br>' 
		    ,buttons: {
		        confirm: {
		        	text: 'Sim, quero executar',
		        	btnClass: 'btn-blue',
		        	action:	function () {
		        	    $.ajax ({ 
		        	        url:urlOculto,
		        	        type: 'POST',
		        	        cache: false,
		        	        async: false,
		        	        dataType: "json",
		        	        success: function(response)
		        	        {
		        	        	alert('funcionou');
		        	        }
		        	    });
			        }	
		        },
		        cancel: {
		        	text: 'Cancelar',
		        	action: function () {
		            		
		        	}
		        }
		    }
		});
	}); 
});

//Form DatePicker
var dates="";
$(function () {
	$("input").click(function(){
		$(".alert").hide();
		$('.campo').removeClass('error control-group');
		$('.alert.alert-success').hide();
	})
	
	$(".input-group-addon").click(function(){
		$(".alert").hide();
		$('.campo').removeClass('error control-group');
		$('.alert.alert-success').hide();
	})
	
	$(".campo").click(function(){
		$(".alert").hide();
		$('.campo').removeClass('error control-group');
		$('.alert.alert-success').hide();
	})
});

function createDatesValidation() {
	var date = new Date();
	$('#datepickeragendamento').datepicker({
		 startDate: date,
	     language: 'pt-BR',
	     autoclose: 1,
	     ignoreReadonly: true,
	     beforeShowDay: function (currentDate) {
            if (dates != null && dates.length > 0) {
                for (var i = 0; i < dates.length; i++) {                        
                    if (moment(currentDate).unix()==moment(dates[i],'DD.MM.YYYY').unix()){
                        return false;
                   }
                }
            }
            return true;
        }
	}).on('show', function() {
		 var $clazz = $(".datepicker-days").children().find("tfoot").children().find(".today");
		 $clazz.show();
		 $clazz.addClass("label-calendar-agendamento");
		 $clazz.text("* Já existe agendamento da publicação para esse dia ou o horário limite foi ultrapassado.");
		 $clazz.removeClass("today");
	});
}
