<%@ Import Namespace="System.IO" %>
<script runat="server" language="VB">
  Sub Page_Load(sender as Object, e as EventArgs)
    'Get list of images
    Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
    Dim images() as FileInfo = FilterForImages(dirInfo.GetFiles())
    
    'Determine the current image to show
    Dim imgIndex as Integer = 0
    If Not Request.QueryString("N") is Nothing AndAlso IsNumeric(Request.QueryString("N")) then
      imgIndex = CInt(Request.QueryString("N"))
    End If
    
    currentImgTitle.Text = "Image: " & _
          Path.GetFileNameWithoutExtension(images(imgIndex).Name) & _
          " (" & imgIndex + 1 & " of " & images.Length & ")"
    currentImg.ImageUrl = Path.GetFileName(images(imgIndex).Name)
    
    If imgIndex > 0 then
      lnkPrev.NavigateUrl = "pictures.aspx?N=" & imgIndex - 1
    End If
    
    If imgIndex < images.Length - 1 then
      lnkNext.NavigateUrl = "pictures.aspx?N=" & imgIndex + 1
    End If
    
    dlIndex.DataSource = images
    dlIndex.DataBind()
  End Sub


  Function FilterForImages(images() as FileInfo) as FileInfo()
    Dim newImages as New ArrayList(images.Length)
    
    Dim i as Integer
    For i = 0 to images.Length - 1
      If Path.GetExtension(images(i).Name.ToLower()) = ".jpg" OrElse _
         Path.GetExtension(images(i).Name.ToLower()) = ".jpeg" OrElse _  
         Path.GetExtension(images(i).Name.ToLower()) = ".png" OrElse _ 
         Path.GetExtension(images(i).Name.ToLower()) = ".gif" then
        newImages.Add(images(i))
      End If
    Next
    
    Return CType(newImages.ToArray(GetType(FileInfo)), FileInfo())
  End Function
  
  Sub dlIndex_ItemDataBound(sender as Object, e as DataListItemEventArgs)
    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem then
      'Get the Hyperlink
      Dim hl as HyperLink = CType(e.Item.FindControl("lnkPic"), HyperLink)
    
      'Set the Text and Navigation properties
      hl.Text = Path.GetFileNameWithoutExtension(DataBinder.Eval(e.Item.DataItem, "Name").ToString()) & _
             " (" & Int(DataBinder.Eval(e.Item.DataItem, "Length") / 1000) & " KB)"
      hl.NavigateUrl = "pictures.aspx?N=" & e.Item.ItemIndex
    End If
  End Sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pictures - Ron Sall Body Werx Online! Zeeland, MI 49464</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Custom Hot Rod, Hot Rod, Ron Sall, Body Werx, HotRod, Body Shop, Zeeland, MI"/>
<meta name="description" content="Located in Zeeland MI, Ron Sall Body Berx has been in the Custom Hot rod Restoration Business for over 35 years.  Take a look at what we have to offer!"/>
<meta name="author" content="Weerd Designs, Grand Rapids"/>
<link rel="stylesheet" type="text/css" href="/css/layout.css">
<link rel="stylesheet" type="text/css" href="/css/formatting.css">
<script type="text/javascript" src="/Scripts/mainfunctions.js"></script>
 <STYLE TYPE="text/css">
    .ImageTitle {font-size:12pt;}
    .index {font-size:8pt;width:100%}
	.ListIndex{font-size:8pt; color:#999999; cursor:pointer;}
	.ListIndex:hover{ color:#990033;cursor:pointer; text-decoration:underline;}
    .NavLink { }
  </STYLE>
</head>
<body style="background-color:#000000;">
<div id="main">
	<div id="bodyWerxLogo">
	</div>
	<div id="topRight">
	</div>
	<div id="topLeftLinks">
	</div>
	<div id="topLinks"><img src="/images/links/linksfillerleft.gif" /><img id="homeLink" class="TopImageLinks" src="/images/links/homeoff.gif" onMouseOver="DisplayMainLinks(this.id,'on','home');" 
        onmouseout="DisplayMainLinks(this.id,'out','home');"  onclick="window.location='/home.asp'"/><img id="pictureLink" class="TopImageLinks" src="/images/links/picturesoff.gif" onMouseOver="DisplayMainLinks(this.id,'on','pictures');" 
        onmouseout="DisplayMainLinks(this.id,'out','pictures');" onClick="window.location='/slideshow/pictures.aspx'"/><img id="aboutUsLink" class="TopImageLinks" src="/images/links/aboutusoff.gif" onMouseOver="DisplayMainLinks(this.id,'on','aboutus');" 
        onmouseout="DisplayMainLinks(this.id,'out','aboutus');" onClick="window.location='/about.asp'"/><img id="contactLink" class="TopImageLinks" src="/images/links/contactusoff.gif" onMouseOver="DisplayMainLinks(this.id,'on','contactus');" 
        onmouseout="DisplayMainLinks(this.id,'out','contactus');" onClick="window.location='/contact.asp'"/><img src="/images/links/linksfillerright.gif" /></div>
        <div id="topRightLinks">
	</div>
	<div id="container" >
    <h1>Gallery</h1>
    
    <div align="center">
    <asp:HyperLink runat="server" CssClass="NavLink" id="lnkPrev"  ImageUrl="/images/prev.gif"  /> 
    <asp:HyperLink runat="server" CssClass="NavLink" id="lnkNext"  ImageUrl="/images/next.gif"/>
    <br />
<br />
    <asp:Image runat="server" id="currentImg" /><br />
<asp:Label runat="server" id="currentImgTitle" CssClass="ImageTitle" />
<br /><br />
    <asp:DataList runat="server" id="dlIndex" OnItemDataBound="dlIndex_ItemDataBound"
        RepeatColumns="2" CssClass="index">
      <ItemTemplate>
        <li><asp:HyperLink runat="server" id="lnkPic" CssClass="ListIndex"/></li>
      </ItemTemplate>
    </asp:DataList>

</div>
    <div id="bottom">
	</div>
    <div id="CopyrightandLinks"><a class="link2" href = "/home.asp">Home</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a class="link2" href = "/slideshow/pictures.aspx">Pictures</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a class="link2" href = "/about.asp">About Us</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a class="link2" href = "/contact.asp">Contact Us</a><br /><a class="link2" href="/copyright.asp">Copyright © 2009 </a> Ron Sall Body Werx </div>
    
  </div>
	
</div>
</body>
</html>