//
// +---------------------------------------------------------------------------+
// | Matchcrew                                                                 |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | May 2010 - creation                                                     |
// |                                                                           |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2010 Matchcrew, Inc.                                        |
// | All rights reserved.                                                      |
// +---------------------------------------------------------------------------+
//

function AjaxConnection() 
{
   this.setOptions=setOptions;
   this.getOptions=getOptions;
   this.connect=connect;
   this.uri="ajax_service.php";
   this.x = false;
} 

function setOptions(opt)
{
   for(i=0;i<opt.length;i++)  
   {
      this.options += "&"+opt[i];
   }
}

function getOptions()
{
   return this.options;
}

function connect(return_func)
{
    with(this)
    {
         x=init_object();
         this.x = x;
         x.open("POST", uri,true);
         x.onreadystatechange = function() {
                 if (x.readyState != 4)
                      return;
                      eval(return_func + '(x.responseText,x)');
                      delete x;
                }
         x.setRequestHeader('Content-Type' , "text/html");
         x.send(null);
     }
}

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.overrideMimeType) {
		   x.overrideMimeType('text/xml');
		}
	}
        if (x)
                return x;
}

