﻿function AjaxConnection()
{
   this.setOptions=setOptions;
   this.getOptions=getOptions;
   this.connect=connect;
   this.uri="ajax_service.php";
}
function setOptions(opt)
{
   for(i=0;i<opt.length;i++)
   {
      this.options += "&"+opt[i];
   }
}
function getOptions()
{
   return this.options;
}

function connect(return_func, status_func)
        {
            with(this)
            {
                x=init_object();
                x.open("POST", uri,true);
                x.onreadystatechange = function() {
                        try
                        {                        
                        if (x.readyState != 4)
                        {
                            //eval(status_func+'('+x.readyState+', '+x.status+')');
                            return;
                        }
                        }
                        catch(err)
                        {
                        return;
                        }
                            eval(return_func + '(x.responseText)');
                            delete x;
                }
                x.setRequestHeader('Content-Type',
                    'application/x-www-form-urlencoded');
                x.send(getOptions());
            }
        }

function init_object() {
        var x;
        try {
                x=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                        x=new ActiveXObject("Microsoft.XMLHTTP");
                } catch (oc) {
                        x=null;
                }
        }
        if(!x && typeof XMLHttpRequest != "undefined")
                x = new XMLHttpRequest();
        if (x)
                return x;
}

function updatecheck(partialname, index)
{
    if (document.getElementById(partialname+"check_"+index).checked)
    {
        document.getElementById(partialname+"row_"+index).style.backgroundColor = "#ffffaf";
    }
    else
    {
        document.getElementById(partialname+"row_"+index).style.backgroundColor = "#dddddd";
    }
}