jQuery( function() {
  // Disable dragging on certain portlets
  jQuery('#layout-column_portlet\\:71_INSTANCE_0001').removeClass('lfr-portlet-column');
  jQuery('#layout-column_portlet\\:73_INSTANCE_0001').removeClass('lfr-portlet-column');
  
  // Toggle company register languages
  var fi = "#location\\.title_fi,#location\\.text_80_fi,#location\\.text_250_fi";
  var en = "#location\\.title_en,#location\\.text_80_en,#location\\.text_250_en";
  var de = "#location\\.title_de,#location\\.text_80_de,#location\\.text_250_de";
  var ru = "#location\\.title_ru,#location\\.text_80_ru,#location\\.text_250_ru";
  
  jQuery(en+","+de+","+ru).parent().parent().hide();
  //jQuery("#toggle-lang").click(function () { jQuery(en+","+de+","+ru).parent().parent().toggle(); });
  jQuery("#show-lang").click(function () {
    jQuery(en+","+de+","+ru).parent().parent().show(); 
    jQuery("#show-lang").hide(); 
    jQuery("#hide-lang").show(); 
  });
  jQuery("#hide-lang").click(function () {
    jQuery(en+","+de+","+ru).parent().parent().hide();
    jQuery("#hide-lang").hide(); 
    jQuery("#show-lang").show(); 
  });
  
  // Toggle company register delivered
  jQuery('.checkedItem').each(function(){
    var $thisRow = jQuery(this);

    jQuery("#show-delivered").click(function () {
      $thisRow.show();
      jQuery("#show-delivered").hide();
      jQuery("#hide-delivered").show();
      jQuery("td.shoppingbasket input.shoppingbasket,#selectAll").attr("checked",false);
    });
    
    jQuery("#hide-delivered").click(function () {
      $thisRow.hide();
      jQuery("#show-delivered").show();
      jQuery("#hide-delivered").hide();
      jQuery("td.shoppingbasket input.shoppingbasket,#selectAll").attr("checked",false);
    });
    
    $thisRow.hide();
  });

  // Toggle checkboxes if checkedItems are visible
  jQuery("#selectAll").change(function () {
    if ( !jQuery('.checkedItem').length || jQuery('.checkedItem').is(':visible')) {
      tog = jQuery('#selectAll').is(':checked');
      jQuery("td.shoppingbasket input.shoppingbasket").attr("checked",tog);
    }
  });
});

