// JScript File
function rbgShowRegionOrIG_OnClick(selectedItem)
{
switch (selectedItem)
	{
		case 0:		  
		    document.getElementById("ddMCIncomeGroup").disabled=true;
		    document.getElementById("ddMCRegion").disabled=false;
		    break;
		case 1:
		    document.getElementById("ddMCIncomeGroup").disabled=false;
		    document.getElementById("ddMCRegion").disabled=true;
		    break;
	   

    }
}
function Window_OnLoad()
	{

	    ddlMCTopic_OnChange(document.getElementById("ddlMCTopic"));
	    ddlSBTopic_OnChange(document.getElementById("ddlSBTopic"));

	
	}
    
   window.onload = Window_OnLoad;

	function ddlMCTopic_OnChange(Topic) { 
	    
   	    var topicID;
   	    var indicatorID;
   	    
	    
	    if (document.getElementById("txtTopicID").value != null)
	    {
	        
	        document.getElementById("txtTopicID").value = Topic.value;
	        topicID = document.getElementById("txtTopicID").value;
	    }
	    else
	    {
	        topicID = 1;
	    }
	    document.getElementById("txtTopicID").value = topicID;

	    if ((document.getElementById("txtIndicatorID").value != null) && (document.getElementById("txtIndicatorID").value != ""))
	    {

                indicatorID = document.getElementById("txtIndicatorID").value;

	    
	    }
	    else
	    {
	            document.getElementById("txtIndicatorID").value = 1;
	    	    indicatorID = document.getElementById("txtIndicatorID").value;
	    }

	    getIndicators("/Custom/getIndicatorsDYOA.ashx?topicid="+topicID+"&noattrib=false&indicatorid=" +  indicatorID  + "&controlname=ddlMCIndicator", iHandler);
  
        
       }
       
       	function ddlSBTopic_OnChange(Topic) { 
	    
   	    var topicID;
   	    var indicatorID;
   	    
	    
	    if (document.getElementById("txtSBTopicID").value != null)
	    {
	        
	        document.getElementById("txtSBTopicID").value = Topic.value;
	        topicID = document.getElementById("txtSBTopicID").value;
	    }
	    else
	    {
	        topicID = 1;
	    }
	    document.getElementById("txtSBTopicID").value = topicID;

	    if ((document.getElementById("txtSBIndicatorID").value != null) && (document.getElementById("txtSBIndicatorID").value != ""))
	    {

                indicatorID = document.getElementById("txtSBIndicatorID").value;

	    
	    }
	    else
	    {
	            document.getElementById("txtSBIndicatorID").value = 1;
	    	    indicatorID = document.getElementById("txtSBIndicatorID").value;
	    }

	    getIndicatorsSB("/Custom/getIndicatorsDYOA.ashx?topicid="+topicID+"&noattrib=false&indicatorid=" +  indicatorID  + "&controlname=ddlSBIndicator", iHandlerSB);
  
        
       }
    
     function getIndicators(url, responseHandler)   
     {   
         //alert(url);
         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 getIndicatorsSB(url, responseHandler)   
     {   
         //alert(url);
         if (window.XMLHttpRequest)   
          {   
              // browser has native support for XMLHttpRequest object   
              reqSB = new XMLHttpRequest();   
          }   
          else if (window.ActiveXObject)   
          {   
             // try XMLHTTP ActiveX (Internet Explorer) version   
             reqSB = new ActiveXObject("Microsoft.XMLHTTP");   
          }   
             
          if(req)   
          {   
              reqSB.onreadystatechange = responseHandler;   
              reqSB.open('GET', url, true);   
              reqSB.setRequestHeader("content-type","application/x-www-form-urlencoded");   
              reqSB.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("divMCIndicator").innerHTML = req.responseText;                    
            }
        }  
    }
    
   
    
    function iHandlerSB()
    {
        if (reqSB.readyState == 4 || reqSB.readyState == 'complete')   
        { 
            //Exception handling for ashx page           
            if(reqSB.responseText == 'error')
            {
                window.location = '/home.aspx'; 
            }
            else
            {
              document.getElementById("divSBIndicator").innerHTML = reqSB.responseText;                    
            }
        }  
    }
    
    function ddlMCIndicator_refresh()
    {
        var selObj = document.getElementById("ddlMCIndicator");
        var selIndex = selObj.selectedIndex;
        
        document.getElementById("txtIndicatorID").value = selObj.options[selIndex].value ;
    }
    
    function ddlSBIndicator_refresh()
    {
        var selObj = document.getElementById("ddlSBIndicator");
        var selIndex = selObj.selectedIndex;
        
        document.getElementById("txtSBIndicatorID").value = selObj.options[selIndex].value ;
    }