function dom_init() {
  
  $("#content img[title]").each(function(){
    var mystyle = $(this).attr('style');
    var mytitle = $(this).attr('title');
    var myclass = $(this).attr('class');
    var mywidth = $(this).attr('width');
    
    if (myclass == undefined) {
      myclass = "";
    }
    
    if (mystyle == undefined) {
      if (mywidth) {
        mystyle = "width: " + mywidth + "px;";
      } else {
       mystyle = ""; 
      }
    } else {
      
      if (mystyle.lastIndexOf(';') != mystyle.length-1) {
        var end = "; ";
      } else {
        var end = " ";
      }
      
      mystyle = mystyle + end + "width: " + mywidth + "px;";
    }
    
    if ($(this).parent()[0].tagName == "A") {
      $(this).parent().wrap('<div class="imagewrap '+myclass+'" style="'+mystyle+'"></div>');
      $(this).parent().parent().append('<div class="bu">'+mytitle+'</div>');
    } else {
      $(this).wrap('<div class="imagewrap '+myclass+'" style="'+mystyle+'"></div>');
      $(this).parent().append('<div class="bu">'+mytitle+'</div>');
    }
  });
  

  $("#content a[target=_blank]").each(function(){
    var suffix = this.href.substr(this.href.lastIndexOf('.')).toUpperCase();
    if (suffix == ".JPG" || suffix == ".GIF" || suffix == ".PNG" || suffix == ".JPEG") {
      $(this).addClass('lightbox').fancybox({
        'speedIn' : 600,
        'speedOut' : 300
      });
    }
  });
  
   $('.lightbox').fancybox({
      'speedIn' : 300,
      'speedOut' : 300,
      'overlayOpacity' : '0.5',
      'overlayColor' : '#000000'
    });
    
    $('.lightboxgrid').each(function(){
      var mytitle = $(this).data('title');
      $(this).fancybox({
            'speedIn' : 300,
            'speedOut' : 300,
            'overlayOpacity' : '0.5',
            'overlayColor' : '#000000',
            'title' : mytitle
          });
    });
  
  $("#content a[href^=http]").each(function(){
    if (this.href.toLowerCase().search(window.location.host) && $(this).find('img').length == 0) {
      $(this).addClass('external');
    } 
  });  
  
  
  
  
}
