<!--#include virtual="/includes/topofpage.asp"-->
<%
'
'
'select distinct county from businesses
'sp_columns Businesses
'
'select zip, county "county" from businesses
'	group by zip, county
'	order by "county", zip
'
'select zip, city, county from businesses
'	group by zip, city, county
'	order by county, zip, city


'Get Area Codes for County/City/State/Country
'Get Zip Codes for County/City/State/Country
'Get Counties for City/State/Country
'Get States for Country
'Get Cities for County/State/Country
'Get Countries
'Get Tax Rates for County/City/State/Country
'Get Lat/Long for City/County/State/Country
'Get Tax Rates for Entity/Group
'Non-Profit Entity does not return Tax Rates

Dim Page 
Page = "56"

Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("conn_string")

Dim RSRate, SQLRate

If (UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" And Request.Form("page") = Page And (Request.Form("cont") = "1" or Request.Form("cont") = "2")) Then

	Dim Row_ID
	For each Row_ID in Request.Form("edit")
		Expire_Date = Replace(Request.Form("Expire_Date" & Row_ID), "'", "''")
		Effective_Date = Replace(Request.Form("Effective_Date" & Row_ID), "'", "''")

		If isDate(Expire_Date) = False Then
			Expire_Date = "NULL"
		Else
			Expire_Date = "'" & Expire_Date & "'"
		End If

		If isDate(Effective_Date) = False Then
			Effective_Date = "'" & Date & "'"
		Else
			Effective_Date = "'" & Effective_Date & "'"
		End If

		Conn.Execute ("Update_Tax_Rate @Row_ID='" & Row_ID & "', @Tax_Rate = '" & Request.Form("Tax_Rate" & Row_ID) & "', @Effective_Date = " & Effective_Date & ", @Expire_Date = " & Expire_Date & ", @Verified = '" & Request.Form("Verified" & Row_ID) & "'")

	Next

    ' Linking to the next page
    If Request.Form("cont") = "1" Then Response.Redirect "manage-welcome.asp"
    'If Request.Form("cont") = "2" Then Response.Redirect "manage-welcome.asp"

End If

Dim State
If Trim(Request("State")) <> "" Then
	State = Request("State")
'ElseIf Not Trim(Session("State_Abbr")) = "" Then
'	State = Session("State_Abbr")
Else
	State = ""
End If

Dim Country
If Trim(Request("Country")) <> "" Then
	Country = Request("Country")
'ElseIf Not Trim(Session("Country_Abbr")) = "" Then
'	Country = Session("Country_Abbr")
Else
	Country="US"
End If

Dim City
If Trim(Request("City")) <> "" Then
	City = Request("City")
'ElseIf Not Trim(Session("City")) = "" Then
'	City = Session("City")
Else
	City=""
End If

If Request("cont") = "6" Then City = ""
If Request("City") = "-" Then City = ""

Dim County
If Trim(Request("County")) <> "" Then
	County = Request("County")
'ElseIf Not Trim(Session("County")) = "" Then
'	County = Session("County")
Else
	County=""
End If

 'Getting Tax Rate List

	' Getting List of that Rate Types
	Dim SQLTaxTypes, RSTax_Types
	SQLTaxTypes = "Execute Get_Tax_Rate_Types"
	Set RSTaxTypes = Conn.Execute(SQLTaxTypes)
	
	If Not RSTaxTypes.EOF Then


	End If

%>
<html>
<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #5e5ebe; SCROLLBAR-HIGHLIGHT-COLOR: #5e5ebe; SCROLLBAR-SHADOW-COLOR: #5e5ebe; SCROLLBAR-3DLIGHT-COLOR: #5e5ebe; SCROLLBAR-ARROW-COLOR:  #6666CC; SCROLLBAR-TRACK-COLOR: #E3E3E3; SCROLLBAR-DARKSHADOW-COLOR: #666666; }
</STYLE>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--

var taxtype;
var cont;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function Sub_Form (cont)
{
  form1.cont.value=cont;
  form1.submit();
}

function Add_Rate(taxtype)
{

var emsg = '';

if (!((!form1.County.value == '' && form1.City.value == '') || (form1.County.value == '' && !form1.City.value == '')) && !(form1.County.value == '' && form1.City.value == '')) emsg += 'Cannot select both a County and a City to assign a rate to.\n';

if (!emsg == '') {
	alert(emsg);
} else {
  form1.action = 'tax-rates_add.asp';
  form1.Tax_Rate_Type_ID.value = taxtype;
  form1.submit();
 }
}


function State_onchange()
{
  form1.action = 'tax-rates_admin.asp';
  form1.cont.value='3';
  form1.submit();
}

function Country_onchange()
{
  form1.action = 'tax-rates_admin.asp';
  form1.cont.value='4';
  form1.submit();
}


function City_onchange()
{
//  if (!form1.City.value == '') {
    form1.action = 'tax-rates_admin.asp';
    form1.cont.value='5';
    form1.submit();
//  }
}

function County_onchange()
{
  if (!form1.County.value == '') {
    form1.City.value = '';
    form1.action = 'tax-rates_admin.asp';
    form1.cont.value='6';
    form1.submit();
  }
}

//-->
</script>
<link rel="stylesheet" href="../Style-sheets/standard-input-form.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/headline.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/galley-text-indent.css" type="text/css">
</head>

<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/icon-return-to-main-2.gif','images/icon-submit-changes-2.gif','images/icon-continue-wizard-2.gif')">
<form name="form1" method="post" action="">
<INPUT type="hidden" id=page name=page value="<%=Page%>">
<INPUT type="hidden" id=cont name=cont value="">
<INPUT type="hidden" id=Tax_Rate_Type_ID name=Tax_Rate_Type_ID>
  <table width="525" border="0" cellspacing="0" cellpadding="2" align="center">
    <tr> 
      <td width="338">&nbsp;</td>
      <td align="right" width="187">&nbsp;</td>
    </tr>
    <tr> 
      <td width="338" bgcolor="#5e5ebe" class="headline-ffffff" align="middle">Tax Rate Management</td>
      <td bgcolor="#5e5ebe" align="right" width="187"><A onmouseover="MM_swapImage('Image1','','images/icon-return-to-main-2.gif',1)" onmouseout=MM_swapImgRestore() href="default-lodging.asp"><IMG height=17 src="images/icon-return-to-main.gif" width=75 useMap=#returntomain border=0 name=Image1></a></td>
    </tr>
    <tr> 
      <td class="galley-text-indent" colspan="2">Tax Management for:&nbsp;&nbsp; <% If City = "" And County <> "" Then Response.Write(County & " County,") %>&nbsp;<% If City <> "" Then Response.Write(City & ",") %>&nbsp;<% If State <> "" Then Response.Write(State) %>&nbsp;<% If Country <> "" Then Response.Write(Country) %></td>
    </tr>
  </table>
  <table width="500" border="0" cellspacing="0" cellpadding="2" align="center">
    <tr> 
      <td width="45">&nbsp;</td>
      <td width="109">&nbsp;</td>
      <td width="334">&nbsp;</td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td colspan="2" class="manage-menu-bold">Tax Rates For:</td>
    </tr>
    <tr> 
      <td colspan="3">
	<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr><td width="50"></td><td class="manage-menu" valign="top">Country:</td><td class="manage-menu" valign="top">State/Province:</td></tr>
	<tr><td width="100">&nbsp;</td><td><select name="Country" onchange="return Country_onchange()" id="Country" Language="JAVASCRIPT">
<%
	Dim RSCountry
   Set RSCountry = Conn.Execute("Select * from Countries;")

   If Not RSCountry.EOF Then
	Do Until RSCountry.EOF
       Response.Write "<option value=""" & Trim(RSCountry("Country_Abbr")) & """"
       If Trim(RSCountry("Country_Abbr")) = Trim(Country) Then Response.Write " selected"
       Response.Write ">" & RSCountry("Country_Name") & "</option>" & Chr(13)
       RSCountry.MoveNext
    Loop
   End If 
%>        
	</select></td><td><select name="State" onchange="return State_onchange()" id="State" Language="JAVASCRIPT">
		<option value="">Select</option>
<%
	Dim RSState
   Set RSState = Conn.Execute("Select * from States S Inner Join Countries C On S.Country_ID = C.Country_ID Where C.Country_Abbr='" & Country & "';")

   If Not RSState.EOF Then
	Do Until RSState.EOF
       Response.Write "<option value=""" & Trim(RSState("State_Abbr")) & """"
       If Trim(RSState("State_Abbr")) = Trim(State) Then Response.Write " selected"
       Response.Write ">" & RSState("State_Name") & "</option>" & Chr(13)
       RSState.MoveNext
    Loop
   End If 
%>        
		</select></td></tr>
	<tr><td colspan="3">&nbsp;</td></tr>
	<tr><td width="50"></td><td class="manage-menu" valign="top">City:</td><td class="manage-menu" valign="top">County:</td></tr>
	<tr><td></td>
		<td><select name="City"onchange="return City_onchange()" id="City" Language="JAVASCRIPT">
		<option value="">Select</option>
<%
	Dim RSCities
   Set RSCities = Conn.Execute("Get_Cities @State_Abbr='" & State & "', @Country_Abbr = '" & Country & "'")

   If Not RSCities.EOF Then
	Do Until RSCities.EOF
       Response.Write "<option value=""" & Trim(RSCities("City")) & """"
       If Trim(RSCities("City")) = Trim(City) Then Response.Write " selected"
	Response.Write ">" & RSCities("City") & "</option>" & Chr(13)
       RSCities.MoveNext
    Loop
   End If       
%>        
      </select></td>
		<td><select name="County" onchange="return County_onchange()" id="County" Language="JAVASCRIPT">
		<option value="">Select</option>
<%
	Dim RSCounties
   Set RSCounties = Conn.Execute("Get_Counties @City='" & City & "', @State_Abbr='" & State & "', @Country_Abbr = '" & Country & "'")

   If Not RSCounties.EOF Then
	Do Until RSCounties.EOF
       Response.Write "<option value=""" & Trim(RSCounties("County")) & """"
       If Trim(RSCounties("County")) = Trim(County) Then Response.Write " selected"
	   Response.Write ">" & RSCounties("County") & "</option>" & Chr(13)
       RSCounties.MoveNext
    Loop
   End If       
%>        
      </select></td></tr>
	</table>
      </td>
    </tr>
    <tr> 
      <td width="45">&nbsp;</td>
      <td width="109">&nbsp;</td>
      <td width="334">&nbsp;</td>
    </tr>

	<% Do While Not RSTaxTypes.EOF	
		SQLRate = "Get_Tax_Rate_Locale @County='" & County & "', @City='" & City & "', @State='" & State & "', @Country='" & Country & "', @Tax_Rate_Type_ID='" & RSTaxTypes("Tax_Rate_Type_ID") & "', @Verified='0', @Date_Off='1'"
		'Response.Write SQLRate
		Set RSRate = Conn.Execute(SQLRate)
%>
    <tr> 
      <td colspan="3"  height="16" class="manage-menu-bold"><%=RSTaxTypes("Tax_Type_Name")%></td>
    </tr>
	<% If Not RSRate.EOF Then
		Do While Not RSRate.EOF %>
    <tr> 
      <td width="45" class="manage-menu">&nbsp;</td>
      <td  width="109" class="manage-menu">Tax Rate:</td>
      <td  width="334" class="manage-menu">
         &nbsp;&nbsp;Effective Date:&nbsp;&nbsp;Expire Date:&nbsp;&nbsp;&nbsp;&nbsp;Active?</td>
    </tr>
 
    <tr> 
      <td width="45"><input type="checkbox" name="edit" value="<%=RSRate("Row_ID")%>"></td>
      <td width="109" align="left">&nbsp;&nbsp;&nbsp;<input name="Tax_Rate<%=RSRate("Row_ID")%>" size="4" Value="<%=RSRate("Tax_Rate")%>"></td>
      <td class="manage-menu">&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="Effective_Date<%=RSRate("Row_ID")%>" size="10" value="<%=RSRate("Effective_Date")%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="Expire_Date<%=RSRate("Row_ID")%>" size="10" value="<%=RSRate("Expire_Date")%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="Verified<%= RSRate("Row_ID")%>" <% If RSRate("Verified") = True Then Response.Write "checked"%>> Yes</td>
    </tr>
	<%	  RSRate.MoveNext
	     Loop
	   Else %>
	<% End If
	%>

    <tr>
      <td colspan="3" class="manage-menu" align="right"><a onClick="Add_Rate('<%=RSTaxTypes("Tax_Rate_Type_ID")%>')" style="{cursor:hand; text-decoration:none; background-color:#e3e3e3;}" class="manage-menu"><font size="1">&nbsp;Add a New <%=RSTaxTypes("Tax_Type_Name")%> Rate&nbsp;</font></a></td>
    </tr>
    <tr> 
      <td width="45">&nbsp;</td>
      <td width="109">&nbsp;</td>
      <td width="334">&nbsp;</td>
    </tr>

    <%	
	   RSTaxTypes.MoveNext
	   Loop
	%>
	 
    <tr> 
      <td width="45">&nbsp;</td>
      <td width="109">&nbsp;</td>
      <td width="334">&nbsp;</td>
    </tr>
  </table>

  <table width="525" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr bgcolor="#5e5ebe"> 
 <!-- -->
      <td align="right" width="49%" bgcolor="#5e5ebe">
		<a href="javascript:Sub_Form('1');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('submitchanges','','images/icon-submit-changes-2.gif',1)">
			<img src="images/icon-submit-changes.gif" width="200" height="15" name="submitchanges" border="0">
		</a>
	  </td>
      <td width="51%">
		<a href="javascript:Sub_Form('2');" onmouseover="MM_swapImage('Image2','','images/icon-continue-wizard-2.gif',1)"  onmouseout=MM_swapImgRestore()>
			<img src="images/icon-continue-wizard.gif" width="150" height="15" usemap="#continue" border="0" name="Image2">
		</a>
	  </td>
 </tr>
  <tr> 
    <td width="49%">&nbsp;</td>
    <td width="51%">&nbsp;</td>
  </tr>
</table> 
</form>
</body>
</html>
<% Set Conn = Nothing %>