var ImageHover = Class.create({
	initialize: function(id, img) {
	    var images = img
	    var elem = $$(id)
	    if(elem.length < 1) {
	        return false
	    }
	    elem.each(function(index, item) {
	        var img = new Image()
        	console.log('xxa')
	        Event.observe(img, 'load', function() {
	            var smallDimensions = {width: $(item).attr('width'), height: $(item).attr('height')}
	            var bigDimensions = {width: $(this).attr('width'), height: $(this).attr('height')}
	            var div = $.create('div',{'class':'bigger'}).css({
	                'position': 'absolute',
	                'width': $(this).attr('width'),
	                'height': $(this).attr('height'),
	                'top': 0,
	                'left': 0,
	                'z-index': 100
	            }).hide()
	            if($(item).parent().filter('a').length > 0) {
	                div.append($.create('a',{
	                    'href':$(item).parent().filter('a').attr('href'),
	                    'class':'display-block'
	                }).append(img))
	            } else {
	                div.append(img)
	            }
	            $('body').append(div)
	            $(item).mouseover(function(event) {
	                var position = $(item).offset()
	                position.left -= (bigDimensions.width - smallDimensions.width) / 2
	                position.top -= (bigDimensions.height - smallDimensions.height) / 2
	                $(item).css('visibility','hidden')
	                div.css({
	                    left: position.left,
	                    top: position.top
	                }).show()
	            })
	            div.mouseout(function(event) {
	                div.hide()
	                $(item).css('visibility','')
	            })
	        });
	        Element(img, {'href': images[index]})
	    })
	}
})

