function bulkDeleteSystems(){
  if(confirm('Are you sure that you want to delete chosen systems?')){
    url = "bulk-delete-systems";
    $.post(url, 
      $("#systemListForm").serialize(), 
      function(data){
        if(data.OK){
          alert('Systems successfully deleted');
        } else{
          alert(data.error);
        }
      },
      'json'
    );
  }
}

function changeInstallerPageState(){
  state = $('[name=installerPageState]').val();
  if(state != ''){
    document.location = state + '-' + 'solar-installers';
  }
}

function showAddNewOwnerForm(){
  $('#profile-container').slideDown('slow');
}

function installerChooseOwner(){
  ownerId = $('[name=ownerId]').val();

  if(ownerId != ''){
    document.location = 'system?ownid=' + ownerId + '&exist=1';
  }
}

function showContractUploadForm(){
  $('#uploadContractFormContainer').show();
}

function showSellSrecForm(){
  $("#sellSrecsFormContainer").show();
}

function selectAllCheckboxes(form){
  $('#' + form + ' input:checkbox').attr('checked', 'checked'); 
}

function unselectAllCheckboxes(form){
  $('#' + form + ' input:checkbox').attr('checked', ''); 
}

function setUpDashboardToggle(divsToHide){
  $('h2').click(function(event) {
    var $target = $(event.target);
    $target.next().toggle();
  });

  $.each(divsToHide, function(i, div){
    $('#' + div).hide();
  });
}
