function GetXmlHttpObject()
{
    try
    {
        // Opera 8.0+, Firefox, Safari
        return new XMLHttpRequest();

    }
    catch (e)
    {
        // Internet Explorer Browsers
        try
        {
            return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                return new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                return null;
            }
        }
    }

    return null;
}




//function ajax_response()
//{
//    var xmlhttp = ajax_EventEmails_stateChanged.xmlhttp;
//
//    if (xmlhttp.readyState>0 && xmlhttp.readyState<4)
//    {
//        onBegin();
//    }
//    if (xmlhttp.readyState==4)
//    {
//        try
//        {
//            if (xmlhttp.responseXML == null)
//            {
//                throw new Error("Data read error");
//            }
//
//            var xmlDoc=xmlhttp.responseXML.documentElement;
//            var state = xmlDoc.getElementsByTagName("status")[0].getAttribute("state");
//            var message = getValueFromNode(xmlDoc, "status");
//
//            if (state != 'ok') throw new Error("Data error:\n" + message);
//
//            alert(message);
//
//        }
//        catch (e)
//        {
//            if (e.message != 'ok') alert(e.message);
//        }
//        finally
//        {
//            document.getElementById('busylayer').style.visibility = 'hidden';
//            return false;
//        }
//    }
//
//    function onBegin()
//    {
//
//    }
//
//    function onEnd()
//    {
//
//    }
//
//}



function getValueFromNode(xmlDoc, nodename)
{
    try
    {
        if (xmlDoc.getElementsByTagName(nodename)[0].childNodes.length==0) return '';
        else return getLongNode(xmlDoc.getElementsByTagName(nodename)[0]); //.childNodes[0].nodeValue;
    }
    catch(e)
    {
        return '';
    }
}

function getLongNode(node)
{
    if (node=='') return '';
    if (typeof(node).textContent != 'undefined') return node.textContent;
    else return node.firstChild.nodeValue;
}



function getSelectedRadio(container, name)
{
    radios_arr = document.getElementsByName(name);

    for (i=0; i<radios_arr.length; i++)
    {
        if (radios_arr[i].checked) return radios_arr[i].value
    }

    return -1;
}