/*
 *  Italian initialisation for the jQuery UI date picker plugin.
 *  Written by Apaella (apae...@gmail.com).
 *  Version 1.5b2
 *  Modified by B Marcello <m.bozzi@contur.it>
 */
  $(function() {
      $.datepicker.regional['it'] = {
          clearText: 'Svuota', clearStatus: '',
          clearStatus: 'Cancella la data corrente',
          closeText: 'Chiudi', closeStatus: '',
          closeStatus: 'Chiudi senza cambiamenti',
          prevText: '&lt;Prec', prevStatus: '',
          prevStatus: 'Mostra il mese precedente',
          nextText: 'Succ&gt;', nextStatus: '',
          nextStatus: 'Mostra il mese successivo',
          currentText: 'Oggi', currentStatus: '',
          currentStatus: 'Mostra il mese corrente',
          monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
          monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic'],
          monthStatus: 'Mostra un altro mese',
          yearStatus: 'Mostra un altro anno',
          weekHeader: 'Sm', weekStatus: '',
          weekStatus: 'Settimana dell\'anno',
          dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
          dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
          dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'],
          dayStatus: 'Imposta DD come primo giorno della settimana',
          dateStatus: 'Seleziona DD, M d',
          /*dateFormat: 'yy-mm-dd', firstDay: 1,*/
          dateFormat: 'dd/mm/yy', firstDay: 1,
          initStatus: 'Seleziona una data',
          isRTL: false
      };
  $.datepicker.setDefaults($.datepicker.regional['it']);
  $(function() {
		$("#datepicker").datepicker({showOn: 'focus'});
	});
  $(function() {
		$("#datepicker2").datepicker({showOn: 'focus'});
	});
  $(function() {
	  $("#datepicker_com").datepicker({showOn: 'focus', minDate: '+1D' });
  });
  $(function() {
	  $("#network_id-99999").click(function() {
		  var all_status = this.checked;
		  $("input[name^='network_id']").each(function(){
			this.checked=all_status;
		  });
	  });
  });
  $("#sede_legale_stesso_indirizzo").change(function() {
      $("#fieldset-SedeLegaleGrp").toggle();
  });
  $("#iata_agenzia").change(function() {
      $("#iata_numero").toggle();
  });
  $("#crs_id").change(function() {
      if ( $("#crs_id").val() != 1 ) {
    	  $("#crs_codice").show();
      } else {
        $("#crs_codice").hide();
      }
  });
  $("#cambia_password").change(function() {
      $("#fieldset-PasswordGrp").toggle();
  });
  $(".tooltip").tooltip({
    		showURL: false
    	});
  });
  $(document).ready(function() {
  	        $("#tabella_ordinabile")
  	        	.tablesorter({
  	    		  widthFixed: true,
	  	  		  widgets: ['zebra'] 
  	        	})
	  	        .tablesorterPager({
	  	        	container: $("#pager"), 
	  	        	positionFixed: false
	  	        	});
  });
  
  $(document).ready(function() {
	  $("#tabella_com")
	  .tablesorter({
		  widthFixed: true,
		  widgets: ['zebra'], 
		  headers: { 
		  0: { sorter: false }, 
		  7: { sorter: false },
		  8: { sorter: false },
		  9: { sorter: false } 
	  } })
	  .tablesorterPager({
		  container: $("#pager"), 
		  positionFixed: false
	  });
	  /*.columnFilters({excludeColumns:[0,7,8,9]});*/
	  
	  /*$("#tabella_ordinabile tbody tr").quicksearch({
  	            labelText: 'Ricerca: ',
  	            attached: '#tabella_ordinabile',
  	            position: 'after',
  	            delay: 100,
  	            loaderText: 'Caricamento...',
  	            onAfter: function() {
  	                if ($("#tabella_ordinabile tbody tr:visible").length != 0) {
  	                    $("#tabella_ordinabile").trigger("update");
  	                    $("#tabella_ordinabile").trigger("appendCache");
  	                    $("#tabella_ordinabile tfoot tr").hide();
  	                }
  	                else {
  	                    $("#tabella_ordinabile tfoot tr").show();
  	                }
  	            }
  	        });*/
  });
  
  $(document).ready(function() {
	  $("#tabella_agenzie")
	  .tablesorter({
		  widthFixed: true,
		  widgets: ['zebra'], 
		  headers: { 
	          6: { sorter: false },
	          7: { sorter: false },
	          8: { sorter: false }
      } })
      .tablesorterPager({
    	  container: $("#pager"), 
    	  positionFixed: false, 
    	  size:10
    	  });
      /*.columnFilters({
    	  excludeColumns:[0,1,2,7,8,9]
      });*/
	  
	  /*$("#tabella_agenzie tbody tr").quicksearch({
		  labelText: 'Ricerca: ',
		  attached: '#tabella_agenzie',
		  position: 'before',
		  delay: 100,
		  loaderText: 'Caricamento...',
		  onAfter: function() {
		  if ($("#tabella_agenzie tbody tr:visible").length != 0) {
			  $("#tabella_agenzie").trigger("update");
			  $("#tabella_agenzie").trigger("appendCache");
			  $("#tabella_agenzie tfoot tr").hide();
		  }
		  else {
			  $("#tabella_agenzie tfoot tr").show();
		  }
	  }
	  });*/
	  
	  
  });
  
  $(document).ready(function() {
	  $("#tabella_utenti")
	  .tablesorter({
		  widthFixed: true,
		  widgets: ['zebra'], 
		  headers: { 
		  0: { sorter: false }, 
		  6: { sorter: false },
		  7: { sorter: false },
		  8: { sorter: false } 
	  } })
	  .tablesorterPager({
		  container: $("#pager"), 
		  positionFixed: false
		  });
      /*.columnFilters({
    	  excludeColumns:[0,6,7,8]
      });*/
	  
	$('ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);

  });
  
  /*
   * per eseguire il submit del form quando premi enter
   */
  function checkEnter(e){
	  var characterCode;
	  if(e && e.which){
		  e = e;
		  characterCode = e.which;
	  } else {
		  e = event;
		  characterCode = e.keyCode;
	  }
	  if(characterCode == 13){
		  document.forms[0].azione.value='mostra';
		  document.forms[0].submit();
		  return false;
	  }
	  return true;
  }

