
function printmail(name,domain,code)
{
    var mail = name +'@'+ domain +'.'+ code;            
    document.write('<a href=\"mailto:'+ mail +'\">'+ mail +'</a>');
}

function printmail2(name,domain,code,text)
{
    var mail = name +'@'+ domain +'.'+ code;            
    document.write('<a href=\"mailto:'+ mail +'\">'+ text +'</a>');
}

function fadeOut(id) {
    var box = $(id);
    var fx = box.effects({duration: 1000, transition: Fx.Transitions.Quart.easeOut});
    fx.start({
        }).chain(function() {
            this.start.delay(2000, this, {'opacity' : 0});
        }).chain(function() {
            this.start.delay(100, this, {'opacity' : 1});
            box.style.display="none";
    });
}

//window.addEvent('domready', function() {
//    
//});


/* LISTBOX 
***********************************/

function moveSelectItem(selectId, action) {

    var selectBox = $(selectId);
    var selectedItemPos = selectBox.selectedIndex;
    if (selectedItemPos < 0) return; //No selected option
    
    var optionList = [];
    for (var i = 0; i < selectBox.options.length; i++) {
        optionList.push(selectBox.options[i]);
    }
    
    if (action == 'top') { 
    
        selectBox.appendChild(optionList[selectedItemPos]);
        for (var j = 0; j < optionList.length; j++) {
            if (j != selectedItemPos) {
                selectBox.appendChild(optionList[j]);
            }
        }
        return;
        
    } else if (action == 'bottom') { 
    
        selectBox.appendChild(optionList[selectedItemPos]);
        for (var j = 0; j < optionList.length; j++) {
            if (j != selectedItemPos) {
                selectBox.appendChild(optionList[j]);
            }
        }
        selectBox.appendChild(optionList[selectedItemPos]);
        return;
        
    } else { 
    
        var newPos = selectedItemPos + action;
        if (selectBox.options[newPos]) { //Not reached end of list
    
            for (var j = 0; j < optionList.length; j++) {
            
                if (j == selectedItemPos) {
                    selectBox.appendChild(optionList[newPos]);
                } else if (j == newPos) {
                    selectBox.appendChild(optionList[selectedItemPos]);
                } else { 
                    selectBox.appendChild(optionList[j]);
                }
                
            }
            
        }
        
    }
    
}

function deleteSelectedItem(selectId) {

    //var selectBox = $(selectId); Makes entire selectbox dissapear [weird!].
    var selectBox = document.getElementById(selectId);
    var selectedItemPos = selectBox.selectedIndex;
    selectBox.remove(selectedItemPos);
    
    if (selectedItemPos >= selectBox.options.length) {
        selectBox.selectedIndex = selectBox.options.length - 1;
    } else {
        selectBox.selectedIndex = selectedItemPos;
    }

}

function insertSelectItem(selectId, name, value) {

    var selectBox = $(selectId);
    var selectedItemPos = selectBox.selectedIndex;
  
    var opt = document.createElement('option');
    opt.text = name;
    opt.value = value;

    if (selectedItemPos >= 0) {
        var optOld = selectBox.options[selectedItemPos];  
        try {
            selectBox.add(opt, optOld); // standards compliant; doesn't work in IE
        } catch(ex) {
            selectBox.add(opt, selectedItemPos); // IE only
        }
    } else {
        selectBox.add(opt);
        selectedItemPos = selectBox.options.length - 1;
    }
  
    selectBox.selectedIndex = selectedItemPos;
    
}


