function switchOptions(el,name){
  if(el.getAttribute('id')=='switch_button'){    
    options = el.parentNode.parentNode.nextSibling;    
  } else {
    options = el.parentNode.nextSibling;    
  }  

  if(options.style.display=='none' || options.style.display==''){
    options.style.display = 'block';
  }else{
    options.style.display = 'none';
  } 
}

function selectOption(el,name,nr,functionname,formname,fixvalues){
  options = el.parentNode;
  bar = el.parentNode.previousSibling;

  if(bar.id=='customselect_bar_' + name){
    showbar = bar.childNodes[0];
    bar.style.border = '1px solid #00ff00';
    showbar.innerHTML = el.innerHTML;
  }
  
  var value = document['customselect_'+name]['option'+nr].value;
  window[functionname](value,formname,fixvalues);
  
}

function selectOptionsMouseoutHandler(optionsEl,event){
  if(typeof(optionsEl)!='undefined' && typeof(optionsEl.style)!='undefined' && optionsEl.style.display != 'none'){
  
    var toElement = null;
    
    if (event.relatedTarget) toElement = event.relatedTarget;
      else if (event.toElement) toElement = event.toElement;

    while (toElement && toElement.tagName != "DIV"){
      toElement = toElement.parentNode;
    }

    if(toElement){
      if (toElement.id!=optionsEl.id){
        optionsEl.style.display = 'none';
      }
    }else{
      optionsEl.style.display = 'none';
    }
  }
}

function csAttachMenu(menu, header, align) {
  var $ = document.id; // A.K.A. mootools
  var body = document.getElementsByTagName('body')[0];
  
  body.appendChild(menu); 

  menu.style.display = 'block';
	
  align = align || 'left';
  $(menu).position({
    relativeTo: $(header),
    position: {x: align, y: 'bottom'},
    edge: {x: align, y: 'top'}
  });
}
