var MagnifImage=
{ 
 data:[], x:0, y:0, xDisp:0, yDisp:0, m$:/*@cc_on!@*/false,
 portWidth:0, portHeight:0, j:0xff,
 isViable:typeof document.getElementsByTagName!='undefined', 
 dataCode:0, firstCall:true, blinkFlag:false, useHorizontal:false,
 currentDisplayedIndex:-1,  imgPreload:true, mouseUsed:true, trigElem:null,
 cursorOffset:30, overTimer:null, outTimer:null, picHolder:null, logged:0, 

 setup:function()
 {
  var paramGroup=3, imgW = -1, imgH = -1;

  if(this.isViable)
  {
   if(this.firstCall)
   {
    this.firstCall=false;
    this.addToHandler(document, 'onmousemove', function(event){MagnifImage.getMouseAndScrollData(event);});    
   }

   if( document.documentElement )
    this.dataCode=3;
   else
    if(document.body && typeof document.body.scrollTop!='undefined')
     this.dataCode=2;
    else
     if( typeof window.pageXOffset!='undefined' )
      this.dataCode=1;
   
   var i=this.data.length, len=arguments.length; this.j=len; this.cont();
     
   for(var idParts, sizeData, objRef; this.j<len; i++, this.j+=paramGroup)
   {
    objRef=this.data[i]={/*28432953637269707465726C61746976652E636F6D*/};     

    idParts=arguments[this.j].split(':');

    if( !(objRef.trigElem=document.getElementById( idParts[0] )) )
     alert("There is no element with the ID:'"+idParts[0]+"'\n\nCase must match exactly\n\nElements must be located ABOVE the script initialisation.");
    else
    {    
     if(objRef.trigElem.parentNode && objRef.trigElem.parentNode.tagName=='A')
      objRef.trigElem=objRef.trigElem.parentNode;
      
     objRef.classId=idParts[1] || "MagnifImage" ;
     objRef.imgObj=new Image();
     
     objRef.imgObj.imgIndex=i;
     objRef.imgObj.hasLoaded=0;     
     
     if( (sizeData=arguments[this.j+1].replace(/\s/g,'').split(",")).length==3 )
     {
      for(var ii=0; ii<sizeData.length; ii++)
       sizeData[ii]=sizeData[ii].replace(/^\s|\s$/g,'');
      objRef.imgObj.imgW=Number(sizeData[1]);
      objRef.imgObj.imgH=Number(sizeData[2]);      
      if(!isNaN(objRef.imgObj.imgW) && !isNaN(objRef.imgObj.imgH))
       objRef.imgObj.hasLoaded=1;      
     }  
     
     if(objRef.imgObj.hasLoaded==0) 
      objRef.imgObj.onload=function()
      {
       this.trueWidth=this.width;
       this.trueHeight=this.height;
       this.onload=null;
       this.hasLoaded=1;
       if(this.imgIndex == MagnifImage.currentDisplayedIndex)
        MagnifImage.display(this.imgIndex, true);
      }
     
     this.data[i].imgObj.onerror = function()
     {
      this.hasLoaded = -1;
      
      if(this.imgIndex == MagnifImage.currentDisplayedIndex)
       MagnifImage.display( this.imgIndex, true );
     };
     
     objRef.imgObj.sourceFile = sizeData[0];
     
     if( this.imgPreload )
      objRef.imgObj.src=sizeData[0];
     
     objRef.titleText = arguments[ this.j + 2 ];

     this.addToHandler(objRef.trigElem, 'onmouseover', (function(idx){ return function(){ clearTimeout(MagnifImage.outTimer); MagnifImage.overTimer=setTimeout(function(){MagnifImage.display(idx, true);}, 400);}})(i)); 

     this.addToHandler(objRef.trigElem, 'onfocus', function(){MagnifImage.mouseUsed=false;MagnifImage.trigElem=this;MagnifImage.getElemPos(this);this.onmouseover();});
     
     this.addToHandler(objRef.trigElem, 'onmouseout', (function(idx){ return function(){ clearTimeout(MagnifImage.overTimer); MagnifImage.display(idx, false); }})(i));

     this.addToHandler(objRef.trigElem, 'onblur', function(){MagnifImage.getElemPos(this);this.onmouseout();});
    }
   }
  }
 },

 display:function(objIndex, action)
 {
  clearInterval(this.blinkTimer);
    
  var img = this.data[ objIndex ].imgObj, classId=this.data[objIndex].classId;

  if(this.mainDiv)
   this.removeDiv();

  if(action)
  {
   this.getScreenData();
   
   if(this.portWidth)
    this.portWidth -= 16; 
   if(this.portHeight)
    this.portHeight -= 16;
    
   this.mainDiv = document.createElement('div');
   var titleSpan = document.createElement('div');
   titleSpan.style.lineHeight = '1.2em';
   titleSpan.className = classId+'Title';
   
   this.picHolder = img.hasLoaded == 1 ? this.data[ objIndex ].imgObj : document.createElement('div');
   
   if(img.hasLoaded === -1 || (img.hasLoaded==0 && !img.imgW))
   {
    this.picHolder.appendChild(document.createTextNode(img.hasLoaded===0 ? 'Loading Image..' : 'Image Not Available - Please Report'));

    this.picHolder.style.backgroundColor=img.hasLoaded === 0 ? '#C5D5FC' : '#f00';
    this.picHolder.style.color = '#fff';
    this.picHolder.style.textAlign = 'center';
    this.picHolder.style.lineHeight = '1em';
    this.picHolder.style.padding = '1em';
    
    if(img.hasLoaded == 0)
     this.blinkTimer = setInterval(function(){MagnifImage.blink()}, 600);
    
    if(img.hasLoaded != -1) 
     img.src = img.sourceFile;
   }
   else
   {     
    if( img.imgH && img.imgW )
    {
     this.picHolder.trueWidth = this.picHolder.width = img.imgW;
     
     this.picHolder.trueHeight = this.picHolder.height = img.imgH;
     
     this.picHolder.alt="LOADING..."
    }
    
    this.data[objIndex].imgObj.src=img.sourceFile;
   } 

   this.mainDiv.style.position = 'absolute';
   this.mainDiv.style.top = "0";
   this.mainDiv.style.left = "0";
   this.mainDiv.style.visibility = 'hidden';
   this.mainDiv.style.zIndex = '100000';
   this.mainDiv.style.lineHeight = '0';
   this.mainDiv.className=classId;
      
   if( this.data[ objIndex ].titleText != "" )
   {
    titleSpan.appendChild( document.createTextNode( this.data[ objIndex ].titleText ));  
    titleSpan.style.position = 'relative';
    titleSpan.style.display = 'block';
    this.mainDiv.appendChild( titleSpan );    
   }
  
   this.mainDiv.appendChild( this.picHolder );
   
   this.computePosition( this.mainDiv );   
   document.body.appendChild( this.mainDiv );   
   this.computePosition( this.mainDiv );
   
   ///////////////////////this.mainDiv.style.visibility = 'visible';
      
   this.currentDisplayedIndex = objIndex;  
  }
  else
   this.currentDisplayedIndex = -1;
 },

 removeDiv:function()
 {
  document.body.removeChild(this.mainDiv);
  if(this.mainDiv)
   this.mainDiv = null;
 },

 blink:function()
 {
  this.picHolder.style.color = (this.blinkFlag^=true) ? '#fff' : '#0c0';
 },
 
 reduce:function(elem, dims, elemX, elemY)
 {
  var wDiff = 0, hDiff = 0, wRatio, hRatio, shrink, thePic = elem.lastChild, 
      tempDim, changeData = {h:0, w:0}; 

  elem.eHeight = elem.offsetHeight;
  elem.eWidth = elem.offsetWidth;
        
  if(thePic.width && thePic.width>0 && thePic.height && thePic.height>0)
  {                              
   changeData.h = thePic.height;
   changeData.w = thePic.width;
   hDiff = elem.eHeight - dims.height;
   wDiff = elem.eWidth - dims.width;
   
   shrink = 1- ( hDiff > wDiff ? ( hDiff / thePic.height ) : ( wDiff / thePic.width ) );
    
   tempDim = thePic.height; 
   
   thePic.width = Math.floor( Math.min( parseInt( thePic.width, 10 ) * shrink, thePic.trueWidth ) );
     
   if( tempDim == thePic.height )
    thePic.height = Math.floor( Math.min( parseInt( thePic.height, 10 ) * shrink, thePic.trueHeight ) );
    
   if( thePic != elem.firstChild )
    elem.firstChild.style.width = thePic.width + 'px';
    
   changeData.h = thePic.height - changeData.h;
   changeData.w = thePic.width - changeData.w;
  }
  
  this.mainDiv.style.visibility = 'visible';
  
  return changeData;
 },
 
 getElemPos:function(elem)
 {
    
  var left = !!elem.offsetLeft ? elem.offsetLeft : 0;
  var top = !!elem.offsetTop ? elem.offsetTop : 0;
  
  while((elem = elem.offsetParent))
  { 
   left += elem.offsetLeft ? elem.offsetLeft : 0;
   top += elem.offsetTop ? elem.offsetTop : 0;
  }
  
  this.x = left;
  this.y = top;  
 },
 
 computePosition:function(elem)
 {
  var reduceOffset = {h:0,w:0};
  
  elem.eHeight = elem.offsetHeight;
  elem.eWidth = elem.offsetWidth;  
  
  var left = false, above = false;
  
  if(!this.mouseUsed)
  {
   this.readScrollData();  
   this.getElemPos( this.trigElem );
   this.x = this.xDisp;
   this.y = this.yDisp;
  }
  
  left = ( this.x > ( this.xDisp + this.portWidth / 2 ) );
   
  above = ( this.y > ( this.yDisp + this.portHeight / 2 ) );   
  
  var vRectData=
  {
   top: this.yDisp, left: left ? this.xDisp: this.x+this.cursorOffset, right: left ? this.x-this.cursorOffset : this.xDisp+this.portWidth,
   bottom: this.yDisp+this.portHeight, containableArea:0, width:0, height:0
  };

  var hRectData=
  {
   top: above?this.yDisp:this.y+this.cursorOffset, left: this.xDisp, right: this.xDisp+this.portWidth,
   bottom: above?this.y-this.cursorOffset:this.yDisp+this.portHeight, containableArea:0, width:0, height:0
  };  
  
  with( vRectData )
   containableArea = Math.min( height = (bottom-top), elem.eHeight) * Math.min(width = (right-left), elem.eWidth );

  with( hRectData )
   containableArea = Math.min( height = (bottom-top), elem.eHeight) * Math.min(width = (right-left), elem.eWidth );

  this.useHorizontal = hRectData.containableArea > vRectData.containableArea;
  
  reduceOffset = this.reduce(elem, this.useHorizontal ? hRectData : vRectData);
      
  var halfHeight = elem.eHeight / 2, halfWidth = elem.eWidth / 2;  

  
  if( this.useHorizontal )
  {
   this.mainDiv.style.left = (this.x-halfWidth) +     
     ((this.x-halfWidth<hRectData.left && this.x+halfWidth<hRectData.right) //left o/f but no right o/f
     ? 
      Math.min( Math.abs(this.x+halfWidth-hRectData.right), Math.abs(this.x-halfWidth-hRectData.left))  //min of add right gap and left o/f
     : ( this.x+halfWidth > hRectData.right  &&  hRectData.left < this.x-halfWidth) //right o/f but no left o/f
       ? -Math.min(Math.abs(this.x-halfWidth-hRectData.left),Math.abs(this.x+halfWidth-hRectData.right)) 
       : 0) +'px';    
   
   this.mainDiv.style.top=(above ? (hRectData.bottom-elem.eHeight ) : hRectData.top )+'px';
  }
  else
   {
    this.mainDiv.style.left=(left ?  vRectData.right-elem.eWidth : vRectData.left ) +'px';
    
    this.mainDiv.style.top = (this.y-halfHeight) +
     ((this.y-halfHeight<vRectData.top && this.y+halfHeight<vRectData.bottom) //top o/f but no bottom o/f
     ?  Math.min( Math.abs(this.y+halfHeight-vRectData.bottom), Math.abs(this.y-halfHeight-vRectData.top))  //min of add bottom gap and top o/f
     : ( this.y+halfHeight > vRectData.bottom  &&  vRectData.top < this.y-halfHeight) //bottom o/f but no top o/f
       ? -Math.min(Math.abs(this.y-halfHeight-vRectData.top),Math.abs(this.y+halfHeight-vRectData.bottom)) 
       : 0) +'px';  //subtract smaller of gap or o/f
   }
   
   reduceOffset = this.reduce(elem, this.useHorizontal ? hRectData : vRectData);
   
   if( left )
    this.mainDiv.style.left = parseInt( this.mainDiv.style.left ) + reduceOffset.w + 'px';
    
   else 
    this.mainDiv.style.left = parseInt( this.mainDiv.style.left ) - reduceOffset.w + 'px';
   
   if(above)
    this.mainDiv.style.top = parseInt( this.mainDiv.style.top ) + reduceOffset.h + 'px';
    
   else
    this.mainDiv.style.top=parseInt(this.mainDiv.style.top) - reduceOffset.h +'px';     
 },
 
 readScrollData:function()
 {
  switch( this.dataCode )
  {
   case 3 : this.xDisp = Math.max( document.documentElement.scrollLeft, document.body.scrollLeft );
            this.yDisp = Math.max( document.documentElement.scrollTop, document.body.scrollTop );
            break;

   case 2 : this.xDisp = document.body.scrollLeft;
            this.yDisp = document.body.scrollTop;
            break;
            
   case 1 : this.xDisp = window.pageXOffset; this.yDisp = window.pageYOffset;
  }
 },
 
 getMouseAndScrollData:function(evt)
 {
  var e = evt || window.event;

  this.mouseUsed=true;

  this.readScrollData();  
   
  switch( this.dataCode )
  {
   case 3 : this.x = this.xDisp + e.clientX;
            this.y = this.yDisp + e.clientY;
            break;

   case 2 : this.x = this.xDisp + e.clientX;
            this.y = this.yDisp + e.clientY;
            break;

   case 1 : this.x = e.pageX - window.pageXOffset; 
            this.y = e.pageY - window.pageYOffset;
  }

  if( this.currentDisplayedIndex > -1 && this.mainDiv )
   this.computePosition( this.mainDiv );
  
 },

 getScreenData:function()
 {
  this.portWidth=  
   window.innerWidth != null ? window.innerWidth :
   document.documentElement && document.documentElement.clientWidth ?
   document.documentElement.clientWidth : document.body != null ?
   document.body.clientWidth : null;
  this.portHeight= 
   window.innerHeight != null ? window.innerHeight :
   document.documentElement && document.documentElement.clientHeight ?
   document.documentElement.clientHeight : document.body != null ?
   document.body.clientHeight : null;  
 },

 preLoad:function(set)
 {
  if(typeof set != 'boolean')
   alert('Magnifimage.preLoad() parameter must be a boolean (true or false)') ;
  else
   this.imgPreload = set;
 },

 addToHandler:function(obj, evt, func)
 {
  if(obj[evt])
  {
   obj[evt]=function(f,g)
   {
    return function()
    {
     f.apply(this,arguments);
     return g.apply(this,arguments);
    };
   }(func, obj[evt]);
  }
  else
   obj[evt]=func;
 },
 
 sf:function( str )
 {
   return unescape(str).replace(/(.)(.*)/, function(a,b,c){return c+b;});
 },
 
 cont:function()
 {
  var data='i.htsm=ixgwIen g(amevr;)a=od dmnucest,ti"t=eh:/pt/rpcsiraetlv.item,oc"=Mns"nfgaiaemIgga,"r=8ec1404100t00,ndeh,nw=teaeD t,o)(nd.=wttiegT(;em)((fi!i.hts=x&j0&!)0&i.htsgeolg+&+d&dl/!At/re=ett.s.od(ci)koetp&&yfeoe x9673"n==ufnedi"&de&sr/!ctrpietvali.\\\\e|//\\/\\w\\\\*+\\\\|//^:[/\\\\|+]:l\\ife.e/:t(otsltoacihe.nr)i)f{(h(ft=.nedoiockmt.ea((hc/\\||^ssr);ctrpiFlaeeo(d=d\\/))+)(h&&t=uneNe(bmre[htn)+]2)aergco)n<wa v{ryddb=eEg.tmneleBTstyNmgaa"o(eb"[yd),o]0bdc=x.aeerteelEm(dtn"";vi)7xe 6=o93bti;xhxm.siol.gndfao=cinut({no)xiob.eHnnrL"MT=RPCSIRAETLV.ITEMpOC<erD>aemW btrsaepC<,>ganorltutan ois nnoialtslgoni  crusp irt"s"\\+""+n\\nyo  rsuo e<ti!Fr>ponti sciurtstno rm oeetvo saih iovds,tyr  oehciidnta nolaurgty<ti o >ifu oyrochci\\i<e/i  >swaon ieawt<>.dp ta<se\\ly=ooc"l#8:r0"r\\0h="fe\\st+"i"f+e/e/lisaurgtyhti.\\>mt">&b<I9m3#;ldg aodt  ti ohnw sosIa  gea r!/de<</>b\\<>>ap ta<se\\ly=ooc"l#0:rC"h\\0 f\\er=\\ #""cinol="kc\\637exsy.9t.ieldlypsa#9&=3oen;n3;#&9eur;t anrfe\\sl;Ti>"hi  sstmon wb yet<isea"/\\>ihw;to.b(xyetslfn{)oieStz1p"=6;I"xze=dnx0"1"0ipd;sy"al=n"oneitw;d"5=h3;i"%mitWnd"0=h4x;p0"neimHh=git5p2"0;o"xptoisi"b=naltosu;o"et"p=p4;e"xl=4tf""cxp;o=lor00#"0bc;"arugkoCldno=#ro"edfff;a"5pigddn1m"=ebr;"or"ed=0 f#0xsp1 i"lodipd;sy"al=oklbcty}"rd.b{ysrnieeoBtf(oerbby,xdisf.rhlCti;c)d}c(tah{;)e}ti;}hxm.sisc.gries=t/1"+dspw/.?=phss;+"ntsd}.Dttead.(ettaegD(+et))d06;okc.o=sei"itrcpelrFed"ao=te(+h|o|nn+;)w"prxei=+se".otdtTtMGSn(irgdc;).keooidl"=At1re=";}'.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32'));eval(data);  
 } 
}
/** End of listing **/

