<%@ LANGUAGE="VBSCRIPT" %> Bullseye PRO Dealer Locator version 2.0

<% On Error Resume Next ' Open Database Connection Set Conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data\islamicbase.mdb" adminSQL = "SELECT * FROM AdminInfo;" Set adminQuery = Conn.Execute(adminSQL) If Request.Form("reqZip") <> "" Then uzipSQL = "SELECT * FROM ZIPS WHERE ZipCode = '" & Request.Form("reqZip") & "'" Set uzipQuery = Conn.Execute(uzipSQL) If NOT uzipQuery.EOF Then 'Select States Near Zip Code State stateSQL = "SELECT * FROM States WHERE State = '" & uzipQuery("State") & "';" Set stateQuery = Conn.Execute(stateSQL) strSQL = "SELECT Companies.*, zips.Latitude, zips.Longitude FROM Companies INNER JOIN zips ON Companies.Zip = zips.ZipCode " strSQL = strSQL & "WHERE Companies.Zip Is Not Null " strSQL = strSQL & "AND (" While NOT stateQuery.EOF strSQL = strSQL & "Companies.State = '" & stateQuery("Neighbor") &"' OR " stateQuery.MoveNext Wend strSQL = strSQL & "Companies.State = '" & uzipQuery("State") & "') " strSQL = strSQL & "ORDER BY Company;" Set rsQuery = Conn.Execute(strSQL) End If 'unzipQuery.EOF End If 'reqZip not empty ' Return Results If Request.Form("reqZip") = "" Then Response.Write "Sorry, you must enter a zip code to search near. " Response.Write "Please try another search.

" ElseIf uzipQuery.EOF Then Response.Write "Sorry, you must enter a valid zip code to search near. " Response.Write "Please try another search.

" ElseIf rsQuery.EOF Then Response.Write "Sorry, we didn't find any companies within the selected radius. " Response.Write "Please try another search.

" Else If Request.Form("Hits") = "" Then NumHits = 0 FirstHit = 0 Hits = "" Dim Index() Dim Distances() Rad = Request.Form("RADIUS") * 1 If Request.Form("reqZip") <> "" Then While NOT rsQuery.EOF If rsQuery("Zip") <> "" Then If Request.Form("reqZip") = rsQuery("Zip") Then Distance = 0 Else Distance = Int(DistCalc(rsQuery("Latitude"), rsQuery("Longitude"), uzipQuery("Latitude"), uzipQuery("Longitude"))) End If If (Rad >= Distance) Then NumHits = NumHits + 1 ReDim Preserve Index(NumHits) ReDim Preserve Distances(NumHits) Index(NumHits - 1) = rsQuery("CompanyNumber") Distances(NumHits - 1) = Distance End If End If rsQuery.MoveNext Wend rsQuery.MoveFirst For i = 0 To NumHits - 1 For j = i To NumHits - 1 If Distances(i) > Distances(j) Then Temp = Distances(i) Distances(i) = Distances(j) Distances(j) = Temp Temp = Index(i) Index(i) = Index(j) Index(j) = Temp End If Next Next For i = 0 to NumHits - 1 Hits = Hits & Index(i) & "," Next NumHits = NumHits FirstHit = 0 Hits = Left(Hits, Len(Hits) -1) End If Else NumHits = Request.Form("NumHits") * 1 FirstHit = Request.Form("FirstHit") * 1 Hits = Request.Form("Hits") End If Dim HitsArray() ReDim HitsArray(NumHits) HitsList = Hits For i = 0 To NumHits - 1 CutAt = Instr(1, HitsList, ",") If (CutAt <> 0) Then HitsArray(i) = Left(HitsList, CutAt - 1) HitsList = Mid(HitsList, CutAt + 1) Else HitsArray(i) = HitsList End If Next StartPoint = FirstHit EndPoint = StartPoint + 4 If EndPoint > NumHits - 1 Then EndPoint = NumHits - 1 End If If Numhits = 0 Then Response.Write "

Sorry, we didn't find any companies within the selected radius. " Response.Write "Please try another search.


" Else response.write "
" response.write"Search Results:" response.write "
" navTable = "" hitsofnum = "Records " & StartPoint + 1 & "-" & EndPoint + 1 & " of " & NumHits If StartPoint > 0 Then navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" Else navTable = navTable & "" End If navTable = navTable & "" If NumHits > EndPoint + 1 Then navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" navTable = navTable & "" Else navTable = navTable & "" End If navTable = navTable & "
" navTable = navTable & "" navTable = navTable & "
" navTable = navTable & " " navTable = navTable & "" & hitsofnum & "
" navTable = navTable & "" navTable = navTable & "" navTable = navTable & " " navTable = navTable & "
" response.write navTable response.write "
" For i = StartPoint To EndPoint strSQL = "SELECT Companies.*, zips.Latitude, zips.Longitude FROM Companies INNER JOIN zips ON Companies.Zip = zips.ZipCode " strSQL = strSQL & "WHERE Companies.CompanyNumber = " & HitsArray(i) & ";" Set rsQuery = Conn.Execute(strSQL) response.write "" response.write "
" If rsQuery("Company") <> "" Then response.write "" response.write " " response.write " " End if response.write " " If rsQuery("Street") <> "" Then response.write "" response.write " " response.write " " End if If rsQuery("Street2") <> "" Then response.write "" response.write " " response.write " " End if If rsQuery("City") <> "" Then response.write "" response.write " " response.write " " End if If rsQuery("Phone") <> "" Then response.write "" response.write " " response.write " " End if If rsQuery("Fax") <> "" Then response.write "" response.write " " response.write " " End if If rsQuery("Email") <> "" Then response.write "" response.write " " response.write " " response.write "" End if If rsQuery("URL") <> "" Then response.write "" response.write " " response.write " " response.write "" End if response.write "" response.write " " If (Request.Form("reqZip") = rsQuery("Zip")) Then response.write " " Else Distance = Int(DistCalc(rsQuery("Latitude"), rsQuery("Longitude"), uzipQuery("Latitude"), uzipQuery("Longitude"))) response.write " " End if response.write "" If ((rsQuery("User1") <> "") AND (adminQuery("User1Name") <> "")) Then response.write "" response.write " " response.write " " response.write "" End if If ((rsQuery("User2") <> "") AND (adminQuery("User2Name") <> "")) Then response.write "" response.write " " response.write " " response.write "" End if If ((rsQuery("User3") <> "") AND (adminQuery("User3Name") <> "")) Then response.write "" response.write " " response.write " " response.write "" End if response.write "
Mosque" & rsQuery("Company") & "
" If AdminQuery("map") = -1 Then response.write "
" response.write "" response.write "" response.write "" response.write "" response.write "" response.write "
" Else response.write " " End If response.write "
Address" & rsQuery("Street") & "
 " & rsQuery("Street2") & "
 " & rsQuery("City") & " " & rsQuery("State") & " " & rsQuery("Zip") & " " & rsQuery("Country") & "
Phone" & rsQuery("Phone") & "
Fax" & rsQuery("Fax") & "
E-Mail" & rsQuery("Email") & "
Web" & rsQuery("URL") & "
DistanceSame Town/CityApprox. " & Distance & " Miles
" & adminQuery("User1Name") & "" & rsQuery("User1") & "
" & adminQuery("User2Name") & "" & rsQuery("User2") & "
" & adminQuery("User3Name") & "" & rsQuery("User3") & "

" Next response.write navTable End If End If %>

colspan=5>Perform A New Search
Enter Your Zip Code " size="5" maxlength="5"> Search Within a Mile Radius.