
function checkUrl(url) {
    invalidChrs = new Array(" ", "?", "&", "=", "!", "@", "#", "$", "^", "*", "\\", "/", "%");
    var result = url;
    for(var i=0; i<invalidChrs.length; i++) {
        if (result.indexOf(invalidChrs[i]) < 0) continue;
        result = result.replace(invalidChrs[i], "-");
    }
    return result;
}

function getRadioValue(radio) {
    for(i=0;i<radio.length;i++)
        if (radio[i].checked) return radio[i].value;
    return 0;
}

function setRadioValue(radio, value) {
    if (radio == null) return;
    for(var i=0;i<radio.length;i++)
        if (radio[i].value == value) {
            radio[i].checked = true;
            return;
        }
}

function clearSelect(sel) {
    while (sel.options.length > 0) sel.options.remove(0);
}

function addSelectOption(sel, value, title) {
    var opt = new Option();
    opt.value = value;
	opt.text = title;
    sel.options.add(opt);
}

function getSelectValue(sel) {
    return sel.options[sel.selectedIndex].value;
}

function setSelectValue(select, value) {
    for(var i=0;i<select.options.length;i++)
        if (select.options[i].value == value) {
            select.selectedIndex = i;
            return;
        }
}
function deleteSelectOption(sel, index) {
	sel.options.remove(index);
}