<?	
	$image_result = mysql_query("SELECT * FROM images WHERE fid = '$fid' order by 'image_id'", $db);
	$image_count = mysql_num_rows($image_result);
	
	$file_path = $setup->url . "/usr/" . $mid;

?>
<script language="javascript">
	
	<?php
	$i = 0;
	while($image = mysql_fetch_object($image_result)){
	?>
	spin<? echo $i; ?> = new Image();
		spin<? echo $i; ?>.src = "<? echo $file_path . "/hta_" . $image->filename; ?>";
	<?	
		$i++;
		} 
	?>
		
	var x = "0"
	var s = ""
	
	function spinIt( image ) {
		s = 1;
		imgmgr.spin_icon.src = eval("spin" + image + ".src");
	}
	
	function autoSpin(i) {
		imgmgr.spin_icon.src = eval("spin" + i + ".src");
	}
	
	function countdown()
		{
		if(s != 1) {
			if(x > <? echo $image_count - 1; ?>) {
				x = 0;
			}
			autoSpin(x);
			x = eval(x + 1);
			timerID = setTimeout("countdown()", 250)
			}
		}
	
</script>
<table cellpadding="0" cellspacing="0" border="0">

	<?
		$image_result2 = mysql_query("SELECT * FROM images WHERE fid = '$fid' order by 'image_id'", $db);
		$first_image = mysql_fetch_object($image_result2);
		$first_image2 = $first_image->filename;
	?>
	
	<tr>
	
		<td height="60" align="center" valign="middle"><a href="<? echo $setup->url; ?>/spin.php?fid=<? echo $fid; ?>" target="_new"><img src="<?php print( $file_path ) . "/hta_" . $first_image2; ?>" name="spin_icon" width="50" border="0"></a></td>
		
	</tr>
	<script>countdown();</script>
</table>