var UpstateTax = {};
function getData(id){
  if (!UpstateTax.states) 
  UpstateTax.states = [
    {
        name    : 'Alabama Department of Revenue',
        website : 'http://www.ador.state.al.us',
        refund  : 'https://www.alabamainteractive.org/cgi-bin/ador/income_tax_lookup/search.cgi'
    },{
        name    : 'Alaska Department of Revenue',
        website : 'http://www.revenue.state.ak.us',
        refund  : ''
    },{
        name    : 'Arizona Department of Revenue',
        website : 'http://www.revenue.state.az.us',
        refund  : 'https://www.aztaxes.gov'
    },{

        name    : 'Arkansas DFA',
        website : 'http://www.arkansas.gov/dfa/',
        refund  : 'https://www.ark.org/dfa_ri/app/login.html'
    },{
        name    : 'California Franchise Tax Board',
        website : 'http://www.ftb.ca.gov',
        refund  : 'http://www.ftb.ca.gov/online/refund/index.asp'

    },{
        name    : 'Colorado Department of Revenue',
        website : 'http://www.revenue.state.co.us',
        refund  : 'https://www.myincometax.state.co.us/index.asp'
    },{
        name    : 'Connecticut DRS',
        website : 'http://www.ct.gov/drs',
        refund  : 'https://drsindtax.ct.gov/AUT/refundStatus.aspx?TXPYRTYP=I'
    },{
        name    : 'Delaware Division of Revenue',
        website : 'http://www.state.de.us/revenue',
        refund  : 'https://dorweb.revenue.delaware.gov/refinq/'
    },{
        name    : 'District of Columbia',
        website : 'http://cfo.dc.gov/etsc',
        refund  : 'https://www.taxpayerservicecenter.com/individual/Ind_RefundStatus_Logon.jsp'
    },{
        name    : 'Florida Department of Revenue',
        website : 'http://www.myflorida.com/dor',
        refund  : ''
    },{
        name    : 'Georgia Department of Revenue',
        website : 'http://www.etax.dor.ga.gov',
        refund  : 'https://etax.dor.ga.gov/WMRefund/index.aspx'
    },{
        name    : 'Hawaii Department of Taxation',
        website : 'http://www.state.hi.us/tax',
        refund  : 'https://tax.ehawaii.gov/hoihoi/refund.html'
    },{
        name    : 'Idaho State Tax Commission',
        website : 'http://tax.idaho.gov/index.html',
        refund  : 'https://www.accessidaho.org/secure/istc/refund/status.html'
    },{
        name    : 'Illinois Department of Revenue',
        website : 'http://www.revenue.state.il.us',
        refund  : 'https://www.revenue.state.il.us/app/refund/servlet/RefundStatus'
    },{
        name    : 'Indiana Department of Revenue',
        website : 'http://www.in.gov/dor',
        refund  : 'https://secure.in.gov/apps/dor/tax/refund/'
    },{
        name    : 'Iowa Department of Revenue',
        website : 'http://www.state.ia.us/tax',
        refund  : 'https://eservices.idrf.state.ia.us/taxrefund/index.jsp'
    },{
        name    : 'Kansas Department of Revenue',
        website : 'http://www.ink.org/public/kdor',
        refund  : 'https://www.kdor.org/refundstatus/default.asp'
    },{
        name    : 'Kentucky Dept. of Revenue',
        website : 'http://revenue.ky.gov',
        refund  : 'http://revenue.ky.gov/refund.htm'
    },{
        name    : 'Louisiana Dept. of Revenue',
        website : 'http://www.rev.state.la.us',
        refund  : 'https://webtax2.rev.louisiana.gov/status/refund/'
    },{
        name    : 'Maine Revenue Services',
        website : 'http://www.state.me.us/revenue',
        refund  : 'https://portalx.bisoex.state.me.us/jav/RefundStatus_prod/'
    },{
        name    : 'Maryland Comptroller',
        website : 'http://www.marylandtaxes.com',
        refund  : 'https://interactive.marylandtaxes.com/INDIV/refundstatus/home.aspx'
    },{
        name    : 'Massachusetts Dept. of Revenue',
        website : 'http://www.mass.gov/dor',
        refund  : 'https://wfb.dor.state.ma.us/webfile/wsi/'
    },{
        name    : 'Michigan Department of Treasury',
        website : 'http://www.michigan.gov/treasury',
        refund  : 'https://treas-secure.treas.state.mi.us/eservice_enu/'
    },{
        name    : 'Minnesota Dept. of Revenue',
        website : 'http://www.taxes.state.mn.us',
        refund  : 'https://www.mndor.state.mn.us/wm/servlets/TaxReturnsServlet'
    },{
        name    : 'Mississippi State Tax Commission',
        website : 'http://www.mstc.state.ms.us',
        refund  : 'https://www.mstc.state.ms.us/IncomeInquiry/index.jsp'
    },{
        name    : 'Missouri Department of Revenue',
        website : 'http://dor.mo.gov',
        refund  : 'https://dors.mo.gov/tax/taxinq/welcome.jsp'
    },{
        name    : 'Montana Department of Revenue',
        website : 'http://www.state.mt.us/revenue',
        refund  : 'https://tap.dor.mt.gov/MT_xwTapRfn.aspx'
    },{
        name    : 'Nebraska Dept. of Revenue',
        website : 'http://www.revenue.state.ne.us',
        refund  : 'http://www.revenue.state.ne.us/refund/refunds.htm'
    },{
        name    : 'New Hampshire Dept. of Rev.',
        website : 'http://webster.state.nh.us/revenue',
        refund  : ''
    },{
        name    : 'New Jersey Division of Revenue',
        website : 'http://www.state.nj.us/treasury/taxation',
        refund  : ''
    },{
        name    : 'New Mexico Taxation &amp; Revenue',
        website : 'http://www.state.nm.us/tax',
        refund  : 'https://tap.state.nm.us/NM_xwTapRfn.aspx'
    },{
        name    : 'New York Dept. of Tax and Finance',
        website : 'http://www.tax.state.ny.us',
        refund  : 'https://www8.nystax.gov/PRIS/prisHome'
    },{
        name    : 'North Carolina Dept. of Revenue',
        website : 'http://www.dor.state.nc.us',
        refund  : 'https://eservices.dor.nc.gov/wheresmyrefund/'
    },{
        name    : 'North Dakota State Tax Comm.',
        website : 'http://www.nd.gov/tax',
        refund  : 'http://www.nd.gov/tax/indincome/refundinfo/'
    },{
        name    : 'Ohio Department of Taxation',
        website : 'http://tax.ohio.gov',
        refund  : 'https://www.tax.state.oh.us/PROD/WheresMyRefundWeb/wheresmyrefund.jsp'
    },{
        name    : 'Oklahoma Tax Commission',
        website : 'http://www.oktax.state.ok.us',
        refund  : 'http://www.tax.ok.gov/refund.html'
    },{
        name    : 'Oregon Department of Revenue',
        website : 'http://egov.oregon.gov/DOR',
        refund  : 'http://www.tax.ok.gov/refund.html'
    },{
        name    : 'Pennsylvania Dept. of Revenue',
        website : 'http://www.revenue.state.pa.us',
        refund  : 'http://www.doreservices.state.pa.us/Individual/RefundDefault.htm?revenueNav=|689|'
    },{
        name    : 'Rhode Island Division of Taxation',
        website : 'http://www.tax.ri.gov',
        refund  : 'https://www.ri.gov/cgi-bin/taxation/refund/status.cgi'
    },{
        name    : 'South Carolina Dept. of Revenue',
        website : 'http://www.sctax.org',
        refund  : 'https://www.sctax.org/refundstatus/refund.aspx'
    },{
        name    : 'Tennessee Dept. of Revenue',
        website : 'http://www.state.tn.us/revenue',
        refund  : ''
    },{
        name    : 'Texas Comptroller of Public Accts.',
        website : 'http://www.window.state.tx.us/taxes',
        refund  : ''
    },{
        name    : 'Utah State Tax Commission',
        website : 'http://tax.utah.gov',
        refund  : 'https://tax.utah.gov/txrw/'
    },{
        name    : 'Vermont Department of Taxes',
        website : 'http://www.state.vt.us/tax',
        refund  : 'https://secure.vermont.gov/TAX/refund/'
    },{
        name    : 'Virginia Department of Taxation',
        website : 'http://www.tax.virginia.gov',
        refund  : 'http://www.tax.virginia.gov/site.cfm?alias=WhereIsMyRefund'
    },{
        name    : 'West Virginia State Tax Dept.',
        website : 'http://www.state.wv.us/taxdiv',
        refund  : 'https://www.state.wv.us/secure/tax/'
    },{
        name    : 'Wisconsin Dept. of Revenue',
        website : 'http://www.dor.state.wi.us',
        refund  : 'http://www.dor.state.wi.us/faqs/inquiry.html'
		}]
    return (id == null) ? UpstateTax.states : UpstateTax.states[id];
}

function handleClick(event,id){
  function createElement(name, cls) {
    var e = document.createElement(name);
    if (cls) e.className = cls;
    return e;
  }
  var data = getData(id);
  if (data.el) data.el.dom.style.display = 'block';
  else {
    var tip = createElement('div', 'x-tip');
    var el = tip.appendChild(createElement('div','x-tip-tl'));
    el = el.appendChild(createElement('div','x-tip-tr'));
    el = el.appendChild(createElement('div','x-tip-tc'));
    el = el.appendChild(createElement('div','x-tip-header x-unselectable x-tip-draggable'));
    el.appendChild(createElement('div','x-tool x-tool-close')).onclick = function (){
      var x = this;
      while (x.className != 'x-tip') {
        x = x.parentNode;
      } 
      x.style.display = 'none';
    };;
    el = el.appendChild(createElement('span','x-tip-header-text'));
    el.innerHTML = data.name;

    // see if we can get name width
    var tmp = document.createElement('div');
    document.body.appendChild(tmp);
    tmp.style.position = 'absolute';
    tmp.style.top = '-1000px';
    tmp.style.left = '-1000px';
    tmp.style.visibility = 'hidden';
    tmp.innerHTML = data.name;

    var wrap = tip.appendChild(createElement('div','x-tip-bwrap'));
    el = wrap.appendChild(createElement('div','x-tip-ml'));
    el = el.appendChild(createElement('div','x-tip-mr'));
    el = el.appendChild(createElement('div','x-tip-mc'));
    var content = el.appendChild(createElement('div','x-tip-body'));
    content.style.width = tmp.offsetWidth + 'px';
    tip.style.width = (tmp.offsetWidth+18) + 'px';
    el = content.appendChild(createElement('a'));
    el.href=data.website;
    el.innerHTML = "Website";
    el.target = '_blank';
    el = content.appendChild(createElement('br'));
    el = content.appendChild(createElement('a'));
    el.href=data.refund;
    el.innerHTML = "Refund Tracking";
    el.target = '_blank';

    el = wrap.appendChild(createElement('div','x-tip-bl x-panel-nofooter'));
    el = el.appendChild(createElement('div','x-tip-br'));
    el.appendChild(createElement('div','x-tip-bc'));

    el = Ext.fly(document.body);
    tip.style.top = (event.clientY-50+(Ext.isGecko ? window.pageYOffset : 0))+'px';
    tip.style.left = (event.clientX+(Ext.isGecko ? window.pageXOffset : 0))+'px';
    data.el = el.appendChild(tip);
  }  
  // This doesn't position well if scroll bars are scrolled.
}  
