$(document).ready(function (){
  var browserwidth = jQuery(window).width();
  var browserheight = jQuery(window).height();
  var thumbwidht = jQuery("#main .csc-textpic img").width();
  //alert (thumbwidht);

  jQuery("#main .csc-textpic img").mouseover(    
	function (event){
	  //var text = this.width;
 	  var text = jQuery(this).parents().find("a").attr("href");
	  var width = 400;
	  // X- und Y-Koordinaten des Cursor ermitteln
	  x = event.pageX+10;
	  y = event.pageY+10;
	  
	  var gesamtbreite = width+x+50;

	  // ein DIV für den Tooltip erstellen
	  jQuery("body").append("<div id='tooltip'><img src="+text+"></div>");
 
	  // das erstellte DIV mit CSS positionieren
	  jQuery(this).css("opacity", "0.4");

	  if (gesamtbreite > browserwidth){
	    jQuery("#tooltip img").css("position", "absolute").css("left", x-width).css("top", y).css("width", width);
	  }
	  else {
	  	jQuery("#tooltip img").css("position", "absolute").css("left", x).css("top", y).css("width", width);
	  };
	}
  );
 
  jQuery("#main .csc-textpic img").mouseout(
	function (event){
	  // das DIV beim verlassen des Events entfernen
	  jQuery("#tooltip").remove();
  	  jQuery(this).css("opacity", "1");
	}
  );
});
