Element.implement({
	doCenter:function(){
		windowSize = window.getSize();
		objectSize = this.getSize();
		this.setStyles({
			position	:	'absolute',
			left		:	windowSize.x/2 - objectSize.x/2,
			top			:	(windowSize.y/2 - objectSize.y/2) + document.getScroll().y
		});
		return this;
	}
});
Element.implement({
	createThumb: function(url_prefix){
		//if (!Browser.Engine.trident4){
			this.addEvent('mouseover',function(e){
					var event = new Event(e);
					var target = event.target;
					y = target.getPosition().y
					x = target.getPosition().x
					x_ = (window.getSize().x - 1000)/2;
					
					var path_array = this.src.split('/');
					var file_name = path_array[path_array.length-1];
							
					$('preview_image')
					.addClass('img_over')
					.setProperty('src', '/uploaded/shop_products/normal/' + file_name)
					.setStyles({
						'opacity':1,
						position:'absolute',
						top:y - 20,
						left:x + target.getSize().x ,
						'display':'block',
						opacity:1,
						'z-index':999999999//getHighestIndex()
					})
			});
			this.addEvent('mouseout',function(){
				$('preview_image').setStyle('display','none');
				$('preview_image').setProperty('src',"");
			});
		//}
	},
	createThumbDetail: function(url_prefix){
		//alert(this.getParent());
		this.preloader = this.getPrevious();
		this.preloader.setStyle('display','none');
		this.addEvent('click',function(){
			var path_array = this.src.split('/');
			var file_name = path_array[path_array.length-1];
			
			this.preloader.setStyles({
				'position'	:	'absolute',
				'display'	:	'block',
				'width'		:	90,
				'height'	:	70,
				'opacity'	:	0.80					
			});	
			var zIndex = getHighestIndex()
			this.thumb = new Element("img",{
				src: '/uploaded/shop_products/large/' + file_name,
				events: {
					'load': (function(img){
						var k = 2;
						this.preloader.setStyle('display','none');
						if (this.thumb)
							this.thumb.setStyles({
								'display':'block',
								opacity:1,
								'z-index':zIndex + 1
							})
							.doCenter()
					}).bind(this,this.thumb),
					'click':function(){
						modalCloseMorph.start({
							'opacity': 0
						});
						this.remove();
					}
				}
			})
			.setStyles({'opacity':0,display:'block'})
			.addClass('browse')
			.inject($E('body'));
			$('domwinModalBackground').setStyles({'z-index':zIndex,'display':'block',opacity:0});
			modalOpenMorph = new Fx.Morph($('domwinModalBackground'), {
				'duration': 200
			});
			modalCloseMorph = new Fx.Morph($('domwinModalBackground'), {
				'duration': 200,
				onComplete: function(){
					$('domwinModalBackground').setStyle('display', 'none');
				}.bind(this)
			});		
			modalOpenMorph.start({
				'opacity': .55
			});
		});
	},
	createThumbNahled: function(){
		this.addEvent('mouseover',function(){

			link_to_small 	= '/uploaded/shop_products/small/';
			link_to_normal 	= '/uploaded/shop_products/normal/';
			var detail = $$('.image_thumb_detail');
			
			var small_path_array = this.src.split('/');
			var small_file_name = small_path_array[small_path_array.length-1];
		
			sizes = new Image();
			sizes.src = link_to_normal + small_file_name;
						
			detail[0].src = link_to_normal + small_file_name;
			//detail[0].setProperties({width:sizes.width,height:sizes.height});
			
		});
		
	}
});
