function changeLinks()
    {
      var as,i,islink;
// grab all links, loop over them;
      as=document.getElementsByTagName('a');
      for(i=0;i<as.length;i++)
      {
// check which link has a target attribute, and send this one to popup
      if (as[i].getAttribute('href')) 
       {
        if( (Right( (as[i].getAttribute('href')).toLowerCase(),4) == '.jpg') ||
            (Right( (as[i].getAttribute('href')).toLowerCase(),4) == '.gif')  )
        {
//         as[i].onclick=function(event){return(doTooltip(event,0,this));};
           as[i].onclick=function(event){return(OWOWenlarge(this.href,event,'center',300,300));};
//          as[i].onclick=function(){return(Openwin(this));};
//         as[i].onMouseover=function(){doTooltip(event,0,this);return false};
//         as[i].onmouseout=function(){hideTip();return false};
         }
        }  
      }
    }



    function popup(o)
    {
// open a new window with the location of the link's href
      window.open(o.href,'newwin','height=400,width=400');
      return false;
    }

/* window 'load' attachment */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


// if the browser can deal with DOM, call the function onload
    if(document.getElementById && document.createTextNode)
    {
//      window.onload=changeLinks
      addLoadEvent(changeLinks);
//      window.onload=initTip;

    }

// #####################################
function Left(str, n){
  if (n <= 0)
      return "";
  else if (n > String(str).length)
      return str;
  else
      return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// ######################### NEW POPUP #############################
// EXAMPLE:
// onClick="return OWOWenlarge('lemoncake.jpg',event,'center',300,375)">

document.write('<div id="OwowShowimage"></div>')
document.write('<style type="text/css">');
document.write('#OwowShowimage{position:absolute;visibility:hidden;');
document.write('border: 1px solid rgb(65,35,35);}');
document.write('#dragbar{cursor: hand;cursor: pointer;cursor: move;background-color: #EFEFEF;');
document.write('min-width: 100px; /*NS6 style to overcome bug*/');
document.write('}');
//document.write('.loading {background: url(/images/loading.gif) no-repeat; background-position: 50% 50%;}');
document.write('.loading {background: url(/images/loading.gif) no-repeat; background-position: 90% center;}');
document.write('#dragbar #closetext{color:rgb(65,35,35);font-family:Arial, Helvetica, sans-serif; font-size:10pt;font-weight: bold;margin-right: 1px;}');
document.write('</style>');

// ### script
/***********************************************
* Image Thumbnail viewer- ? Dynamic Drive (www.dynamicdrive.com)
* Last updated Sept 26th, 03'. This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode &&
document.compatMode!="BackCompat" && !window.opera)?
document.documentElement : document.body
}

var lastimgwidth=0;
var lastimgheight=0;


function OWOWenlarge(which, e, position, imgwidth, imgheight, Dtype){

if (lastimgwidth==0||lastimgheight==0) {
lastimgwidth=imgwidth;
lastimgheight=imgheight;
}
RePosition=false;
 x= ResetEnlarge(e,position, lastimgwidth, lastimgheight)
RePosition=true;
if (x==false) {
var InnerParts;
//InnerParts='<table width=1 border="0" CELLSPACING=0 BGCOLOR="white"><tr><td align="Left" id="dragbar"><font color=black>Drag</font></td><td width="5%"><a id="closetext" href="#" onClick="closepreview();return false;"><font color=black>X</font></a></td></tr><tr><td COLSPAN="2">'
//InnerParts='<table width=1 border="1" CELLSPACING=0 BGCOLOR="white"><tr><td>'
//
InnerParts='<table width=150 height=150 border="0" CELLSPACING=0 style="background-color:rgb(65,35,35)" xBGCOLOR="white" xbackground="/loading.gif"><tr><td align="Center" height=1 id="dragbar"><a id="closetext" href="#" onClick="closepreview();return false;">Close</a></td></tr><tr><td COLSPAN="1" Class="loading">'
  if (Dtype=="URL") {
   InnerParts+='<iframe width="'+imgwidth+'" height="'+imgheight+'" src="'+which+'"></iframe>';
  }
  else
  {
//InnerParts+='<A HREF="#" STYLE="text-decoration: none" onClick="closepreview();return false;"><img src="'+which+'" border=2></A>'
InnerParts+='<A HREF="#" STYLE="text-decoration: none" onClick="closepreview();return false;"><img src="'+which+'"  onload="ResetEnlarge(this ,\'center\', this.offsetWidth, this.offsetHeight)" border=></A>'
  }
InnerParts+='</td></tr></table>'

crossobj.innerHTML=InnerParts

//crossobj.style.visibility="visible"
return false
}
else {//if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}
}

function ResetEnlarge(e, position, imgwidth, imgheight)
 {
   imgwidth=imgwidth-143
 
   
  if (ie||ns6)
   {
    crossobj=document.getElementById? document.getElementById("OwowShowimage") : document.all.OwowShowimage
    if (position=="center")
     {
      pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
      horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
      vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
      if (window.opera && window.innerHeight) //compensate for Opera toolbar
        vertpos=pgyoffset+window.innerHeight/2-imgheight/2
      vertpos=Math.max(pgyoffset, vertpos)
     }
    else
     {
      var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
      var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
     }
     if (RePosition==true) {
   crossobj.style.left=horzpos+"px"
   crossobj.style.top=(vertpos-0)+"px"
   crossobj.style.visibility="visible"
   }
return false
 }
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}


function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if
(ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
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")
