var current_index = 0;
var current_sub_index = "";
var max_current_index = 6;

function change_main(index)
{
    if( current_sub_index == "" || (current_sub_index != "" && current_sub_index.substr(0,1) != index) )
    {       
        var elems = xGetElementsByClassName('main-desc');
        
        for( var prop in elems )
        {
            elems[prop].style.display = 'none';
        }

        xGetElementById('main-'+index).style.display = 'block';
        
        current_index = index;
        
        current_sub_index = "";
        
        highlight_bottom(index,true);
    }
}

function highlight_bottom(index,always_highlight)
{
    if( always_highlight == true || current_index != index )
    {
        for( i=0; i<max_current_index; i++ )
        {
            filter = 1;
            obj = xGetElementById("main-bottom-"+i).style;
            obj.opacity = filter;
            obj.MzOpacity = filter;
            obj.KhtmlOpacity = filter;
            obj.filter = "alpha(opacity="+filter*100+")";
        }
        
        filter = 0.7;
        obj = xGetElementById('main-bottom-'+current_index).style;
        obj.opacity = filter;
        obj.MzOpacity = filter;
        obj.KhtmlOpacity = filter;
        obj.filter = "alpha(opacity="+filter*100+")";
    }
}

function change_sub_main(index)
{
    var elems = xGetElementsByClassName('main-desc');
    
    for( var prop in elems )
    {
        elems[prop].style.display = 'none';
    }

    xGetElementById('main-'+index).style.display = 'block';
    
    current_index = index.substr(0,1);
    
    current_sub_index = index;
    
    highlight_bottom(index,false);
}

function view_more(index)
{
    current_index = parseInt(current_index)+parseInt(index);
    
    if( current_index < 0 )
    {
        current_index = 5;
    }
    if( current_index > 5 )
    {
        current_index = 0;
    }

    var elems = xGetElementsByClassName('main-desc');
    
    for( var prop in elems )
    {
        elems[prop].style.display = 'none';
    }
       
    xGetElementById('main-'+current_index).style.display = 'block';
    
    highlight_bottom(index,true);
}
