// JavaScript Document

var currentThumb = "";
function hoverThumb(id) {
	
	el = $(id);
	var b =document.body;
	var file = el.href;
	var ext = file.match(/(.{3}$)/)[1];
	
	el.removeEvent('mouseover');

	if(currentThumb) {
		b.removeChild(currentThumb);
	}

	//var dummy = $('search_value');
	var y = el.getTop() + 20;
	
	var x = el.getLeft() + 20;

 	var th = new Element('div');
	th.className = "imagePreview";
	th.setStyle('left',  x);
	th.setStyle('top', y );
	th.setAttribute('id','imagePreview');	
	
	//
	
	th.addEvent('click',function(){currentThumb = ""; b.removeChild(th)});
	
	th.injectInside(b);
	
	if(ext == 'swf') {
		var thswf = new Element('div');
		thswf.setAttribute('id','swfPreview');
		thswf.injectInside(th);
		
		var so = new SWFObject(file,"preview", "300", "300", "8", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.write("swfPreview");
		//alert("hola");
	} else {
		var thimg = new Element('img');
		thimg.setStyle('visibility', 'hidden' );
		thimg.onload = function() {
			mynewEff = thimg.effect('opacity',{duration: 500, transition: Fx.Transitions.linear, wait: false }).start(0,1);
		}
		thimg.src = file;
		thimg.injectInside(th);
	}
	currentThumb = th;
	
	//el.addEvent('mouseout',function(){currentThumb = ""; b.removeChild(th)});
}
