// http://www.dustindiaz.com/getelementsbyclass/
function getElementsByClass(searchClass,node,tag) 
{
	var classElements = new Array();
	if ( node == null )
    {
		node = document;
    }
	if ( tag == null )
    {
		tag = '*';
    }
	
    var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	
    for (i = 0, j = 0; i < elsLen; i++) 
    {
		if ( pattern.test(els[i].className) ) 
        {
            classElements[j] = els[i];
            j++;
		}
	}
	return classElements;
}

/*
<div class="bm_sel bm_sel_off" id="bm_sel_telepay"></div> 
<div class="bm_sel bm_sel_off" id="bm_sel_ebill"></div>

class_group = bm_sel
str_id_sel_on = bm_sel_ebill
class_sel_on = bm_sel_on_ebill
class_sel_off = bm_sel_off
*/
function set_sel_class(class_group, str_id_sel_on, class_sel_on, class_sel_off)
{    
    var arr_id_sel_on = str_id_sel_on.split(", ");
    
    // ! Div only to speed up search
    // var arr_element = getElementsByClass(class_group, document, 'div');
    var arr_element = getElementsByClass(class_group, document);

    for (i = 0; i < arr_element.length; i++)
    {
        var element = arr_element[i];
        element.className = class_sel_off;    

        for (cur_id_sel_on= 0 ; cur_id_sel_on < arr_id_sel_on.length ; cur_id_sel_on++ )
        {    
            if (element.id == arr_id_sel_on[cur_id_sel_on])
            {                
                element.className = class_sel_on;
            }
        }        
    }
}

function set_sel_display(class_group, str_id_display)
{    
    var arr_id_display = str_id_display.split(", ");
    
    // ! Div only to speed up search
    // var arr_element = getElementsByClass(class_group, document, 'div');
    var arr_element = getElementsByClass(class_group, document);

    for (i=0; i < arr_element.length; i++)
    {
        var element = arr_element[i];
        element.style.display = 'none';    

        for (cur_id_display = 0; cur_id_display < arr_id_display.length ; cur_id_display++ )
        {    
            if (element.id == arr_id_display[cur_id_display])
            {                
                element.style.display = 'block';
            }
        }        
    }
}