window.addEvent('domready', function(){

  $$('.det_img img').each(function(img)
  {
    img.setStyle('position', 'absolute');
    img.setProperties({
            thumb_width: img.width,
            thumb_height: img.height,
            zoom_width: 250,
            zoom_height: 250
          });

  if(img.getProperty('width') / img.getProperty('height') > img.getProperty('zoom_width') / img.getProperty('zoom_height')){
    img.setProperty('zoom_width', Math.floor((img.getProperty('width') < img.getProperty('zoom_width')) ? img.getProperty('zoom_width') : img.getProperty('width')));
    img.setProperty('zoom_height', Math.floor(img.getProperty('zoom_width') / img.getProperty('width') * img.getProperty('height')));
  }else{
    img.setProperty('zoom_height', Math.floor((img.getProperty('height') < img.getProperty('zoom_height')) ? img.getProperty('zoom_height') : img.getProperty('height')));
    img.setProperty('zoom_width', Math.floor(img.getProperty('zoom_height') / img.getProperty('height') * img.getProperty('width')));
  }

    img.addEvent('mouseenter', function(e) {

      if(this.getStyle('height') > (this.getProperty('thumb_height') + 'px'))
        return;

      this.setStyle('zIndex', '5');
      
      try{  
        var myEffects = $(this).effects({duration: 300, transition:Fx.Transitions.Sine.easeInOut});
      }
      catch(e)
      {
        var myEffects = new Fx.Morph($(this), {duration: 300, transition: Fx.Transitions.Sine.easeInOut});  
      }
      
      myEffects.start({'height': [this.getProperty('thumb_height'), this.getProperty('zoom_height')], 'width': [this.getProperty('thumb_width'), this.getProperty('zoom_width')], 'left': [0, Math.floor((this.getProperty('zoom_width') - this.getProperty('thumb_width')) / -2)], 'top': [0, Math.floor((this.getProperty('zoom_height') - this.getProperty('thumb_height')) / -2)]});
    });


    img.addEvent('mouseleave', function(e) {
      if(this.getStyle('height') < (this.getProperty('zoom_height') + 'px'))
        return;

      this.setStyle('zIndex', '1');

      try{  
        var myEffects = $(this).effects({duration: 300, transition:Fx.Transitions.Sine.easeInOut});
      }
      catch(e)
      {
        var myEffects = new Fx.Morph($(this), {duration: 300, transition: Fx.Transitions.Sine.easeInOut});  
      }
      
      
      myEffects.start({'height': [this.getProperty('zoom_height'), this.getProperty('thumb_height')], 'width': [this.getProperty('zoom_width'), this.getProperty('thumb_width')], 'left': [Math.floor((this.getProperty('zoom_width') - this.getProperty('thumb_width')) / -2), 0], 'top': [Math.floor((this.getProperty('zoom_height') - this.getProperty('thumb_height')) / -2), 0]});

    });


  });

});

Slimbox.scanPage = function() {
	$$("a").filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	}).slimbox({/* options */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
	window.addEvent("domready", Slimbox.scanPage);
}
