<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
#c// ###################################################################
#c// Album Theme by George Hansper
#c// ###################################################################
#c//
<:
# Path setting - this is the path to the images
$PATH = Theme_URL();

$CREDIT_FONT = "size='-2' color='#CCCCCC'";
$TITLE_FONT = "color='#CCCCCC'";
$link_color = "#FFFFFF";
$BODY = "bgcolor='#808080' link='$link_color' alink='$link_color' vlink='$link_color' text='#CCCCCC'";

@Photo_Border = ('white',5);
#@Album_Border = ('#101080',5);
#@Movie_Border = ( 'black',5);

$INITIAL_ICON_SIZE=150;

$START_TITLE = "<font $TITLE_FONT>";
$START_MAIN = "<font $MAIN_FONT>";
$START_CREDIT = "<font $CREDIT_FONT>";

$SLIDESHOW = Option('slideshow');
$COLS=Option('columns');

# Borders

my %Border = (
  Photo => {
	L  => { url => "$PATH/Photo_Border_L.gif",  x => 25, y => 100 },
	R  => { url => "$PATH/Photo_Border_R.gif",  x => 25, y => 100 },
	TL => { url => "$PATH/Photo_Border_TL.gif", x => 25, y => 25 },
	TR => { url => "$PATH/Photo_Border_TR.gif", x => 25, y => 25 },
	BL => { url => "$PATH/Photo_Border_BL.gif", x => 25, y => 25 },
	BR => { url => "$PATH/Photo_Border_BR.gif", x => 25, y => 25 },
	T  => { url => "$PATH/Photo_Border_T.gif",  x => 125, y => 25 },
	B  => { url => "$PATH/Photo_Border_B.gif",  x => 125, y => 25 }
  },

  Album => {
  	TL => { url => "$PATH/Album_Border_TL.png", x => 6, y => 6 },
	T => { url => "$PATH/Album_Border_TL.png",  x => 300, y => 6 },
	TR => { url => "$PATH/Album_Border_TR.png", x => 25, y => 6 },
	R => { url => "$PATH/Album_Border_R.png",   x => 25, y => 300 },
	BR => { url => "$PATH/Album_Border_BR.png", x => 25, y => 25 },
	B => { url => "$PATH/Album_Border_B.png",   x => 300, y => 25 },
	BL => { url => "$PATH/Album_Border_BL.png", x => 6, y => 25 },
	L => { url => "$PATH/Album_Border_TL.png",  x => 6, y => 300 },
  },
  
   Movie => {
 	TL => { url => "$PATH/Movie_Border_CNR.gif",  x => 15, y => 5 },
 	TR => { url => "$PATH/Movie_Border_CNR.gif",  x => 15, y => 5 },
 	BL => { url => "$PATH/Movie_Border_CNR.gif",  x => 15, y => 5 },
 	BR => { url => "$PATH/Movie_Border_CNR.gif",  x => 15, y => 5 },
 	L => { url => "$PATH/Movie_Border_L.gif",  x => 15, y => 114 },
	R => { url => "$PATH/Movie_Border_R.gif",  x => 15, y => 114 },
	T => { url => "$PATH/Movie_Border_CNR.gif", x => 15, y => 5 },
	B => { url => "$PATH/Movie_Border_CNR.gif", x => 15, y => 5 }
  }
);  # my %Border

sub My_Border {
	my ($tag,$border) = @_;
	my $indent;
	my $html;
	$_ = $tag;
	m/^(\s*)/;
	$indent = $1;
	if ( @{$border} > 0 ) {
		# Simple border - Color+width only
		$html  = $indent . "<table border=0 cellspacing=0  bgcolor='@{$border}[0]' cellpadding='@{$border}[1]'>\n";
		$html .= $indent . "	<tr><td align='center' valign='center'>\n";
		$html .= $tag    . "\n";
		$html .= $indent . "	</td></tr>\n";
 		$html .= $indent . " </table>\n";
	} else {
		# Fancy gif-based vorder 
		$html  = $indent . "<table border=0 cellpadding=0 cellspacing=0 >\n";
		$html .= $indent . "	<tr>\n";
		$html .= $indent . "	<td width=$Border{$border}{TL}{x} height=$Border{$border}{TL}{y} background='$Border{$border}{TL}{url}' ></td>\n";
		$html .= $indent . "	<td height=$Border{$border}{T}{y} background='$Border{$border}{T}{url}' ></td>\n";
		$html .= $indent . "	<td width=$Border{$border}{TR}{x} height=$Border{$border}{TR}{y} background='$Border{$border}{TR}{url}' ></td>\n";
		$html .= $indent . "	</tr>\n";
		$html .= $indent . "	<tr>\n";
		$html .= $indent . "	<td width=$Border{$border}{L}{x} background='$Border{$border}{L}{url}' ></td>\n";
		$html .= $indent . "	<td align='center' valign='bottom'>\n";
		$html .= $tag    . "\n";
		$html .= $indent . "	</td>\n";
		$html .= $indent . "	<td width=$Border{$border}{R}{x} background='$Border{$border}{R}{url}' ></td>\n";
		$html .= $indent . "	</tr>\n";
		$html .= $indent . "	<tr>\n";
		$html .= $indent . "	<td width=$Border{$border}{BL}{x} height=$Border{$border}{BL}{y} background='$Border{$border}{BL}{url}' ></td>\n";
		$html .= $indent . "	<td height=$Border{$border}{B}{y} background='$Border{$border}{B}{url}' ></td>\n";
		$html .= $indent . "	<td width=$Border{$border}{BR}{x} height=$Border{$border}{BR}{y} background='$Border{$border}{BR}{url}' ></td>\n";
		$html .= $indent . "	</tr>\n";
		$html .= $indent . "</table>\n";
	}
	return $html;
}

sub img_with_border {
	my ($img) = @_;
	my $tag;
	my $border;
	my $href;
	if ( Get($img,'type') eq 'dirs' ) {
		if ( @Album_Border == 2 ) {
			$border = \@Album_Border;
		} else {
			$border = 'Album';
		}
		$href = Get($img,'href','dir');
	} elsif ( Get($img,'is_movie') ) {
		if ( @Movie_Border == 2 ) {
			$border = \@Movie_Border;
		} else {
			$border = 'Movie';
		}
		$href = Get($img,'href','image');
	} else {
		if ( @Photo_Border == 2 ) {
			$border = \@Photo_Border;
		} else {
			$border = 'Photo';
		}
		$href = Get($img,'href','image');
	}
	my $tag;
	$tag  = "\t\t\t\t$href\n";
	$tag .= "\t\t\t\t\t<img src=" . Get($img,'URL','album_page','thumb') . " " . get_initial_thumb_size($img);
	$tag .= " alt='" . Name($img) . "' ";
	$tag .= " style='border:0'";
	$tag .= " $img->{intag}";
	$tag .= " >\n";
	$tag .= "\t\t\t\t</a>\n";
	#if ( @{$border} == 2 ) {
	#	return $tag;
	#} else {
		return My_Border($tag,$border);
	#}
}

sub get_initial_thumb_size {
	my ($img) = @_;
	my $thumb_x;
	my $thumb_y;
	my $width;
	my $height;
	$thumb_x = Get($img,'thumb','x');
	$thumb_y = Get($img,'thumb','y');
	if ( $thumb_x > 0 && $thumb_y > 0 ) {
		if ( $thumb_y > $thumb_x ) {
			$height = "height=$INITIAL_ICON_SIZE";
			$width = "width=" . $INITIAL_ICON_SIZE * $thumb_x / $thumb_y;
		} else {
			$width = "width=$INITIAL_ICON_SIZE";
			$height = "height=" . $INITIAL_ICON_SIZE * $thumb_y / $thumb_x;
		}
		return("$width $height");
	} else {
		return("");
	}
}

############################################################################
# Start HTML
############################################################################
:>//
<head>
	<meta http-equiv="content-type" content="text/html;charset=<:=Option('charset'):>">
	<meta http-equiv="Content-Style-Type" content="text/css">
	<: Meta() :>
	<title><:= Trans('Album:') :> <:= Path('album_name') :></title>
	<:= $CSS :>
	<script language="JavaScript" type="text/JavaScript">
<:
	# Add a name=... property to each image, so we know which ones to zoom
	my $type;
	foreach $type ( 'dirs', 'pics' ) {
		my $image = First($type);
		while ($image) {
			my $name = Name($image);
			$name =~ s/[^a-z0-9_:\.-]/_/ig;
			$name =~ s/^([^a-z])/Z$1/i ;
			$image->{intag} .= " name='$name'";
			$image = Next($image);
		}
	}
_:>//
	function setthumbsize(arg) {
		var i;
		for(i=0; i < document.images.length ; i++) {
			if( document.images[i].name != "" ) {
				aspect = 0.0 + document.images[i].width / document.images[i].height ;
				if( aspect >= 1.0  ) {
					document.images[i].width = arg.value;
					document.images[i].height = arg.value / aspect;
				} else {
					document.images[i].height = arg.value;
					document.images[i].width  = arg.value * aspect;
				}
			}
		}
	}
	</script>
</head>
<body <:=$BODY:> <:Body_Tag():> >
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td align='left'>
			<:=$START_TITLE:>
<:
	if ($Icon) {
		print Image_Ref($Icon,"align='middle'");
		print "\n\t\t<br />&nbsp;&nbsp;&nbsp;&nbsp;\n";
	} else {
		print "\t\t<b>".Trans('Album:')."</b>\n";
	}
_:>//
#c###########################################################################
#c# Parent Albums (ie the path to this child album)
#c###########################################################################
<:= Parent_Albums(' : '); :>
			</font>
		</td>
		<td align='left'>
			<form>
			<font size='-1'><b>Thumbnail size:</b>
<:			my $thumb = First('pic');
			my $thumb_x = Get($thumb,'thumb','x');
			my $thumb_y = Get($thumb,'thumb','y');
			my $icon_size = $thumb_x > $thumb_y ? $thumb_x : $thumb_y ;
			my $button;
			my $last_button=0;
			foreach $button ( sort(100, 120, 150, 200, 240, 300, 360, $icon_size, $INITIAL_ICON_SIZE ) ) {
				if( $button != $last_button && $button <= $icon_size ){
_:>			<input type=radio name=thumbsize value=<:=$button:> onclick="setthumbsize(this)" <:=($button==$INITIAL_ICON_SIZE?"checked":""):> ><:=$button:>
<:				}
				$last_button=$button;
			}
_:>
			</font>
			</form>
		<td align="right">
<:
		$back=Back();
		if ($back && $back ne "''" && $back ne "'0'") {_:>//
			<:=$START_TITLE:>
			<a href=<:=$back:>>
			<:=($Back ? Image_Ref($Back,"align='middle'") : Trans('Up')):>
			</a>
			</font>
<:		}:>//
		</td>
	</tr>
	</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr><td colspan="<:=$COLS:>"><hr></td></tr>
#c###########################################################################
#c# Child Albums
#c###########################################################################
<:
	my $alb = First('dirs');
	my @save;
	my $thumb_html;
	while ($alb) {
		push(@save,$alb);
		if ( @save == 1 ) {
			# This is the 1st album on the row
			print "\t<tr>\n";
		}
		# Output the album icons...
		my ($initial_width,$initial_height);
		if (Option('dir_thumbs')) { _:>
			<td align='center' valign='bottom' width='<:=$Col_Perc:>' >
<:			if ( Get($alb,'thumb','x') > 0 ) {
				print img_with_border($alb);
			}
			if ( @save >= $COLS || Next($alb) eq undef ) {
				# If this is the last album on this row _:>
			</td>
		</tr>
		<tr>
<:			} # end @save >= $COLS ||...
		} # end if Option('dir_thumbs')
		# Output the album captions...
		if ( @save >= $COLS || Next($alb) eq undef ) {
			my $col;
			for($col=0; $col < $COLS; $col++) { 
				if($save[$col] eq undef ) { _:>
				<td>&nbsp;</td>
<:					} else { _:>
				<td align='center' width='<:=$Col_Perc:>' valign='top'>
						<:=$START_MAIN:>
						<:= Image_Array( (-e Get($save[$col],'path').'/.htaccess') ? @Locked : @NotLocked) :>
						<:=Get($save[$col],'href','dir'):>
						<:=Pretty(Name($save[$col]),1,1):></a>
						<: my $cap = Caption($save[$col]);
						   my $num_pics = Get($save[$col],'num_pics_str');
						   my $num_dirs = Get($save[$col],'num_dirs_str');
						   if ($cap || $num_pics || $num_dirs) { _:>
							<br />
							<font size='-2'>
							<:=$cap if $cap:>
							<:="<br />" if $cap && ($num_pics || $num_dirs):>
							<:=$num_dirs:><:=", " if $num_pics && $num_dirs:>
							<:=$num_pics:>
							</font>
						<: } _:>
					</font>
				</td>
<:					}
			} # end for $col
		}
		if ( @save >= $COLS ) {
			# This is the last album on the row
			print "\t</tr>\n";
			undef @save;
		}
		$alb = Next($alb);
	} # End child album loop
	# Bar after child albums
	if ( num('dirs') > 0 ) { _:>//
	<tr><td colspan="<:=$COLS:>"><hr></td></tr>
<:	}
_:>//
#c###########################################################################
#c# Header (Optional)
#c###########################################################################
<:
	if (isHeader()) { _:>
	<tr>
		<td colspan="<:=$COLS:>">
			<center>
				<:pHeader():>
			</center>
		</td>
	</tr>
	<tr><td colspan="<:=$COLS:>"><hr></td></tr>
<: 	} _:>//
#c###########################################################################
#c# Images (this album)
#c###########################################################################
<:
	my $img = First('pics');
	my @save;
	my $border;
	while ($img) {
		push(@save,$img);
		if ( @save == 1 ) {
			# This is the 1st thumbnail on the row
			print "\t<tr>\n";
		}
		# Output the thumbnails...
_:>//
			<td align='center' valign='bottom' width='<:=$Col_Perc:>' >
			<:=img_with_border($img):>//
			</td>
<:		if ( @save >= $COLS || Next($img) eq undef ) {
			# If this is the last thumbnail on this row _:>
		</tr>
		<tr>
<:		} # end if ...% $COLS
		# Output the captions...
		if ( @save >= $COLS || Next($img) eq undef ) {
			my $col;
			for($col=0; $col < $COLS; $col++) { 
				if($save[$col] eq undef ) { _:>
			<td>&nbsp;</td>
<:				} else { _:>
				<td align='center' valign='top' width='<:=$Col_Perc:>'>
				  <:=$START_MAIN:>
					<:=Get($save[$col],'href','image'):>
					<:=Pretty(Name($save[$col]),1,1):></a>
						<font size='-2'>
					<: if (my $cap = Caption($save[$col])) { _:>
						<:=$cap:><br />
						<:=Get($save[$col],'full','x'):> x <:=Get($save[$col],'full','y'):>
						- <:=Get($save[$col],'full','filesize'):>bytes
					<: } :>
						</font>
					</font>
					<font size="-4"><br />&nbsp;</font>
				</td>
<:				}
			} # end for $col
		} # end if ...% $COLS 
		if ( @save >= $COLS ) {
			# This is the last thumbnail on the row
			print "\t</tr>\n";
			undef @save;
		}
		$img = Next($img);
	}
_:>
	<tr><td colspan="<:=$COLS:>"><hr></td></tr>
#c###########################################################################
#c# Footer (Optional)
#c###########################################################################
<: if (isFooter()) { _:>
	<tr>
		<td colspan="<:=$COLS:>">
			<center>
				<:pFooter():>
			</center>
		</td>
	</tr>
	<tr><td colspan="<:=$COLS:>"><hr></td></tr>
<: } _:>
#c###########################################################################
#c# Credit
#c###########################################################################
	<tr>
		<td colspan="<:=$COLS:>">
			<div align="center">
				<font <:=$CREDIT_FONT:>><: Credit() :> on <:=scalar localtime:></font>
			</div>
		</td>
	</tr>
</table>
</body>
</html>
