<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
	
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
		If Not Page.IsPostBack Then
			Dim sHeader As String = "home"
			Select Case System.IO.Path.GetFileNameWithoutExtension(Request.Path)
				Case "info"
					sHeader = "aboutannandale"
				Case "about"
					sHeader = "aboutus"
				Case "advertise"
					sHeader = "advertisinginformation"
				Case "events"
					sHeader = "chamberevents"
				Case "contact"
					sHeader = "contact"
				Case "b2b_intro"
					sHeader = "blank"
				Case "b2b_add"
					sHeader = "blank"
				Case "b2b_edit"
					sHeader = "chambermembers"
				Case "b2b_show"
					sHeader = "chambermembers"
				Case "resource"
							 sHeader = "resources"
				Case Else
					sHeader = "home"
			End Select
			imgCorner.ImageUrl = String.Format("~/_images/theme/header_{0}_corner.gif", sHeader)
			BuildAds()
		End If

	End Sub
	Sub BuildAds()
		'todo: expand logic if ACC ever sells more than one AD (read from db for instance)
		Static sNoAdFile As String = "<td align='left' valign='top'><img alt='Blue Block' border='0' height='60' src='../_images/ads/ad_blue_blank.png' width='234' ></td><td align='left' valign='top'><a href='../_downloads/Endeavor_current.pdf' target='_blank'><img alt='Read the latest Endeavor Newsletter' border='0' height='60' src='../_images/ads/ad_endeavor.gif' width='234'></td>"
      Static sTopFullFormat As String = "<td align='left' valign='top' class='ad' ><a href='{0}' target='_blank'><img src='{1}' alt='{2}' border='0' height='60' width='468'></a></td>"
      Static sTopLeftFormat As String = "<td align='left' valign='top' class='ad' ><a href='{0}' target='_blank'><img src='{1}' alt='{2}' border='0' height='60' width='234'></a></td>"
      Static sTopRightFormat As String = "<td align='left' valign='top' class='ad' ><a href='{0}' target='_blank'><img src='{1}' alt='{2}' border='0' height='60' width='234'></a></td>"
      Static sLeftFormat As String = "<a href='{0}' target='_blank'><img src='{1}' alt='{2}' border='0' width='120' /></a>"
		Dim iAdCount = 0
      Try
         AdL1.Text = "<br /><br/><br /><br/><br /><br/>"
         Dim oX As System.Xml.XmlDocument = CType(Cache("xmlads"), System.Xml.XmlDocument)
         If oX Is Nothing Then
            oX = New System.Xml.XmlDocument
            Dim sPath As String = Server.MapPath("~/App_Data/ads.xml")
            If IO.File.Exists(sPath) Then
               oX.Load(sPath)
               Cache.Insert("xmlads", oX, New System.Web.Caching.CacheDependency(sPath))
            Else
               oX = Nothing
            End If
         End If
         Dim adHref As String
         Dim adAlt As String
         Dim adSrc As String
         Dim AdTopFull As String = ""
         Dim AdTL As String = "<td align='left' valign='top'><img alt='Blue Block' border='0' height='60' src='../_images/ads/ad_blue_blank.png' width='234' ></td>"
         Dim AdTR As String = "<td align='left' valign='top'><a href='../_downloads/Endeavor_current.pdf' target='_blank'><img alt='Read the latest Endeavor Newsletter' border='0' height='60' src='../_images/ads/ad_endeavor.gif' width='234'></td>"
         If oX IsNot Nothing Then
            Dim sXPath As String = "//ad"
            Dim oAds As System.Xml.XmlNodeList = oX.SelectNodes(sXPath)
            'Top Banner adds
            If oAds IsNot Nothing And oAds.Count > 0 Then
               For Each oAd As System.Xml.XmlNode In oAds
                  'add filtering for end dates
                  Dim DateCheck As Date
                  If Not oAd.SelectSingleNode("./@end") Is Nothing Then
                     If Not Date.TryParse(oAd.SelectSingleNode("./@end").Value, DateCheck) Then
                        DateCheck = Today
                     End If
                  Else
                     DateCheck = Today
                  End If
                  If DateCheck >= Today Then
     
                     If oAd.SelectSingleNode("./@location").Value = "TF" Then
                        'test section limit
                        Dim bOK As Boolean = True
                        If oAd.SelectSingleNode("./@section") IsNot Nothing Then
                           If oAd.SelectSingleNode("./@section").Value.ToUpper = "FP" AndAlso Request.AppRelativeCurrentExecutionFilePath.ToLower() <> "~/root/index.aspx" Then
                              bOK = False
                           End If
                        End If
                        If bOK Then
                           iAdCount += 1
                           adHref = oAd.SelectSingleNode("./@href").Value
                           adAlt = oAd.SelectSingleNode("./@alttext").Value
                           adSrc = oAd.SelectSingleNode("./@src").Value
                           If adSrc.StartsWith("~/") Then
                              adSrc = adSrc.Substring(1)
                           ElseIf Not adSrc.StartsWith("/") Then
                              adSrc = "/" & adSrc
                           End If
							
                           adSrc = Request.ApplicationPath & adSrc
							
                           AdTopFull = String.Format(sTopFullFormat, adHref, adSrc, adAlt)
                           Exit For
                        End If
							
                     End If
                     If oAd.SelectSingleNode("./@location").Value = "TL" Then
                        iAdCount += 1
                        adHref = oAd.SelectSingleNode("./@href").Value
                        adAlt = oAd.SelectSingleNode("./@alttext").Value
                        adSrc = oAd.SelectSingleNode("./@src").Value
                        If adSrc.StartsWith("~/") Then
                           adSrc = adSrc.Substring(1)
                        ElseIf Not adSrc.StartsWith("/") Then
                           adSrc = "/" & adSrc
                        End If
							
                        adSrc = Request.ApplicationPath & adSrc
							
                        AdTL = String.Format(sTopLeftFormat, adHref, adSrc, adAlt)
                     End If
                     If oAd.SelectSingleNode("./@location").Value = "TR" Then
                        iAdCount += 1
                        adHref = oAd.SelectSingleNode("./@href").Value
                        adAlt = oAd.SelectSingleNode("./@alttext").Value
                        adSrc = oAd.SelectSingleNode("./@src").Value
                        If adSrc.StartsWith("~/") Then
                           adSrc = adSrc.Substring(1)
                        ElseIf Not adSrc.StartsWith("/") Then
                           adSrc = "/" & adSrc
                        End If
							
                        adSrc = Request.ApplicationPath & adSrc
							
                        AdTR = String.Format(sTopRightFormat, adHref, adSrc, adAlt)
                     End If
                     
                     If oAd.SelectSingleNode("./@location").Value = "L1" Then
                        iAdCount += 1
                        adHref = oAd.SelectSingleNode("./@href").Value
                        adAlt = oAd.SelectSingleNode("./@alttext").Value
                        adSrc = oAd.SelectSingleNode("./@src").Value
                        If adSrc.StartsWith("~/") Then
                           adSrc = adSrc.Substring(1)
                        ElseIf Not adSrc.StartsWith("/") Then
                           adSrc = "/" & adSrc
                        End If
							
                        If Request.ApplicationPath <> "/" Then
                           adSrc = Request.ApplicationPath & adSrc
                        End If
							
                        AdL1.Text = String.Format(sLeftFormat, adHref, adSrc, adAlt)
                     End If
                  End If
               Next
               If AdTopFull <> String.Empty Then
                  litAdsTop.Text = AdTopFull
               Else
                  litAdsTop.Text = AdTL & AdTR
               End If
               'to do Sidebar ads
            End If
				
         End If
      Catch ex As Exception
         iAdCount = 0
      End Try
		If iAdCount = 0 Then
			'manual ads
			litAdsTop.Text = sNoAdFile
		End If
	End Sub
</script>

<html>
<head>
	<title>Annandale Chamber of Commerce</title>
	<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
	<!-- Annandale Chamber of Commerce -->
	<meta content="Annandale Chamber of Commerce" name="author">
	<meta content="Annandale Chamber of Commerce" name="description">
	<meta content="Annandale Chamber of Commerce,Annandale,Chamber,Chamber of Commerce, Virginia" name="keywords">

	<script language="JavaScript" src="../_scripts/menu1.js" type="text/javascript">
	</script>


	 <meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
	 <link href="../_style/cccBasic.css" rel="stylesheet" type="text/css" />

</head>
<body background="../_images/theme/background.gif" bgcolor="#ffffff" leftmargin="0"  text="#000000" topmargin="0">
<form runat="server">
	<font face="Arial, Helvetica" size="2">
	<!-- header -->
		<table border="0" cellpadding="0" cellspacing="0" width="630">
			<tbody>
				<tr>
					<td align="left" colspan="3" valign="top">
						<img alt="Annandale Chamber of Commerce" border="0" height="5" src="../_images/theme/header-top.gif" width="630"></td>
				</tr>
				<tr>
					<td align="left" rowspan="2" valign="top" >
						<img alt="Annandale Chamber of Commerce" border="0" height="99" src="../_images/theme/header-left.gif" width="117"></td>
					<td align="left" height="60" valign="top" width="468">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<asp:Literal ID="litAdsTop" runat="server"></asp:Literal>
								</tr>
							</tbody>
						</table>
					</td>
					<td align="left" rowspan="2" valign="top">
						<img alt="Annandale Chamber of Commerce" border="0" height="99" src="../_images/theme/header-right.gif" width="45"></td>
				</tr>
				<tr>
					<td align="left" colspan="3" valign="top">
						<img alt="Annandale Chamber of Commerce" border="0" height="39" src="../_images/theme/header-bottom.gif" width="468"></td>
				</tr>
			</tbody>
		</table>
		<table border="0" cellpadding="0" cellspacing="0" width="800">
				<tr>
					<td align="left" valign="top">
						<img border="0"  src="../_images/theme/menutop.gif" width="133"></td>
					<td align="left" colspan="2" valign="top">
						<asp:Image ID="imgCorner" runat="server"  BorderWidth="0"  borderstyle="None"  />
						</td>
				</tr>
				<tr>
				<!-- MENU -->
					<td align="left" valign="top" width="133">
						<a href="../root/index.aspx" onmouseout="msout('home');" onmouseover="msover('home'); return true;">
							<img alt="Home" border="0" height="23" name="home" src="../_images/buttons/home.gif" width="133"></a><br>
						<a href="../contactus/contact.aspx" onmouseout="msout('contactus');" onmouseover="msover('contactus'); return true;">
							<img alt="Contact Us" border="0" height="22" name="contactus" src="../_images/buttons/contactus.gif" width="133"></a><br>
						<a href="../aboutus/about.aspx" onmouseout="msout('aboutus');" onmouseover="msover('aboutus'); return true;">
							<img alt="About Us" border="0" height="23" name="aboutus" src="../_images/buttons/aboutus.gif" width="133"></a><br>
						<a href="../directory/b2b_intro.aspx" onmouseout="msout('joinnow');" onmouseover="msover('joinnow'); return true;">
							<img alt="Join Now" border="0" height="20" name="joinnow" src="../_images/buttons/joinnow.gif" width="133"></a><br>
						<a href="../directory/b2b_show.aspx" onmouseout="msout('chambermembers');" onmouseover="msover('chambermembers'); return true;">
							<img alt="Chamber Members" border="0" height="36" name="chambermembers" src="../_images/buttons/chambermembers.gif" width="133"></a><br>
						<a href="../chamberevents/events.aspx" onmouseout="msout('chamberevents');" onmouseover="msover('chamberevents'); return true;">
							<img alt="Chamber Events" border="0" height="35" name="chamberevents" src="../_images/buttons/chamberevents.gif" width="133"></a><br>
						<a href="../resources/resource.aspx" onmouseout="msout('resources');" onmouseover="msover('resources'); return true;">
							<img alt="Resources" border="0" height="23" name="resources" src="../_images/buttons/resources.gif" width="133"></a><br>
						<a href="../aboutannandale/info.aspx" onmouseout="msout('aboutannandale');" onmouseover="msover('aboutannandale'); return true;">
							<img alt="About Annandale" border="0" height="35" name="aboutannandale" src="../_images/buttons/aboutannandale.gif" width="133"></a><br/>
						<a href="../advertisinginformation/advertise.aspx" onmouseout="msout('advertisinginformation');" onmouseover="msover('advertisinginformation'); return true;">
							<img alt="Advertising Information" border="0" height="36" name="advertisinginformation" src="../_images/buttons/advertisinginformation.gif" width="133"></a><br>
						<br>
						<br>
						<center>
							<br>
                     <asp:Literal ID="AdL1" runat="server" mode="PassThrough"></asp:Literal>
							<!--
							<a href="../advertisinginformation/advertise.aspx">
								<img border="0" src="../_images/ads/placead-small.gif"></a><br>
							<img border="0" height="5" src="../_images/theme/11blank.gif" width="1"><br>
							<a href="../advertisinginformation/advertise.aspx">
								<img border="0" src="../_images/ads/placead-small.gif"></a><br>
							-->
							
							 <br />
							 <br/>
							 <asp:HyperLink ID="hlAdmin" runat="server" ImageUrl="~/_images/buttons/adminlogin.gif" NavigateUrl="~/directory/b2b_edit.aspx" text=""></asp:HyperLink>
							 
						</center>
					
						<center>
							<span style="font-size: 0.8em; color: #ffffff"><strong>Hosted by Clarocode Company, LLC</strong></span></center>
				<br />
				<br />
				<center>
							<span style="font-size: 0.6em; color: #ffffff">Design by NBR Computer Consulting, LLC</span></center>			
					</td>
					<td>
						<img border="0" height="1" src="../_images/theme/11blank.gif" width="15" alt=""/></td>
			<!-- BODY CONTENT -->		
					<td align="left" valign="top" width="667">
						<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
						</asp:ContentPlaceHolder>
					</td>
				</tr>
		</table>

	</font>
</form>
</body>
</html>

