/**
     * Generates a thumbnail image
     *
     * @param int    $video_id  the video sql id
     * @param string $video_code  the video uid
     * @param string $video_type  the video type
     * @param int    $k  the css variable
     * @param int    $width(optional)  the width of the thumbnail image
     * @param int    $height(optional)  the height of the thumbnail image
     * @param string $class(optional)  the class of the thumbnail image
     * @return       $code
     */
	function generateThumbnail( $video_id, $video_code, $video_type, $video_thumbnail, $k, $width=null, $height=null, $class=null, $tooltip_data=null, $video_duration=null)
	{
		global $hwdvsItemid, $mainframe, $hwdvsTemplateOverride;
		$c = hwd_vs_Config::get_instance();
  		$db =& JFactory::getDBO();
		$doc = & JFactory::getDocument();

		if (!isset($width))
		{
			$width = $c->thumbwidth;
		}
		if (!isset($height))
		{
			$height = $width*$c->tar_fb;
		}
		if (!isset($class) || empty($class))
		{
			$class = "thumb".$k;
		}
		if ($tooltip_data[0])
		{
			JHTML::_('behavior.tooltip');
			$tt_title = $tooltip_data[1]." :: ".$tooltip_data[2];
			$thumb_title = "";
			$thumb = "<span class=\"hasTip\" title=\"".$tt_title."\">";
		}
		else
		{
			$thumb = "";
			$thumb_title = $tooltip_data[1];
		}

		if ($c->thumb_ts == 1)
		{
			$thumb.= "<div class=\"watermark_box\">";
		}

		$thumbnailURL = hwd_vs_tools::generateThumbnailURL( $video_id, $video_code, $video_type, $video_thumbnail );

		// assume local for following variables
		$path_ext = (!empty($video_thumbnail) ? $video_thumbnail : "jpg");
		$path_thumb = PATH_HWDVS_DIR.DS."thumbs".DS.$video_code.".".$path_ext;
		$path_thumbd = PATH_HWDVS_DIR.DS."thumbs".DS.$video_code.".gif";

		if (($video_type == "local" || $video_type == "mp4" || $video_type == "swf") && (file_exists($path_thumb) && (filesize($path_thumb) > 0)))
		{
			if ($c->udt == 1 && file_exists($path_thumbd) && (filesize($path_thumbd) > 0))
			{
				if (!defined( '_HWD_VS_DTFLAG' ))
				{
					define( '_HWD_VS_DTFLAG', 1 );
					$doc->addCustomTag("<script type='text/javascript'>function roll_over(img_name, img_src) { document[img_name].src = img_src; }</script>");
				}

				$url_thumbd = URL_HWDVS_DIR."/thumbs/".$video_code.".gif";
				$rand = rand();

				$thumb.= "<img src=\"".$thumbnailURL."\" border=\"0\" alt=\""._HWDVIDS_DETAILS_VIEWVID."\" width=\"".$width."\" height=\"".$height."\" title=\"".$thumb_title."\" class=\"".$class."\" name=\"".$video_code.$rand."\" onmouseover=\"roll_over('".$video_code.$rand."', '".$url_thumbd."')\" onmouseout=\"roll_over('".$video_code.$rand."', '".$thumbnailURL."')\" />";
			}
			else
			{
				$thumb.= "<img src=\"".$thumbnailURL."\" border=\"0\" alt=\""._HWDVIDS_DETAILS_VIEWVID."\" width=\"".$width."\" height=\"".$height."\" title=\"".$thumb_title."\" class=\"".$class."\" />";
			}
		}
		else
		{
			$thumb.= "<img src=\"".$thumbnailURL."\" alt=\""._HWDVIDS_DETAILS_VIEWVID."\" border=\"0\" width=\"".$width."\" height=\"".$height."\" title=\"".$thumb_title."\" class=\"".$class."\" />";
		}

		if ($c->thumb_ts == 1)
		{
			if (!isset($video_duration))
			{
				$video_duration = "N/A";
			}
			else
			{
				$video_duration = hwd_vs_tools::validateDuration($video_duration);
			}
			$thumb.= "<img src=\"".URL_HWDVS_IMAGES."overlay.png\" class=\"watermark\" alt=\"Watermark image\" />
					  <span class=\"timestamp\">".$video_duration."</span>
					  </div>";
		}

		if ($tooltip_data[0])
		{
			$thumb.= "</span>";
		}

		return $thumb;
    }