//Måste använda POST pga kodningen emot Å,Ä,Ö
function Requester(url,params,action)
{
    this.url=url;
    //alert(this.url);
    this.params=params;
    //alert(this.params);
    this.action=action;
    this.requestobj=null;
    this.main();
}
Requester.prototype.main= function()
{
    this.request.call(this);
    if(this.requestobj!=null)
    {
        this.getdata.call(this);
    }
    else
    {
        this.exception.call(this,"Can not continue with request");
    }
}
Requester.prototype.request= function()
{
    try
    {
        //Funkar för Internet Explorer 7 och uppåt samt övriga browsers.
        if(window.XMLHttpRequest)
        {
            this.requestobj= new XMLHttpRequest();
        }
        //Funkar för Internet Explorer 5 - 6.
        else
        {
            this.requestobj= new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    catch(except)
    {
        this.exception.call(this,"Request Method"+except.description);
    }
}
Requester.prototype.getdata=function()
{
    try
    {
        var req=this;
        this.requestobj.onreadystatechange=function()
        {                                    
          if(req.requestobj.readyState==4)
            {
                if(req.requestobj.status==200)
                {
                    req.action.call(req);
                    delete req.requestobj;
                    req.requestobj=null;
                }
                else
                {
                    req.exception.call(req,"Getdata metod object status "+req.requestobj.status);
                }
            }
        }
        this.requestobj.open("POST",this.url);
        this.requestobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.requestobj.setRequestHeader("Content-length", this.params.length);
        this.requestobj.setRequestHeader("Connection", "close");
        this.requestobj.send(this.params);
    }
    catch(exception)
    {
        this.exception.call(this,"GetData Method "+exception.description);
    }
}
Requester.prototype.exception=function(descr)
{
    alert("Exception forming XMLHttpRequest "+descr);
}
