
function _dialog(url, width, height, arguments) {
    var r = '_r=' + Math.round(Math.random() * 10000);
    if (url.indexOf('?') == -1) url += '?' + r; else url += '&' + r;
    var features = "dialogWidth: " + width + "px; dialogHeight: " + height + "px; center: yes; resizable: no; scroll: no; status: no;"
    return window.showModalDialog(url, arguments, features);
}

function _open(url, width, height, target) {
    var r = '_r=' + Math.round(Math.random() * 10000);
    if (url.indexOf('?') == -1) url += '?' + r; else url += '&' + r;
    var features = 'width=' + width + 'px, height=' + height + 'px, resizable=no, status=yes, scrollbars=no, location=no';
    window.open(url, target, features);
    return window.document['returnValue'];
}

/**********************************************/

function _opera() {
    return (window.opera != undefined);
}

function _ie6() {
    return (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE") + 4, 4)) < 7);
}

function _ie7() {
    return (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE") + 4, 4)) >= 7);
}

function _ie() {
    return (_ie6() || _ie7());
}

function _firefox() {
    return ((document.selection == undefined) && (window.opera == undefined));
}

/**********************************************/

function goto(url) {
    top.location.href = url;
}

function A_openInNewWindow(obj, width, height) {
    var url = obj.href;
    var target = "_blank";
    var _width = width || 500;
    var _height = height || 400;
    var features = "width=" + _width + "px, height=" + _height + "px, resizable=yes, scrollbars=yes, status=yes";
    var _window = window.open(url, target, features);
    if (window.event != undefined)
        window.event.returnValue = false;
    return false;
}

function checkSelected(name) {
    var a = document.getElementsByName(name);
    var flag = false; 
    for (var j = 0; j < a.length; j ++)
        flag |= a[j].checked;
    return flag;
}

function verify(name, message) {
    var flag;
    flag = checkSelected(name);
    if (!flag) alert(message);
    if (window.event) window.event.returnValue = flag;
    return flag;
}

function _confirm(message) {
    var flag = window.confirm(message);
    if (window.event) window.event.returnValue = flag;
    return flag;
}

function getSelectedValue(id, _default) {
    if (_default == undefined) _default = '';
    var obj; 
    if (typeof(id) == 'string') obj = document.getElementById(id); else obj = id;
    var index = obj.selectedIndex; 
    if (index == -1) {
        return _default;
    }else{
        return obj.options.item(index).value;
    }
}

