function showTa(id,year,status) {
  // reset values
  if(viewStatus == "current") {
    if(status === 'hover' || ta_click == false) _links_sel_current_hover = []
    if(status != 'hover') _links_sel_current = []
  } else {
    if(status === 'hover' || ta_click == false) _links_sel_all_selected = []
    if(status != 'hover') _links_sel_all = [];
  }


  // if is array draw all nodes/links, or only one, or no TA at all
  if(Object.prototype.toString.call(id) === '[object Array]') {
    id.forEach(function(e,i) { drawNodesLinks(e,'array'); });
  }
  else if(typeof id === 'number') {
    drawNodesLinks(id);
  }

  function drawNodesLinks(d,type) {
     if(viewStatus == "current") {
        // show all nodes which belong to TA
        svg.selectAll(".node.ftaID_" + d).classed("fadeOut",false).classed("node--active",true);

        // show all Links which belong to TA
        var found = -1;
        link_data_grouped.forEach(function(e,i) { if(e.id == d) found = i; });
        if(found != -1) {
          // if year is defined = mouseover in list so draw on canvas 3

          if(status === 'hover') {

            // save for screenshot
            _links_sel_current_hover.push(link_data_grouped[found]);
            canvas_draw_lines(link_data_grouped[found].path, 3, link_data_grouped[found].color, 4); //link_data_grouped[found].members
            if(isSafari == true) {
              var ca = document.getElementById('lines_current_selected_hover_canvas');
              var ur = ca.toDataURL();
              var result = document.getElementById('lines_current_selected_hover_img');
              result.src=ur;
              result.style.width = ca.style.width;
              result.style.height = ca.style.height;
            }
          }
          else  {
            // save for screenshot
            _links_sel_current.push(link_data_grouped[found]);
            // user selected a country draw on canvas 2
            canvas_draw_lines(link_data_grouped[found].path, 2, link_data_grouped[found].color, 4); //link_data_grouped[found].members
            if(isSafari == true) {
              var ca = document.getElementById('lines_current_selected_canvas');
              var ur = ca.toDataURL();
              var result = document.getElementById('lines_current_selected_img');
              result.src=ur;
            }
          }
        }
     }
     else {
        if(type == 'array') {
          var year_ = d.year;
          var id = d.id;
        }
        else {
          var year_ = year;
          var id = d;
        }
        var _links;
        var _links_sel = [];

        function showlinks() {
          if(_links_sel.length > 0) {

            if(status == 'hover') _links_sel_all_selected.push(_links_sel);
            else _links_sel_all.push(_links_sel);

            drawLinks(_links_sel,'total',status);
          }
        }

        if(id>=0) {
          $.each(years, function(a,b) { if(b.val == year_) _links = data_prepared[ years[b.pos].pos ][1]; });
          _links.forEach(function(e,i) {
            if(e.target.id == id) {
              _links_sel.push( e );
              svg.selectAll(".node."+formatBlank(e.source.name)).classed("hide",false).classed("fadeOut",false).classed("node--active",true); //.classed("show",true)
              svg.selectAll(".node."+formatBlank(e.target.name)).classed("hide",false).classed("fadeOut",false).classed("node--active",true); //.classed("node--active",true)
            }
          });
          showlinks();
        }
        else {
            // woldwide
            var countries = [];
            // start a web worker if supported, not supoorted by ie9 and ie8
            if(window.Worker !== undefined){
              var worker = new Worker('js/worker/12_task.js');
              worker.addEventListener('message', function(e) {
                if(e.data.cmd == "totalWorldwideBack") {
                  $('.loader').hide();
                  _links_sel = e.data.links;
                  countries = e.data.countries;
                  countries.forEach(function(e,i) {
                    svg.selectAll(".node."+formatBlank(e)).classed("hide",false).classed("fadeOut",false).classed("node--active",true);
                  });

                  showlinks();
                }

              }, false);
              // worker.addEventListener('error', console.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message), false);
              worker.postMessage({'cmd': 'totalWorldwide', 'data': data_prepared, 'year':year_}); // Start the worker.
              //worker.terminate()
            } else { // fallback for ie8 and ie9
              for(var i = 0; i<=(year_-1);i++) {
                $('.loader').hide();
                var temp = _links_sel.concat(data_prepared[i][1]); _links_sel = temp;
                data_prepared[i][1].forEach(function(e,i) {
                    if(!isInArray(e.source.name,countries)) countries.push(e.source.name);
                    if(!isInArray(e.target.name,countries)) countries.push(e.target.name);
                });
              }
              countries.forEach(function(e,i) {
                svg.selectAll(".node."+formatBlank(e)).classed("hide",false).classed("fadeOut",false).classed("node--active",true);
              });
              showlinks();
            }


        }
     }
  }

}
// show one TA with specific ID
show one TA with specific ID
show one TA with specific ID
function showTa(id,year,status) {
  if(viewStatus == "current") {
    if(status === 'hover' || ta_click == false) _links_sel_current_hover = []
    if(status != 'hover') _links_sel_current = []
  } else {
    if(status === 'hover' || ta_click == false) _links_sel_all_selected = []
    if(status != 'hover') _links_sel_all = [];
  }
  if(Object.prototype.toString.call(id) === '[object Array]') {
    id.forEach(function(e,i) { drawNodesLinks(e,'array'); });
  }
  else if(typeof id === 'number') {
    drawNodesLinks(id);
  }
  function drawNodesLinks(d,type) {
     if(viewStatus == "current") {
        svg.selectAll(".node.ftaID_" + d).classed("fadeOut",false).classed("node--active",true);
        var found = -1;
        link_data_grouped.forEach(function(e,i) { if(e.id == d) found = i; });
        if(found != -1) {
          if(status === 'hover') {
            _links_sel_current_hover.push(link_data_grouped[found]);
            canvas_draw_lines(link_data_grouped[found].path, 3, link_data_grouped[found].color, 4); 
            if(isSafari == true) {
              var ca = document.getElementById('lines_current_selected_hover_canvas');
              var ur = ca.toDataURL();
              var result = document.getElementById('lines_current_selected_hover_img');
              result.src=ur;
              result.style.width = ca.style.width;
              result.style.height = ca.style.height;
            }
          }
          else  {
            _links_sel_current.push(link_data_grouped[found]);
            canvas_draw_lines(link_data_grouped[found].path, 2, link_data_grouped[found].color, 4); 
            if(isSafari == true) {
              var ca = document.getElementById('lines_current_selected_canvas');
              var ur = ca.toDataURL();
              var result = document.getElementById('lines_current_selected_img');
              result.src=ur;
            }
          }
        }
     }
     else {
        if(type == 'array') {
          var year_ = d.year;
          var id = d.id;
        }
        else {
          var year_ = year;
          var id = d;
        }
        var _links;
        var _links_sel = [];
        function showlinks() {
          if(_links_sel.length > 0) {
            if(status == 'hover') _links_sel_all_selected.push(_links_sel);
            else _links_sel_all.push(_links_sel);
            drawLinks(_links_sel,'total',status);
          }
        }
        if(id>=0) {
          $.each(years, function(a,b) { if(b.val == year_) _links = data_prepared[ years[b.pos].pos ][1]; });
          _links.forEach(function(e,i) {
            if(e.target.id == id) {
              _links_sel.push( e );
              svg.selectAll(".node."+formatBlank(e.source.name)).classed("hide",false).classed("fadeOut",false).classed("node--active",true); 
              svg.selectAll(".node."+formatBlank(e.target.name)).classed("hide",false).classed("fadeOut",false).classed("node--active",true); 
            }
          });
          showlinks();
        }
        else {
            var countries = [];
            if(window.Worker !== undefined){
              var worker = new Worker('js/worker/12_task.js');
              worker.addEventListener('message', function(e) {
                if(e.data.cmd == "totalWorldwideBack") {
                  $('.loader').hide();
                  _links_sel = e.data.links;
                  countries = e.data.countries;
                  countries.forEach(function(e,i) {
                    svg.selectAll(".node."+formatBlank(e)).classed("hide",false).classed("fadeOut",false).classed("node--active",true);
                  });
                  showlinks();
                }
              }, false);
              worker.postMessage({'cmd': 'totalWorldwide', 'data': data_prepared, 'year':year_}); 
            } else { 
              for(var i = 0; i<=(year_-1);i++) {
                $('.loader').hide();
                var temp = _links_sel.concat(data_prepared[i][1]); _links_sel = temp;
                data_prepared[i][1].forEach(function(e,i) {
                    if(!isInArray(e.source.name,countries)) countries.push(e.source.name);
                    if(!isInArray(e.target.name,countries)) countries.push(e.target.name);
                });
              }
              countries.forEach(function(e,i) {
                svg.selectAll(".node."+formatBlank(e)).classed("hide",false).classed("fadeOut",false).classed("node--active",true);
              });
              showlinks();
            }
        }
     }
  }
}
function showTa ( id , year , status ) { if ( viewStatus == "current" ) { if ( status === 'hover' || ta_click == false ) _links_sel_current_hover = [ ] if ( status != 'hover' ) _links_sel_current = [ ] } else { if ( status === 'hover' || ta_click == false ) _links_sel_all_selected = [ ] if ( status != 'hover' ) _links_sel_all = [ ] ; } if ( Object . prototype . toString . call ( id ) === '[object Array]' ) { id . forEach ( function ( e , i ) { drawNodesLinks ( e , 'array' ) ; } ) ; } else if ( typeof id === 'number' ) { drawNodesLinks ( id ) ; } function drawNodesLinks ( d , type ) { if ( viewStatus == "current" ) { svg . selectAll ( ".node.ftaID_" + d ) . classed ( "fadeOut" , false ) . classed ( "node--active" , true ) ; var found = - 1 ; link_data_grouped . forEach ( function ( e , i ) { if ( e . id == d ) found = i ; } ) ; if ( found != - 1 ) { if ( status === 'hover' ) { _links_sel_current_hover . push ( link_data_grouped [ found ] ) ; canvas_draw_lines ( link_data_grouped [ found ] . path , 3 , link_data_grouped [ found ] . color , 4 ) ; if ( isSafari == true ) { var ca = document . getElementById ( 'lines_current_selected_hover_canvas' ) ; var ur = ca . toDataURL ( ) ; var result = document . getElementById ( 'lines_current_selected_hover_img' ) ; result . src = ur ; result . style . width = ca . style . width ; result . style . height = ca . style . height ; } } else { _links_sel_current . push ( link_data_grouped [ found ] ) ; canvas_draw_lines ( link_data_grouped [ found ] . path , 2 , link_data_grouped [ found ] . color , 4 ) ; if ( isSafari == true ) { var ca = document . getElementById ( 'lines_current_selected_canvas' ) ; var ur = ca . toDataURL ( ) ; var result = document . getElementById ( 'lines_current_selected_img' ) ; result . src = ur ; } } } } else { if ( type == 'array' ) { var year_ = d . year ; var id = d . id ; } else { var year_ = year ; var id = d ; } var _links ; var _links_sel = [ ] ; function showlinks ( ) { if ( _links_sel . length > 0 ) { if ( status == 'hover' ) _links_sel_all_selected . push ( _links_sel ) ; else _links_sel_all . push ( _links_sel ) ; drawLinks ( _links_sel , 'total' , status ) ; } } if ( id >= 0 ) { $ . each ( years , function ( a , b ) { if ( b . val == year_ ) _links = data_prepared [ years [ b . pos ] . pos ] [ 1 ] ; } ) ; _links . forEach ( function ( e , i ) { if ( e . target . id == id ) { _links_sel . push ( e ) ; svg . selectAll ( ".node." + formatBlank ( e . source . name ) ) . classed ( "hide" , false ) . classed ( "fadeOut" , false ) . classed ( "node--active" , true ) ; svg . selectAll ( ".node." + formatBlank ( e . target . name ) ) . classed ( "hide" , false ) . classed ( "fadeOut" , false ) . classed ( "node--active" , true ) ; } } ) ; showlinks ( ) ; } else { var countries = [ ] ; if ( window . Worker !== undefined ) { var worker = new Worker ( 'js/worker/12_task.js' ) ; worker . addEventListener ( 'message' , function ( e ) { if ( e . data . cmd == "totalWorldwideBack" ) { $ ( '.loader' ) . hide ( ) ; _links_sel = e . data . links ; countries = e . data . countries ; countries . forEach ( function ( e , i ) { svg . selectAll ( ".node." + formatBlank ( e ) ) . classed ( "hide" , false ) . classed ( "fadeOut" , false ) . classed ( "node--active" , true ) ; } ) ; showlinks ( ) ; } } , false ) ; worker . postMessage ( { 'cmd' : 'totalWorldwide' , 'data' : data_prepared , 'year' : year_ } ) ; } else { for ( var i = 0 ; i <= ( year_ - 1 ) ; i ++ ) { $ ( '.loader' ) . hide ( ) ; var temp = _links_sel . concat ( data_prepared [ i ] [ 1 ] ) ; _links_sel = temp ; data_prepared [ i ] [ 1 ] . forEach ( function ( e , i ) { if ( ! isInArray ( e . source . name , countries ) ) countries . push ( e . source . name ) ; if ( ! isInArray ( e . target . name , countries ) ) countries . push ( e . target . name ) ; } ) ; } countries . forEach ( function ( e , i ) { svg . selectAll ( ".node." + formatBlank ( e ) ) . classed ( "hide" , false ) . classed ( "fadeOut" , false ) . classed ( "node--active" , true ) ; } ) ; showlinks ( ) ; } } } } }
show one TA with specific ID
show one TA with specific ID
// reset values // if is array draw all nodes/links, or only one, or no TA at all // show all nodes which belong to TA // show all Links which belong to TA // if year is defined = mouseover in list so draw on canvas 3 // save for screenshot //link_data_grouped[found].members // save for screenshot // user selected a country draw on canvas 2 //link_data_grouped[found].members //.classed("show",true) //.classed("node--active",true) // woldwide // start a web worker if supported, not supoorted by ie9 and ie8 // worker.addEventListener('error', console.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message), false); // Start the worker. //worker.terminate() // fallback for ie8 and ie9