function getNext(elem){ 
  pos=elem.nextSibling;    
  while(pos.nodeType != 1)/* Element have a node Type which value is 1 */
    pos=pos.nextSibling;
  return pos;
}

function getFirst(elem) {
    //if (elem) alert(elem.innerHTML);
  pos=elem.firstChild;    
  while(pos.nodeType != 1)/* Element have a node Type which value is 1 */
    pos=pos.nextSibling;
  return pos;
}

function listen(evnt, elem, func, iebug){
  for(i=0;i<elem.length;i++)
    if (elem[i].addEventListener) // W3C DOM
      elem[i].addEventListener(evnt,func,false);
    else
      if (elem[i].attachEvent) // IE DOM
        if(!iebug)
          elem[i].attachEvent("on"+evnt, func)
        else
          eval("elem[i].on"+evnt+"="+func);
};

function $(){
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    
    if (typeof element == 'string')
      element = document.getElementById(element);
    
    if (arguments.length == 1)
      return element;
    
    elements.push(element);
  }
  return elements;
};

function makeAnons(num){
  for(var i = 1;i<=2;i++)
    if(i == num)
      $('anons-'+i).style.display = ''
    else
      $('anons-'+i).style.display = 'none'
}

function rightMenu(){
  var parent = getFirst($('anons'));
  var elem1 = getFirst(parent);
  var elem1_a = getFirst(elem1);
  var elem2 = getNext(elem1);
  var elem2_a = getFirst(elem2);
  
  listen('click', [elem1_a], function(){ 
    parent.className = 'right-activ-1';
    elem1_a.blur();
    makeAnons(1);
  });
  
  listen('click', [elem2_a], function(){ 
    parent.className = 'right-activ-2';
    elem2_a.blur();
    makeAnons(2);
  });
}

var mnuTime = setInterval(function() {
    if ($('anons') && typeof document.getElementsByTagName != 'undefined' && typeof document.getElementById != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
        rightMenu();
        setTimeout(function() {
            $('anons-2').style.position = 'static';
            if (String(window.location).indexOf('showplaylist') != -1) {
                getFirst($('anons')).className = 'right-activ-2';
                makeAnons(2);
            }
            else {
                makeAnons(String(getFirst($('anons')).className).match(/\d/));
            }
        }, 1000);
        clearInterval(mnuTime);
    }
}, 100);