<?

	$dir = "gfx/home_pic_large/";

	if (is_dir($dir)) {
			if ($dh = opendir($dir)) {
				$numberitems=0;
				while (($file = readdir($dh)) !== false) {
					$numberitems++;
				}
			}
		}

		// Open a known directory, and proceed to read its contents
	if (is_dir($dir)) {
		if ($dh = opendir($dir)) {
			$j=0;
			while (($file = readdir($dh)) !== false) {
				if (strpos($file,'jpg',0) || strpos($file,'jpeg',0) || strpos($file,'gif',0))
				{
				$filename[$j]=$file;
				//echo $j.$filename[$j]."<br>";
				$j++;
				}
				
			}
			closedir($dh);
			
			$time_to_mod=date('U');
			$random=rand(0,count($filename)-1);
			$random_image=$filename[$random];
			//echo $random_image;
			//echo $numberitems;
			$caption_query=mysql_query("select * from picture_captions where pic_path='$random_image'");
			$caption=mysql_fetch_array($caption_query);
			echo "<a href=\"#\" onClick=\"MyWindow=window.open('/secure/caption_box.php?pic=$random_image&s=l','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=525,height=650,left=300,top=200'); return false;\"><img width='465' height='190' alt=\"".htmlentities($caption['caption'])."\" src='/gfx/home_pic_large/$random_image' border=0></a>";
		
		}
	}
?>