
var _cboRegionRightUC;
var _cboCommunityRightUC;


function initializeFormRightUC()
{
    _cboRegionRightUC = $get("ctl00_ddd_cboRegionUC");
    _cboCommunityRightUC = $get("ctl00_ddd_ddlCommunityUC"); 
    if(_cboRegionRightUC != null)
    {
        _cboRegionRightUC.onchange = function(){getCommunitiesRightUC(this);};
    }    
}
//*****************************************************************************************************
function getCommunitiesRightUC(object)
{
    makeCommunityEmptyRightUC();
    var regionId = object.options[object.selectedIndex].value;
    var curTime = new Date();    
     if(regionId != -1)
    {
        Readers.getDistrictAndCommunityByRegionIdRightUC(regionId, curTime.toString(), onSuccessCommunityInfoRightUC, onFailureCommunityInfoRightUC, curTime.toString())        
    }
}
function onSuccessCommunityInfoRightUC(result, context, method)
{
    var CommunityInfo = result;
    var objCommunity= _cboCommunityRightUC;
    var CommunityIndex = 0;      
    if(CommunityInfo != null)
    {
        if(CommunityInfo.length > 0)
        { 
             var optnCommunity;// = document.createElement("OPTION");
//             optnCommunity.text = "Please Select";
//             optnCommunity.value = "-1";
//             objCommunity.options.add(optnCommunity);
                     
            for(CommunityIndex = 0; CommunityIndex < CommunityInfo.length; CommunityIndex++)
            {                     
                optnCommunity = document.createElement("OPTION");
                optnCommunity.text = CommunityInfo[CommunityIndex].CommunityName;
                optnCommunity.value =  CommunityInfo[CommunityIndex].CommunityId;
                objCommunity.options.add(optnCommunity);
            }
        }
    }
}

function onFailureCommunityInfoRightUC(result, context, method)
{
   makeCommunityEmptyRightUC();
}
function makeCommunityEmptyRightUC()
{
   var objSlcCommunity = _cboCommunityRightUC;
    
    var i;
    for (i = objSlcCommunity.length - 1; i>0; i--)
    {
       objSlcCommunity.remove(i);
    }
    for (i = objSlcCommunity.length - 1; i>0; i--)
    {
       objSlcCommunity.remove(i);
    }
}
//*****************************************************
