    function topic_OnChange(Topic) {  
    
    getIndicators("getIndicators.ashx?topicid="+Topic.value, iHandler);
    }

function getIndicators(url, responseHandler)   
 {   
     if (window.XMLHttpRequest)   
      {   
          // browser has native support for XMLHttpRequest object   
          req = new XMLHttpRequest();   
      }   
      else if (window.ActiveXObject)   
      {   
         // try XMLHTTP ActiveX (Internet Explorer) version   
         req = new ActiveXObject("Microsoft.XMLHTTP");   
      }   
         
      if(req)   
      {   
          req.onreadystatechange = responseHandler;   
          req.open('GET', url, true);   
          req.setRequestHeader("content-type","application/x-www-form-urlencoded");   
          req.send('');   
      }   
      else  
      {   
          alert('Your browser does not seem to support XMLHttpRequest.');   
      }   
} 

function iHandler()
{
    if (req.readyState == 4 || req.readyState == 'complete')   
    { 
        //Exception handling for ashx page           
        if(req.responseText == 'error')
        {
            window.location = '/home.aspx'; 
        }
        else
        {
            document.getElementById("select").innerHTML = req.responseText;                    
        }
    }  
}

function refresh()
{
    var size = document.getElementById("ctl00_contentBody_rbsize");
    var sector = document.getElementById("ctl00_contentBody_rbsector");
    var owner = document.getElementById("ctl00_contentBody_rbowner");
    var exporting = document.getElementById("ctl00_contentBody_rbexport");
    var indicator = document.getElementById("ddlIndicator");
    var characteristic;

    if(size.checked == true) characteristic = "size";
    else if(sector.checked == true) characteristic = "sector";
    else if(owner.checked == true) characteristic = "ownership";
    else if(exporting.checked == true) characteristic = "exporter";

    window.location = "/CustomQuery/Indicators.aspx?characteristic="+characteristic+"&indicator="+indicator.value;
}


function countryRefresh()
{
    var size = document.getElementById("ctl00_contentBody_rbsize");
    var sector = document.getElementById("ctl00_contentBody_rbsector");
    var owner = document.getElementById("ctl00_contentBody_rbowner");
    var exporting = document.getElementById("ctl00_contentBody_rbexport");
    var economy_year = document.getElementById("ddlEconomy");
    var economy = economy_year.value.split(":");

    var characteristic;

    if(size.checked == true) characteristic = "size";
    else if(sector.checked == true) characteristic = "sector";
    else if(owner.checked == true) characteristic = "ownership";
    else if(exporting.checked == true) characteristic = "exporter";

    window.location = "/CustomQuery/country.aspx?economyid="+economy[0]+"&year="+economy[1]+"&characteristic="+characteristic;
}


function window_onload()
{
    var topicid;
    
    if(document.getElementById("ddlTopic") != null)
    {
        topicid = document.getElementById("ddlTopic").value;
    }
    
    if(topicid >= 0){
        ddlIndicator_OnLoad(document.getElementById("ddlTopic"), document.getElementById("indicatorid"));
        
    }
}

function ddlIndicator_OnLoad(Topic, Indicator) {  
    
    getIndicators("getIndicators.ashx?topicid="+Topic.value+"&indicatorid="+Indicator.value, iHandler);
}


window.onload = window_onload;