document.writeln("<link rel=stylesheet type=text/css href='resizeimgs.css'>");
document.writeln("<div id=showimage style='position:absolute;visibility:hidden;z-index:999;border:1px solid black'></div>");


// =============================================================================
// Begin user defined variables
// =============================================================================
var resizeType = 1; // 0 = Dynamically resize to a fraction of the users desktop
                    //     width divided by the dynamicDivisor variable below.
                    //     (i.e. 1024/4 = 256 or 1280/4 = 320)
                    // 1 = Resize the image if it is wider than the fixedWidth
                    //     variable below
var myWidth = 0;
var enlargeType    = 1     // 0 = Opens in the same window
                        // 1 = Opens in a new window
var fixedWidth     = 405;  // Resize the image if it is wider than this many
                           // pixels. Only used when resizeType = 1.
var dynamicDivisor = 2;    // Resize images to users screen width divided by
                           // this number. Only used when resizeType = 0.
var alignClose   = "left"; // Values are 'left' or 'right'. Default is right.
var topSpacing   = 145;      // Spaces the pop-up window this number of pixels
                           // from the top of the window
var leftSpacing  = 20;      // Spaces the pop-up window this number of pixels
                           // from the left of the window
// =============================================================================
// End of user defined variables
// =============================================================================


//really not important (the first two should be small for Opera's sake)
PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//don't touch (except to modify the window contents)
function popImageExtra(imageURL,imageTitle,AutoClose,oTimeClose,extraHTML){
   var imgWin = window.open('','_blank','scrollbars=yes,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
   if( !imgWin ) { return true; } //popup blockers should not cause errors
   imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
      'function getRefToDivMod( divID, oDoc ) {\n'+
         'if( !oDoc ) { oDoc = document; }\n'+
         'if( document.layers ) {\n'+
         'if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {\n'+
         'for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {\n'+
         'y = getRefToDivNest(divID,oDoc.layers[x].document); }\n'+
         'return y; } }\n'+
         'if( document.getElementById ) { return oDoc.getElementById(divID); }\n'+
         'if( document.all ) { return oDoc.all[divID]; }\n'+
         'return document[divID];\n'+
      '}\n'+
      'function resizeWinTo() {\n'+
         'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
         'if( !document.images[0].height || window.doneAlready ) { return; }\n'+ //in case images are disabled
         'var oH = getRefToDivMod( \'myID\' ); if( !oH ) { return false; }\n'+
         'var oW = oH.clip ? oH.clip.width : oH.offsetWidth;\n'+
         'var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }\n'+
         'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
         'window.doneAlready = true;\n'+ //for Safari and Opera

         'var mH = screen.availHeight-200, mW = screen.availWidth-200;\n'+
         'if( oH > mH || oW > mW ) {\n'+

         'document.images[0].fullH = oH;\n'+
         'document.images[0].fullW = oW;\n'+

         'var hDif = oH - document.images[0].height;\n'+
         'var wDif = oW - document.images[0].width;\n'+
         'mH = mH - hDif; mW = mW - wDif;\n'+
         'mH = mH \/ document.images[0].height;\n'+
         'mW = mW \/ document.images[0].width;\n'+
         'var zoomFactor = ( mH < mW ) ? mH : mW;\n'+
         'oH = Math.floor( document.images[0].height * zoomFactor );\n'+
         'oW = Math.floor( document.images[0].width * zoomFactor );\n'+

         'document.images[0].style.cursor = \'crosshair\';\n'+
         'document.images[0].title = \'Click to resize image\';\n'+
         'document.images[0].oldHeight = document.images[0].height;\n'+
         'document.images[0].oldWidth = document.images[0].width;\n'+
         'document.images[0].newHeight = oH;\n'+
         'document.images[0].newWidth = oW;\n'+
         'document.images[0].onclick = function () { '+
         'if( this.oldHeight == this.height ) { '+
         'this.height = this.newHeight; this.width = this.newWidth; '+
         'setTimeout(\'window.resizeTo(\'+this.oW+\',\'+this.oH+\'); '+
         'if( !window.opera ) { '+
         'window.moveTo(\'+Math.round((this.scW-this.oW)/2)+\','+
         '\'+Math.round((this.scH-this.oH)/2)+\'); }\',1);\n'+
         '} else { this.height = this.oldHeight; this.width = this.oldWidth; '+
         'window.moveTo(0,0); window.resizeTo(this.scW,this.scH); '+
         'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
         'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
         'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
         'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
         'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
         'if( this.fullH < myH ) { var rs = this.fullH - myH; window.resizeBy(0,rs); '+
         'if( !window.opera ) { window.moveBy(0,Math.round(rs/-2)); } }'+
         'if( this.fullW < myW ) { var rs = this.fullW - myW; window.resizeBy(rs,0); '+
         'if( !window.opera ) { window.moveBy(Math.round(rs/-2),0); } }'+
         '} };\n'+

         'document.images[0].height = oH;\n'+
         'document.images[0].width = oW;\n'+
         'oH += hDif; oW += wDif;\n'+
         '}\n'+

         'if(document.getElementsByTagName) {\n'+
            'for( var l = document.getElementsByTagName(\'a\'), x = 0; l[x]; x++ ) {\n'+
               'if(l[x].className==\'makeright\'&&!l[x].style.position){\n'+
                  'l[x].style.position=\'relative\';\n'+
                  'l[x].style.left=(document.images[0].width-(l[x].offsetWidth+l[x].offsetLeft))+\'px\';\n'+
         '}}}\n'+
         'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
         'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
         'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
         'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
         'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
         'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
         'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
         'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
         'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+

         'document.images[0].oH = oH;\n'+
         'document.images[0].oW = oW;\n'+
         'document.images[0].scH = scH;\n'+
         'document.images[0].scW = scW;\n'+

         'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
         (oTimeClose?('window.setTimeout(\'window.close()\','+oTimeClose+');\n'):'')+
      '}\n'+
      '<\/script>'+
      '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
      (document.layers?('<layer left="0" top="0" id="myID">'):('<div style="position:absolute;left:0px;top:0px;display:table;" id="myID">'))+
      '<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
      (extraHTML?extraHTML:'')+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
   imgWin.document.close();
   if( imgWin.focus ) { imgWin.focus(); }
   return false;
}
// =============================================================================
// Do not modify below this line
// =============================================================================
var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all
var nsx,nsy,nstemp

function walkImages(){
    re = /^img/;
    if (document.images){
        for (a=0;a<document.images.length;a++){
          if (re.test(document.images[a].name)) resizeImage(document.images[a]);
        }
    }
}

function doimage(imgObj,event){
    if (document.images) enlargeimg(imgObj,event);
}

//Thumbnail image viewer-
//© Dynamic Drive (www.dynamicdrive.com)

function resizeImage(thisimage) {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
   if (myWidth > 900) myWidth = 900;
//    if (resizeType == 0) fixedWidth = parseInt((screen.width-200)/dynamicDivisor);
    if (thisimage.width > myWidth-fixedWidth) {
      thisimage.width = myWidth-fixedWidth;
      thisimage.style.cursor='pointer';
      thisimage.style.border = '1px dashed #FF0000'
      thisimage.title='Click the image to enlarge';
   }
}

function enlargeimg(which,e){

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  if (myWidth > 900) myWidth = 900;
    if (resizeType == 0) fixedWidth = parseInt((screen.width-200)/dynamicDivisor);
   if (which.width < myWidth-fixedWidth) {return false;}
   if (enlargeType == 0) {
      if (ie||ns6){
         crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
         if (crossobj.style.visibility=="hidden"){
            crossobj.style.left = (ns6? pageXOffset : document.body.scrollLeft) + leftSpacing
            crossobj.style.top  = (ns6? pageYOffset : document.body.scrollTop) + topSpacing
             alignRE = /^left$/i
            crossobj.innerHTML= (alignRE.test(alignClose))? '<div class=tvhead align=left id=drag>&nbsp;<span class=tvclosex onClick=closepreview() style=cursor:pointer> X </span>&nbsp;<span class=tvclose onClick=closepreview()>Close</span> </div><img src="'+which.src+'">' : '<div class=tvhead align=right id=drag> <span class=tvclose onClick=closepreview()>Close</span>&nbsp;<span class=tvclosex onClick=closepreview() style=cursor:pointer> X </span>&nbsp;</div><img src="'+which.src+'">';
            crossobj.style.visibility="visible"
         }
         else
            crossobj.style.visibility="hidden"
            return false
      }
      else if (document.layers){
         if (document.showimage.visibility=="hide"){
            document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="'+which.src+'" border=0></a>')
            document.showimage.document.close()
            document.showimage.left=e.x
            document.showimage.top=e.y
            document.showimage.visibility="show"
         }
         else
            document.showimage.visibility="hide"
            return false
      }
      else
      return true
   }
   else if (enlargeType == 1) {
      popImageExtra(which.src,which.src);
      // eval('window.open("showpic.asp?pic=' + which.src + '","","width='+which.width+'px,height='+which.height+'px,resizable=1,scrollbars=1")')
   }
}


function closepreview(){
   crossobj.style.visibility="hidden"
}

function drag_dropns(name){
   temp=eval(name)
   temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
   temp.onmousedown=gons
   temp.onmousemove=dragns
   temp.onmouseup=stopns
}

function gons(e){
   temp.captureEvents(Event.MOUSEMOVE)
   nsx=e.x
   nsy=e.y
}
function dragns(e){
   temp.moveBy(e.x-nsx,e.y-nsy)
   return false
}

function stopns(){
   temp.releaseEvents(Event.MOUSEMOVE)
}

function drag_drop(e){
   if (ie&&dragapproved){
   crossobj.style.left=tempx+event.clientX-offsetx
   crossobj.style.top=tempy+event.clientY-offsety
   }
   else if (ns6&&dragapproved){
   crossobj.style.left=tempx+e.clientX-offsetx
   crossobj.style.top=tempy+e.clientY-offsety
   }
   return false
}

function initializedrag(e){
   if (ie&&event.srcElement.id=="drag"||ns6&&e.target.id=="drag"){
   offsetx=ie? event.clientX : e.clientX
   offsety=ie? event.clientY : e.clientY

   tempx=parseInt(crossobj.style.left)
   tempy=parseInt(crossobj.style.top)

   dragapproved=true
   document.onmousemove=drag_drop
   }
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
document.onload=walkImages();



