<?php

	$isLeop = ($_SERVER['SERVER_NAME'] == 'leop');

	require "files.php";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<script>
function showImg(image) {
	// No popup on touch screen device
	// Would be good to tell mouse from touch on touch screen laptop
	if("ontouchstart" in window || window.DocumentTouch && 
			document instanceof DocumentTouch) 
		return;

	open('/hover/showimage.php?i='+image, '_blank');
//	alert("URL="+image);
}
</script>

<style> 
#imap {	
	display:block; 

	width: 712px;
	height: 475px;
	background:url(/hover/fulldeck.jpg)	no-repeat; 

	position: relative; 
	margin:10px 0 	5px 0;
}

#imap dd {position:absolute; padding:0; margin:0;}

<?php

/* Adjustments */
$cels = 14;		// Horz columns
$imgLeft = 620;
$imgTop  = 50;
$teaserTop = 700;	// Teaser is image/text on hover - top is left margin

print "/* Start of generated div */ \n";
$rtop = 1;
$cwidth  = 46;
$cheight = 75;
$row2extra = 10;
		
for($rnum=0; $rnum<7; ++$rnum) {
   $rpos = 1;
   for($cel=1; $cel<$cels; ++$cel) {

   $celname = "row_${rnum}_$cel";
   if(!isset($fname[$celname])) {
	$rpos += $cwidth;
	continue;
   }

   $spanleft = $imgLeft - $rpos;
   $spantop  = $imgTop  - $rtop;
print <<<END

/* Row: $celname */
#imap #$celname {
	left:${rpos}px; 
	top:${rtop}px; 
	z-index:80;
}

#imap a#link_$celname {
	display:block; 
	width:${cwidth}px; height:${cheight}px; 
	text-decoration:none; z-index:20;
	top: ${rtop}px;
}

#imap a#link_$celname:hover, #imap a#link_#celname:active {
	border:1px solid #fc0;
}

#imap a#link_$celname:hover span, #imap a#link_#celname:active span  {
	left:${spanleft}px; 
	top: ${spantop}px;
}

END;
	$rpos += $cwidth;
   }
   $rtop += $cheight;
   if($rnum == 1) $rtop += $row2extra;
}
?>

#imap a em {display:none;}

#imap a span, #imap a:visited span {
	display:none;
}


#imap a:hover span {
	position: absolute;
	display:block; 
	color:red; 
	width:300px; height:170px; 
	font:normal 20px/25px 'latomedium', arial, sans-serif; 
	text-align:left;
}

#imap a:hover span img {
	margin-right:1em; 
	margin-bottom:0.5em; 
	border:1px solid #000;
}


/* This is where hover puts text */
#teaser {
	position: absolute;
	left: <?=$teaserTop?>px; 	/* Position of teaser text */
	top:  62px;
	border:1px solid #000;
	display:block; 
	color:red; 
	width:300px; height:170px; 
	font:bold 30px/35px 'latomedium', arial, sans-serif; 
	margin-top: 20px;
	text-align:center;
}

/*
#imap a span:first-line {font-weight:bold; font-style:italic;}
#info .para {width:300px; margin:0;}
*/

.enlabel {
	position: relative;
	top: 300px;
	clear:both;
	text-align: bottom;
	float:left;
}
.eslabel {
	float:right;
}

</style>

<div id="teaser"><p><p>Hover over thumbnails<br>to see full image</div>

<dl id="imap">

<?php
   $celname = "row_0_0";
   $celtext = "Hover over thumbnails to see full image";
print <<<END
<dd id="$celname" class="image-squares">
   <a id="link_$celname"><em>$celname</em>
<span>$celtext</span></dd>

END;

for($rnum=0; $rnum<7; ++$rnum) {
   for($cel=1; $cel<$cels; ++$cel) {

   $celname = "row_${rnum}_$cel";
  
   if(isset($fname[$celname])) {
	$celimg   = $fname[$celname];
	$cellabel = $cname[$celname];
	if($isLeop) $celimg = substr($celimg,1);
   } else {
	$celimg = "mt"; 
	$cellabel = '';
	continue;
   }
   list($enlabel, $eslabel) = explode("|", $cellabel);
#   $celtext = "<br clear=all><span class=enlabel>$enlabel</span><span class=eslabel>$eslabel</span>";
   $celtext = "$enlabel<div class=eslabel>$eslabel</div>";

print <<<END
<dd id="$celname" class="image-squares">
   <a id="link_$celname" onClick="showImg('$celname');"><em>$celname</em>
<span><img src="/$celimg" width=300px>$celtext</span></a></dd>

END;
   }
}

?>
</dl>
<script type="text/javascript">

    jQuery(window).load(function() {
	$('.image-squares').click(function() {
//	    alert("clicked on "+ this.id );
	});
    });

</script>
<h3>Hover over image to see full size<br>
&nbsp;&nbsp;&nbsp;(darker images are studio photos)<br>
&nbsp;&nbsp;&nbsp;(bright images are professional photos)<br>
On mobile, tap</h3>
