

/* ============================================================================ */

/* TEMPLATE */

(function($) {

        
  $.fn.template = function(settings) {
     
    var config = {};
 
    if (settings) $.extend(config, settings);
    
    if (this.length > 1){ 
      this.each(function() { $(this).segment(settings) }); 
      return this;
    }
    
    var title = '';
            
    this.dispatch = function() {
      
      alert (title)
      
    }
      
    this.initialize = function() {
        
        this.html($(config.html));
        
        
        var $dl = this.find('dl');
        
        if ($dl.length>0)
          this.title = $dl.html();
          
        return this;
    };   
    
    return this.initialize();
    
    
  } // template
  
  /* ============================================================================ */

  /* INTRO */
  
  $.fn.sys_intro = function(settings) {
     
    var config = {};
 
    if (settings) $.extend(config, settings);
 
    this.each(function() {
        
       var $content     = config.$html,
           $dd          = $content.find('dd'),
           $dt          = $content.find('dt');

       //  APPLY TEMPLATE
       
       var $template   = $('<div/>').addClass('sys_intro');
           
       $(this).html('');
    
       $dd.each(function() {$('<p/>').html($(this).html()).appendTo($template)});
              
       $(this).append($template);

       //END
       
     });
 
     return this;
 
   }; // GRID

      

})(jQuery);


/* ============================================================================ */

/* BLANKLINK */
(function($) {

        
  $.fn.blanklink = function(settings) {
     
    var config = {};
 
    if (settings) $.extend(config, settings);
 
    this.each(function() {
        
      $(this).attr('target','_blank');
        
    });
    
  } // outlink
      

})(jQuery);


/* ============================================================================ */

/* TEMPLATES */
  
/* 1. GRID */
  
(function($) {
  
  $.fn.aGrid = function(settings) {
     
    var config = {};
 
    if (settings) $.extend(config, settings);
 
    this.each(function() {
      
       
        
       var $content    = $('<div/>').html($(this).html());
           $dd         = $content.find('dd'),
           $dt         = $content.find('dt');
       

       //  APPLY TEMPLATE
       
       var $template   = $('<div/>').addClass('AT-GRID'),
           $mask       = $('<div/>').addClass('AT-GRID-WRAPPER').appendTo($template),
           $thumbnails = $('<div/>').addClass('AT-GRID-THUMBS').appendTo($mask);
       
       $(this).html('');
    
       
       $dd.each(function($index){
       

          var $self = $('<a/>')
          .addClass('AT-GRID-THUMB')
          .attr('href','/'+$dt.html())
          .attr('rel','address:/'+$dt.html())
          .html($(this).html())
          .appendTo($thumbnails)
          
          
          
          
            var $img = $self.find('img')
       
            $img.css({opacity:0})
            
            var $tmp_img = $('<img/>')
            
            $tmp_img.bind('load',on_cache)
            
            $tmp_img.attr('src',$img.attr('src'))
            
         
            function on_cache(e) {
            
              $img.animate({padding:0},50*$index).animate({opacity:1},950,'easeInOutQuart')
              
            }
       


       
       });
       
       $template.append($mask)
       
       $(this).append($template)

       //END
       
     });
 
     return this;
 
   }; // GRID
   
})(jQuery);
 
