function request(url, method, qs, callback, data)
{
    var req = null;
    var ready = false;

    try {
        if(window.XMLHttpRequest) {
            req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 4,5,5.5,6
        }
    } catch(e) {
        return false;
    }

    ready = false;
    method = method.toUpperCase();

    try {
        req.onreadystatechange = function() {
            if(req.readyState == 4 && !ready) {
                ready = true;

                if(callback != null) {
                  callback(req, data);
                }
            }
            else {
              return false;
            }
        }

        if((method=="GET") || (method=="HEAD"))
        {
            req.open(method, url+qs, true);
            req.send(null);
        }
        else if(method=="POST")
        {
            req.open(method, url, true);
             req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
             req.send(qs);
        }
    }

    catch(e) {
        return false;
    }

    return true;
}

function showLoadingIcon()
{
	var ld = document.createElement('img');
	ld.style.position = 'fixed';
	ld.style.top = '10px';
	ld.style.right = '10px';
	ld.src = '/img/ajax-loader.gif';
	ld.id = 'ajax-loading-icon';
	document.body.appendChild(ld);
}

function hideLoadingIcon()
{
	var ld = document.getElementById('ajax-loading-icon');
	document.body.removeChild(ld);
}

function ajaxLinkCallBack(req, callback)
{
	hideLoadingIcon();
	callback(req);
}
