jQuery.noConflict();
(function($) { 
	var hovercount = 3000;
	$(document).ready(function(){
		$("#billeder img").each(function(i,val){
			$(this).attr("sid",i);
		});
		$("#billeder img").hover(function(){
			var offset = $(this).offset();
			var oleft = (offset.left-($(this).attr("owidth")/2))+$(this).width()/2;
			var otop = (offset.top-($(this).attr("oheight")/2))+$(this).height()/2;
			$("body").prepend('<div id="sid_'+$(this).attr("sid")+'" style="position: absolute;top:'+offset.top+'px;left:'+offset.left+'px;"><img src="'+$(this).attr("src")+'" width="'+$(this).attr("twidth")+'" height="'+$(this).attr("theight")+'" /></div>');
			//$("#sid_"+$(this).attr("sid")).css("opacity","0.0");
			hovercount++;
			$("#sid_"+$(this).attr("sid")).css("z-index",hovercount);
			$("#sid_"+$(this).attr("sid")+"").stop().animate({ 
				//opacity: 1.0,
				left: oleft,
				top: otop
			}, 500 );
			$("#sid_"+$(this).attr("sid")+" img").stop().animate({ 
				width: $(this).attr("owidth"),
				height: $(this).attr("oheight")
			}, 500);
			var twidth = $(this).attr("twidth");
			var theight = $(this).attr("theight");
			var owidth = $(this).attr("owidth");
			var oheight = $(this).attr("oheight");
			$("#sid_"+$(this).attr("sid")+"").hover(function(){
				hovercount++;
				$(this).css("z-index",hovercount);
				$(this).find("img").stop().animate({ 
					width: owidth,
					height: oheight
				}, 500 );
				$(this).stop().animate({ 
					//opacity: 0.0,
					left: oleft,
					top: otop
				}, 500);
			},function(){
				$(this).find("img").stop().animate({ 
					width: twidth,
					height: theight
				}, 500 );
				$(this).stop().animate({ 
					//opacity: 0.0,
					left: offset.left,
					top: offset.top
				}, 500,"",function(){
					$(this).remove();
				});
			});
		},function(){});
	});
	$(window).load(function() {
		$("#billeder img").each(function(i,val){
			var width = $(this).width();
			var height = $(this).height();
			$(this).removeAttr("width").removeAttr("height").removeAttr("style");
			var orgwidth = $(this).width();
			var orgheight = $(this).height();
			$(this).attr("twidth",width).attr("owidth",orgwidth).attr("theight",height).attr("oheight",orgheight);
			$(this).width(width).height(height);
		});
	});
})(jQuery);
