﻿var DepartmentTitle = "City Clerk";
var Path = location.pathname.toUpperCase();

var DepartmentMenus = Array(
    Array("Budgets &amp; Taxes", "/ct/budget/"), 
    Array("Business Licensing", "/ct/business/"), 
    Array("Dog Licenses", "/ct/doglicense/"), 
    Array("Elections", "/ct/elections/"),
    Array("Financial Reports", "/ct/financialreports/"),
    Array("Justices of the Peace", "/ct/jp/"),
    Array("Land Records", "/ct/landrecords/"),
    Array("Property Taxes", "/ct/propertytax/"),
    Array("Vital Records", "/ct/vitalrecords/")
);

var BudgetSub = Array(
    Array("Fiscal 2006", "/ct/budget/2006/"),
    Array("Fiscal 2007", "/ct/budget/2007/"),
    Array("Fiscal 2008", "/ct/budget/2008/"),
    Array("Fiscal 2009", "/ct/budget/2009/"),
    Array("Fiscal 2010", "/ct/budget/2010/")
);

var ElectionsSub = Array(
   Array("How to Vote", "/ct/elections/instructions/"),
   Array("Where to Vote", "/ct/elections/locations/"),
   Array("Election Results", "/ct/elections/results/"),
   Array("Instant Runoff Voting", "/ct/elections/irv")
);

var TaxSub = Array(
    Array("Tax Calculator", "/ct/propertytax/calculate/"),
    Array("How to Calculate", "/ct/propertytax/howto/"),
    Array("Tax Dates", "/ct/propertytax/dates/"),
    Array("Change of Address", "/assessor/address/")
);

var Vitals = Array(
    Array("Birth", "/ct/vitalrecords/birth/"),
    Array("Death", "/ct/vitalrecords/death/"),
    Array("Marriage", "/ct/vitalrecords/marriage/")
);

function ShowDepartmentMenu(){
    for(var i=0; i<DepartmentMenus.length; i++){
        if(Path.match(DepartmentMenus[i][1].toUpperCase())){
            document.write('<div style=\"font-weight: bold;\"><a href=\"' + DepartmentMenus[i][1] + '\">' + DepartmentMenus[i][0] + '</a></div>');
            if(i==0){//budget submenu
                for(var x=0; x<BudgetSub.length; x++){
                    if(Path.match(BudgetSub[x][1].toUpperCase())){
                        document.write('<div style=\"font-weight: bold; padding-left: 25px;\"><a href=\"' + BudgetSub[x][1] + '\">' + BudgetSub[x][0] + '</a></div>');
                    }
                    else{
                        document.write('<div style=\"padding-left: 25px;\"><a href=\"' + BudgetSub[x][1] + '\">' + BudgetSub[x][0] + '</a></div>');
                    }
                }
            }

            if(i==3){//elections submenu
                for(var x=0; x<ElectionsSub.length; x++){
                    if(Path.match(ElectionsSub[x][1].toUpperCase())){
                        document.write('<div style=\"font-weight: bold; padding-left: 10px;\"><a href=\"' + ElectionsSub[x][1] + '\">' + ElectionsSub[x][0] + '</a></div>');
                    }
                    else{
                        document.write('<div style=\"padding-left: 10px;\"><a href=\"' + ElectionsSub[x][1] + '\">' + ElectionsSub[x][0] + '</a></div>');
                    }
                }
            }

            if(i==7){//tax submenu
                for(var x=0; x<TaxSub.length; x++){
                    if(Path.match(TaxSub[x][1].toUpperCase())){
                        document.write('<div style=\"font-weight: bold; padding-left: 25px;\"><a href=\"' + TaxSub[x][1] + '\">' + TaxSub[x][0] + '</a></div>');
                    }
                    else{
                        document.write('<div style=\"padding-left: 25px;\"><a href=\"' + TaxSub[x][1] + '\">' + TaxSub[x][0] + '</a></div>');
                    }
                }
            }
        }
        else{
            document.write('<div><a href=\"' + DepartmentMenus[i][1] + '\">' + DepartmentMenus[i][0] + '</a></div>');
        }
    }
    for(i=0; i<Vitals.length; i++){
        if(Path.match(Vitals[i][1].toUpperCase())){
            document.write('<div style=\"font-weight: bold; padding-left: 25px;\"><a href="' + Vitals[i][1] + '">' + Vitals[i][0] + '</a></div>');
        }
        else{
            document.write('<div style=\"padding-left: 25px;\"><a href="' + Vitals[i][1] + '">' + Vitals[i][0] + '</a></div>');
        }
    }    
}