$(document).ready( function() {
 if ($('table.col7_images').length > 0) // make sure we have cards and that these cards have summaries on them
  {
    var presentation = $('table.col7_images').parents('div.presentation');
    presentation.find('div[class^=embedded]').hide();

    presentation.find('table.col7_images td[class^=box]').click(function(){
      var presentation = $(this).parents('div.presentation');
      presentation.find('div[class^=embedded]').hide();
      var num = parseInt( $(this).attr('class').match(/\d+$/) );
      presentation.find('div.embedded' + num).show();
    });
    
    presentation.find('div.startImage img').imagesLoaded(function() {
     // alert( ($this).length );
      $(this).each(function() {
        var $this, url, par;
        
        $this = $(this);
        url = $this.attr('src');
        par = $this.parent();

        $this.remove();

        par
          .css({
            'background' : 'url(' + url + ') no-repeat center center'
          });
      }); // this.each
    }); //imagesLoaded
    
  }
  
  if ($('table.col7_links').length > 0) // make sure we have cards and that these cards have summaries on them
  {
    var presentation = $('table.col7_links').parents('div.presentation');
    presentation.find('div[class^=embedded]').hide();
    presentation.find('div[class^=subtitle]').hide();
    
    presentation.find('div.startVideo').hide();
    presentation.find('div.startImage').show().click(function(){
      $(this).hide();
      $(this).siblings('div.startVideo').show();
    });
    

    presentation.find('div[class^=image] img').imagesLoaded(function() {
     // alert( ($this).length );
      $(this).each(function() {
        var $this, url, par;
        
        $this = $(this);
        url = $this.attr('src');
        par = $this.parent();

        $this.remove();

        par
          .css({
            'background' : 'url(' + url + ') no-repeat center center'
          });
      }); // this.each
    }); //imagesLoaded


    presentation.find('div.startImage').mouseenter(function() {
      $(this).siblings('div.subtitle').show();
      $(this).css({'cursor':'pointer'});
    }).mouseleave(function() {
      $(this).siblings('div.subtitle').hide();
    });

    $('table.col7_links td[class^=box]').click(function(){
      var presentation = $(this).parents('div.presentation');
      var num = parseInt( $(this).attr('class').match(/\d+$/) );
      var link = presentation.find('div.embedded' + num).find('a').attr('href');
      window.open(link, 'newWin' + num);
    });
  }
  
  /* michela */
  
  if ($('table.col3').length > 0)
  {
    var presentation = $('div.presentationCol3');
    
    presentation.find('div[class^=embedded]').hide();
    presentation.find('div[class^=rollover]').hide();

    presentation.find('div.startImage').imagesLoaded(function() {
     // alert( ($this).length );
      $(this).each(function() {
        var $this, url, par;
        
        $this = $(this);
        url = $this.attr('src');
        par = $this.parent();

        $this.remove();

        par
          .css({
            'background' : 'url(' + url + ') no-repeat center center'
          });
      }); // this.each
    }); //imagesLoaded

    presentation.find('table.col3 td[class^=box]').mouseenter(function() {
      $(this).find('div[class^=image]').hide();
      $(this).find('div[class^=rollover]').show();
      $(this).css({'cursor':'pointer'});
    }).mouseleave(function() {
      $(this).find('div[class^=rollover]').hide();
      $(this).find('div[class^=image]').show();
    });

    $('table.col3 td[class^=box]').click(function(){
      var presentation = $(this).parents('div.presentationCol3');
      var num = parseInt( $(this).attr('class').match(/\d+$/) );
      presentation.find('div.viewbox2 div[class^=embedded]').hide();
      presentation.find('div.viewbox2 div.embedded' + num).show();
    });
    
  }
  
  /* jasper */
  if ($('.viewboxJasper').length > 0) {
    $('.viewboxJasper .animation').hide();
    $('.viewboxJasper .startImage').click(function() {
      $(this).hide();
      $(this).siblings('.animation').show();
    });
  }
  
  $('[class^=image]').mouseenter(
		function() {
			$(this).css({'cursor':'pointer'});
		}
	);
  
});

