jQuery(document).ready(function() {
   // generate markup
   jQuery('.panel').hover(function(){   	
   	 	var id = jQuery(this).children(".panel-image").attr('id');   	 	
   	 	var pos = findPos(this);
   	 	var imgheight = jQuery(this).children(".panel-image").height();
   	 	var popupheight = jQuery("#panel-popup-"+id).height();
   	 	var diff = parseInt(popupheight-imgheight);
   	 	var top = imgheight;
   	 	if(diff>0)
			top = imgheight+diff-20;
   	 	jQuery("#panel-popup-"+id).css({"top": "-"+top+"px", "left": "-10px"});
   	 	jQuery("#panel-popup-"+id).show("fast");   	 	
   },
   function() {
   		var id = jQuery(this).children(".panel-image").attr('id');   	 	
   		setTimeout(function() { jQuery("#panel-popup-"+id).hide() }, 200);

   	}
   	);   	
});

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
	} while (obj = obj.offsetParent);
	return [curleft,curtop];
	}
}
