/**
 * Screen Concept Website
 * References
 *
 * The www.screenconcept.ch website is heavily using JavaScript
 * for visual enjoyment, but the whole site degrades beautifully
 * using the unobtrusive JavaScript philoshophy.
 *
 * @author Roman Simecek
 */
var tags = new Array();
function addReferencesBehaviour() {
  console.log('***** addReferencesBehaviour');
  tags = new Array();
  $('#references-selection ul li a').each(function(index, element) {
    $(this).bind("click", function(event) {
      event.preventDefault();
      if($(this).attr('class')!='selected'){
        tag = $(this).attr('id');
        tags.push(tag);
        $('#references-list ul li').each(function(index, element) {
          $(this).hide();
        });
        for(var i = 0; i < tags.length; ++i) {
          $('#references-list ul li.' + tags[i]).each(function(index, element) {
            $(this).show();
          });
        }
        $(this).attr('style', 'color:#CCCCCC');
        $(this).attr('class', 'selected');
      }else{
        for(var i = 0; i < tags.length; ++i) {
          if( tags[i]==$(this).attr('id') ){
            rem = i;
          }
        }
        tags.splice(rem, 1);
        if(tags.length > 0){
          $('#references-list ul li').each(function(index, element) {
            $(this).hide();
          });
          for(var i = 0; i < tags.length; ++i) {
            $('#references-list ul li.' + tags[i]).each(function(index, element) {
              $(this).show();
            });
          }
        }else{
          $('#references-list ul li').each(function(index, element) {
            $(this).show();
          });
        }          
        $(this).attr('style', 'color:#333333');
        $(this).attr('class', '');        
      }
    });
  });
  $('#references-list ul li a').each(function(index, element) {
    $(this).bind("mouseover", function(event) {
      event.preventDefault();
      console.log('***** addReferencesBehaviour: show thumbnails');
    });
  });
}

