﻿$(document).ready(function() {



  // Table Sorter
  // https://github.com/fnagel/jQuery-Accessible-RIA/wiki/Table
	$("#table-projekte").ariaSorTable({
		// rowsToShow: 10,
		pager: false,
		onInit: function() {
			// demoControl();
		},
		colsToHide: {
			// 1: true,
			// 7: true
		}
	});

  /*
	$("#destroy").click(function (event) {
		table1.ariaSorTable('destroy');
	});
	$("#disable").click(function (event) {
		table1.ariaSorTable('disable');
	});
  */

  /* Page: footprint /  Action: Highlight table row */
  $("#table-transport tr, #table-utility tr, #table-direct-emissions tr, #table-credits tr").live('mouseover', function() {
    $(this).addClass("highlight");
  });

  $("#table-transport tr, #table-utility tr, #table-direct-emissions tr, #table-credits tr").live('mouseout', function() {
    $(this).removeClass("highlight");
  });


  /* Page: footprint / Action: Make row clickable
  http://www.electrictoolbox.com/jquey-make-entire-table-row-clickable/
  */
  $('#table-transport td, #table-utility td, #table-direct-emissions td, #table-credits td').live('click', function() {
    var href = $(this).find("a").attr("href");
    var href_title = $(this).find("a").attr("title");
    var href_class = $(this).find("a").attr("class");

    if(href && href_class == "clickable") {
        JQDialog('' + href_title + '', '' + href + '', '');
        return false;
    }
    else if(href && href_class == "notClickable") {
        JQDialogConfirm('' + href + '', '' + href_title + '');
        return false;
    }
  });

  /* Page: edit-footprint / Action: usedname vorbelegen, einheit ändern */
  $('select#data-name').live('change', function() {
      var text = $('select#data-name option:selected').text();
      var title = $('select#data-name option:selected').attr("title");

      $('input#data-usedname').empty().val(text);
      $('span#data-unit').empty().text(title);
    });
});
