function doFlex() {
  if (document.all&&document.getElementById('holder')) {
    document.getElementById('holder').style.width = document.documentElement.clientWidth < 779 ? "779px" : document.documentElement.clientWidth > 1003? "1003px" : "auto";
  }
}

function attachExternals() {
  if (document.getElementsByTagName('a')) {
    as = document.getElementsByTagName('a');
    for (var i=0; i<as.length; i++) {
      if (as[i].className.indexOf('external') >= 0) {
        as[i].target = '_blank';
      }
    }
  }
}

function attachZoomImages() {
  if (document.getElementsByTagName) {
    var images = document.getElementsByTagName('img');
    for (var i=0; i<images.length; i++) {
      if (!images[i].className.indexOf('zoom')) {
        //zoomheight = ((images[i].height*640)/images[i].width);
        zoomheight = 382;
        zoomlink = document.createElement('a');
        zoomlink.className = 'enlarge';
        zoomlink.href = images[i].src.replace('small','large');
        zoomlink.onclick = function() {
          zoomsettings = 'width=750,height='+zoomheight+',menubar=no,toolbar=no,status=no,resizable=yes';
          zoomwindow = window.open('','',zoomsettings);
          zoomwindow.document.open();
          zoomwindow.document.write('<html><head><title>Liability Solutions - Zoom</title></head><body style="text-align:center;margin:0;padding:0;"><img src="'+this+'" /></body></html>');
          if (window.focus) zoomwindow.focus();
          return false;
        }
        images[i].parentNode.appendChild(zoomlink);
        zoomlink.appendChild(images[i]);
/*        zoombreak = document.createElement('br');
        zoomtext = document.createTextNode('Click image to enlarge');
        zoomspan = document.createElement('span');
        zoomlink.appendChild(zoombreak);
        zoomspan.appendChild(zoomtext);
        zoomlink.appendChild(zoomspan);*/
      }
    }
  }
}

function init() {
  doFlex();
  attachExternals();
  attachZoomImages();
}

window.onresize = init;
