<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
#c// ###################################################################
#c// Album Theme by David Ljung Madison
#c// Design by Dave Simmer of DaveWeb.com, modified by Dave Madison
#c// -- Auto generated by simmer_theme v3.06
#c// -- From: http://MarginalHacks.com/Hacks/album/
#c// ###################################################################
#c//
<:

  # Version requirements
  if (Version_Num() < 3.10) {
    print STDERR "\n[THEME ERROR]  This theme requires album v3.10\n";
    exit(-1);
  }

  # Path setting - this is the path to the images
  $PATH = Theme_URL();
  $CSS = "<link rel='stylesheet' type='text/css' href='".$PATH."/Style.css'>";

	$BODY="";
	$START_TITLE = "<span class='title'>";
	$START_MAIN = "<span class='main'>";
	$START_CREDIT = "<span class='credit'>";
	$END_FONT = "</span>";

	$SLIDESHOW = Option('slideshow');
  # Icons/graphics
  @Bar_L =	("$PATH/Bar_L.gif", 5, 3);
  @Bar_M =	("$PATH/Bar_M.gif", '100%', 3);
  @Bar_R =	("$PATH/Bar_R.gif", 5, 3);
  @Locked =	("$PATH/Locked.gif", 12, 10);
  @NotLocked =	("$PATH/NotLocked.gif", 12, 10);
sub Bar {
  my ($colspan) = @_;
  return unless @Bar_M;
:>
			<tr>
				<td colspan='<:=$colspan:>' height="<:=$bar_H:>">
					<table cellpadding=0 cellspacing=0 width='100%'>
						<tr>
<: foreach my $bar ( \@Bar_L, \@Bar_ML, \@Bar_M, \@Bar_MR, \@Bar_R ) {
     next unless @$bar;
     my $width = $bar->[1] =~ /100%/ ? "" : " width=$bar->[1]";
     print "\t\t\t\t\t\t\t<td $width>";
     print Image_Array(@$bar);
     print "</td>\n";
} :>
						</tr>
					</table>
				</td>
			</tr>
<:
}


# Overlays
  push(@Overlays, ["$PATH/Overlay.1.png", 570, 445]);
  push(@Overlays, ["$PATH/Overlay.2.png", 570, 445]);
  push(@Overlays, ["$PATH/Overlay.3.png", 570, 445]);
  push(@Overlays, ["$PATH/Overlay.4.png", 570, 445]);
  push(@Overlays, ["$PATH/Overlay.5.png", 445, 570]);
  push(@Overlays, ["$PATH/Overlay.6.png", 445, 570]);
  push(@Overlays, ["$PATH/Overlay.7.png", 445, 570]);
  push(@Overlays, ["$PATH/Overlay.8.png", 445, 570]);
  push(@Overlays, ["$PATH/Overlay.tn.1.png", 133, 100]);
  push(@Overlays, ["$PATH/Overlay.tn.2.png", 133, 100]);
  push(@Overlays, ["$PATH/Overlay.tn.3.png", 133, 100]);
  push(@Overlays, ["$PATH/Overlay.tn.4.png", 133, 100]);
  push(@Overlays, ["$PATH/Overlay.tn.5.png", 100, 133]);
  push(@Overlays, ["$PATH/Overlay.tn.6.png", 100, 133]);
  push(@Overlays, ["$PATH/Overlay.tn.7.png", 100, 133]);
  push(@Overlays, ["$PATH/Overlay.tn.8.png", 100, 133]);

# Come up with a 'distance' of ratio/size closeness
sub OverlayErr {
  my ($x,$y,$overlay) = @_;

  my $ox = $overlay->[1];
  my $oy = $overlay->[2];
  my $err = abs($x-$ox)/$x;
     $err += abs($y-$oy)/$y;
     $err += abs(($x/$y)-($ox/$oy))/($x/$y);
  $err;
}

srand(time^$$);
sub PickOverlay {
  my ($img, $type) = @_;
  my $x = Get($img,$type,'x');
  return unless $x;
  my $y = Get($img,$type,'y');

  # Find the lowest error
  my $besterr = undef;
  foreach my $overlay ( @Overlays ) {
    my $err = OverlayErr($x,$y,$overlay);
    next if defined $besterr && $besterr<$err;
    $besterr = $err;
  }

  # Now find a list of overlays that are close to that error
  $besterr *= 1.05;	# Err or within 5%	<- HEURISTIC!
  my @best = grep { OverlayErr($x,$y,$_) <= $besterr; } @Overlays;

  # Pick one randomly and apply it
  Overlay($img,$type,'full', $best[int(rand($#best+1))]);
}


  # Thumbnail border
  @Bord_LT =	("$PATH/Bord_LT.gif", 16, 13);
  @Bord_RT =	("$PATH/Bord_RT.gif", 16, 13);
  @Bord_LB =	("$PATH/Bord_LB.gif", 16, 13);
  @Bord_RB =	("$PATH/Bord_RB.gif", 16, 13);
  @Bord_L =	("$PATH/Bord_L.gif", 16, 74);
  @Bord_R =	("$PATH/Bord_R.gif", 16, 74);
  @Bord_TL =	("$PATH/Bord_TL.gif", 30, 16);
  @Bord_TR =	("$PATH/Bord_TR.gif", 30, 16);
  @Bord_BL =	("$PATH/Bord_BL.gif", 30, 16);
  @Bord_BR =	("$PATH/Bord_BR.gif", 30, 16);
  @Bord_T =	("$PATH/Bord_T.gif", 72, 16);
  @Bord_B =	("$PATH/Bord_B.gif", 72, 16);

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Over_TL,\@Over_T,\@Over_TR,\@Over_R,\@Over_BR,\@Over_B,\@Over_BL,\@Over_L) unless @Border;

  # Overlay padding
  push(@Over_T, 39);
  push(@Over_B, 39);
  push(@Over_L, 39);
  push(@Over_R, 39);


  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;

  @Border = (\@Bord_TL,\@Bord_T,\@Bord_TR,\@Bord_RT,\@Bord_R,\@Bord_RB,\@Bord_BR,\@Bord_B,\@Bord_BL,\@Bord_LB,\@Bord_L,\@Bord_LT) unless @Border;
:>//
#c//
#c// ###################################################################
#c// Everything beyond here is the same for every DaveWeb theme..
#c// ###################################################################
<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=<:=Option('charset'):>">
		<meta http-equiv="Content-Style-Type" content="text/css">
		<: Meta() :>
		<title>Image: <:=Name(This_Image) :></title>
    <:= $CSS :>
<: if ($SLIDESHOW) { :>
<: unless ($CSS) { :>
		<style type="text/css">
		<!--
			#SlideShowButton { font-size:75%; }
			#SlideShow { font-size:75%; }
		-->
		</style>
<: } :>
		<script type='text/javascript'>
		<!--
			var cururl=<:=Image_Page_URL():>;
			<:Set_Image_Next():>
			var strurl =  <:=Image_Page_URL():>;
			var timeout_value = 0;
			var stop_request = 0;
			var picnum = 2;
			var loopCheck ='off';

			function slideshow() {
				if (timeout_value != 0 && <:=num('pics'):>-picnum >=0) {
					setTimeout('gonext()', timeout_value*1000)
				}
			}

			function gonext() {
				var counter='';
				if (loopCheck != 'on'){
					counter ='&counter='+picnum;
				};
				this.location=strurl+'?time='+timeout_value+'&loop='+loopCheck+counter
			}

			function checkanimate() {
				if (this.location.toString().indexOf('?time=30') >= 0) {
					timeout_value=30
				} else if (this.location.toString().indexOf('?time=15') >= 0) {
					timeout_value=15
				} else if (this.location.toString().indexOf('?time=10') >= 0) {
					timeout_value=10
				} else if (this.location.toString().indexOf('?time=5') >= 0) {
					timeout_value=5
				} else if (this.location.toString().indexOf('?time=3') >= 0) {
					timeout_value=3
				} else if (this.location.toString().indexOf('?time=0') >= 0) {
					timeout_value=0
				};
				if (this.location.toString().indexOf('&loop=on') >= 0) {
					loopCheck='on'
				};
				if (this.location.toString().indexOf('&counter=') >= 0) {
					do_count();
				};
			}

			function do_count(){
				var x =this.location.toString().indexOf('&counter=');
				picnum=parseInt(this.location.toString().substring(x+9))+1;
			}

			function reset_timer() {
				timeout_value = document.SlideShow.time.options[document.SlideShow.time.selectedIndex].value;
			}

			function stopshow() {
				this.location=cururl;
			}

			function toggleLoop(){
				if( loopCheck =='on'){
					loopCheck='off'
				} else {
					loopCheck='on'
				}
			}

			function slideshowForm(){
				if (this.location.toString().indexOf('&stop=1') >= 0) {
					stopshow();
				}
				checkanimate();
				document.write("<form id=SlideShow name=SlideShow>");
				document.write("&nbsp;&nbsp; <button id=SlideShowButton>Slideshow</button>");

				document.write("<span style='white-space: nowrap'>");
				document.write("&nbsp;&nbsp;&nbsp;delay:&nbsp;");
				document.write("<select name='time' onchange='reset_timer()' size=1  style='font-size:12px;'><option value=0 ");
				if(timeout_value == 0) {document.write(" selected ");};
				document.write(">Select</option><option value=3 ");
				if(timeout_value == 3) {document.write(" selected ");};
				document.write(">3  seconds</option><option value=5");
				if(timeout_value == 5) {document.write(" selected ");};
				document.write(" >5  seconds</option><option value=10 ");
				if(timeout_value == 10) {document.write(" selected ");};
				document.write(":>10  seconds</option><option value=15");
				if(timeout_value == 15) {document.write(" selected ");};
				document.write(" >15  seconds</option><option value=30 ");
				if(timeout_value == 30) {document.write(" selected ");};
				document.write(">30  seconds</option></select>");

				document.write("&nbsp;&nbsp;&nbsp;loop:&nbsp;");
				document.write("<input type=checkbox  name='loop'");
				if (loopCheck =='on'){document.write("checked");};
				document.write(" onclick='toggleLoop()'>");
				document.write("</span>");

				document.write("<button id=SlideShowButton name='stop' value=1>Stop</button>");
				document.write("</form>");
			}

		//-->
		</script>
<: } :>

	</head>

	<body <:=$BODY:> <: print "onload='slideshow()'" if ($SLIDESHOW) :>>
		<:=Image_Array("$PATH/Null.gif",1,10):>
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr valign='top'>
				<td>
<: if (@Icon) {
          print Image_Array(@Icon,"align='middle'");
					print "\n<br />\n";
   } _:>
					<:=$START_TITLE:>
					&nbsp;&nbsp;&nbsp;&nbsp;<:= Parent_Albums(':'); :>
					<:=$END_FONT:>
				</td>
<: if ($SLIDESHOW) { :>
				<td valign=bottom align=center>
					<script type='text/javascript'>
					<!--
  					slideshowForm();
					//-->
					</script>
				</td>
<: } :>
				<td>
					<div align="right">
						<a href=<:=Back():>><:print @Back ? Image_Array(@Back) : "${START_TITLE}Back$END_FONT"; :></a></div>
				</td>
			</tr>
			<: Bar($SLIDESHOW ? 3 : 2) :>
		</table>
		<br />
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
#c//
#c// Prev/caption/next
#c//
			<tr valign='top'>
				<td width="25%">
<: if (my $Prev = Prev(This_Image, $opt->{image_loop})) { _:>
					<div align="left">
					<:=$START_MAIN:>
					<:=Get($Prev,'href','image_page','image_page'):>
          <:= @Prev ? Image_Array(@Prev,"align='top'") : "(prev) "; :><:=Pretty(Name($Prev),1):></a>
					<:=$END_FONT:>
					</div>
<: } _:>
				</td>

				<td width="50%">
					<div align="center">
						<:=$START_TITLE:>
						<:=Get(This_Image,'href','image'):>
						<:=Pretty(Name(This_Image),1,1):></a><:=$END_FONT:>

						<br />
						<:=$START_MAIN:>
						<:=Caption(This_Image):><:=$END_FONT:>
					</div>
				</td>

				<td width="25%">
<: if (my $Next = Next(This_Image, $opt->{image_loop})) { _:>
					<div align="right">
					<:=$START_MAIN:>
					<:=Get($Next,'href','image_page','image_page'):>
          <:=Pretty(Name($Next),1):><:= @Next ? Image_Array(@Next,"align='top'") : " (next)"; :></a>
					<:=$END_FONT:>
					</div>
<: } _:>
				</td>
			</tr>
		</table>

		<table border="0" cellpadding="0" cellspacing="0" width="100%">

#c//
#c// The image
#c//
			<tr>
				<td valign="top" width="100%">
					<div align="center"><br />
					<: PickOverlay(This_Image, 'full') if @Overlays :>
					<: Border(This_Image,'full','image',  @Border) :>
					</div>
				</td>
			</tr>

			<tr>
				<td height="20"><:=Image_Array("$PATH/Null.gif",20,20):></td>
			</tr>

<: Bar(1) :>

			<tr>
				<td>
					<div align="center">
						<:=$START_CREDIT:><: Credit() :> on <:=scalar localtime:><:=$END_FONT:></div>
				</td>
			</tr>
			<tr>
				<td></td>
			</tr>
		</table>
		<p></p>
	</body>

</html>
