﻿// JScript File
function getOptionText(drpElemId)
{
    var optionValue = null;        
    if(drpElemId != null)
    {
        var drpElem = document.getElementById(drpElemId);
        if(drpElem != null)
        {
        
        try{
        
        //Check to see if the DropDownLilst has any items
	       if (drpElem.options.length > 0)
	       {
	        var selectedIndex =  drpElem.selectedIndex;
            if(drpElem != null && selectedIndex != null)
            {
                var option = drpElem.options[selectedIndex];
                if(option != null)
                {
                    optionValue = option.text;
                }
            }
          }
          }catch(e){}
        }
    }    
    return optionValue;        
}   

function cmb_onMouseOut(labelComboDivId, comboDivId, textElemId, comboElemId)
{        
    toggleLabelComboDivVisibility(labelComboDivId, comboDivId, true, textElemId, comboElemId); 
          
}   

        function onComboChange(textElemId, comboElemId)
        {        
            try
            {
                var selectedText = getOptionText(comboElemId);
                var textElem = document.getElementById(textElemId);        
                if(textElem != null)
                {            
                    textElem.innerHTML = selectedText;
                    //textElem.value = selectedText;
                }
            }catch(e){}
                
        }


function RefreshDropdownControl(drpElemId)
{
    if(drpElemId != null)
    {
        var drpElem = document.getElementById(drpElemId);
        if(drpElem  != null)
        {
            var textElemId = drpElem.getAttribute("TEXTBOX_ID");
            onComboChange(textElemId, drpElemId);
        }
    }    
}
function ShowCoboHideLabel(lebel_id,cmb_id)
{   
       if(cmb_id !=null)
       {
         ToggleLayer(cmb_id,null,null);
       }
       if(lebel_id !=null)
       {
         ToggleLayer(lebel_id,null,null);
        }
    return;
}

    //-------------------------
    function ToggleLayer(elmId){
    try{
        if(document.getElementById(elmId).style.display==" " ||  document.getElementById(elmId).style.display=="block"  )
          {
            document.getElementById(elmId).style.display='none';
          }
        else
         {
           document.getElementById(elmId).style.display='block';
         }	
     }catch(e)
{
    
}
    return;
    }

function HideCoboShowLabel(lebel_id,cmb_id)
{
    try{
   
    if(cmb_id !=null)
        document.getElementById(cmb_id).style.display='none';
    
    if(lebel_id !=null)
        document.getElementById(lebel_id).style.display='block';
 
    }catch(e){}   
  
    return;
}

function HideDropdownControl(cmbElem)
{    
    if(cmbElem != null)
    {     
        var lblCmbId = cmbElem.getAttribute("LABEL_COMBO_ID"); 
        if(lblCmbId != null)
        {
            document.getElementById(lblCmbId).style.display='none';            
        }
        else
        {
            cmbElem.style.visibility='hidden';
            cmbElem.style.display='none';            
        }
    }
}

function ShowDropdownControl(cmbElem)
{        
    if(cmbElem != null)
    {        
        var lblCmbId = cmbElem.getAttribute("LABEL_COMBO_ID");             
        if(lblCmbId != null)
        {
            document.getElementById(lblCmbId).style.display='block';            
        }
        else
        {   
            cmbElem.style.visibility = 'visible';
            cmbElem.style.display='block';
        }
    }
}