/*
this.CallBackObject = new CallBackObject();
var oThis = this;
this.CallBackObject.OnComplete = function(text, xml){ oThis.setContent(text);};
this.CallBackObject.OnAbort = function(){alert('Request has been aborted'); oThis.hidePopup();};
this.CallBackObject.OnError = function(status, statusText){alert('Error - ' + statusText);

var data;
data = {id : ‘valoare post data’ };
var url = 'http://region.birdview.com/assistant/leadmine/tree.php';
this.CallBackObject.DoCallBack(url, data);
*/

//--------------------------------------------------------------------

// CallbackObject

function CallBackObject()

{

  this.XmlHttp = this.GetHttpObject();

}



CallBackObject.prototype.GetHttpObject = function()

{

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}



CallBackObject.prototype.DoCallBack = function(url, postData)

{

  var theData = '';

  var theform = document.forms[0];

  var thePage = window.location.pathname + window.location.search;

  var eName = '';



  //theData  = '__EVENTTARGET=&';

  //theData += '__EVENTARGUMENT=&';

  //theData += '__VIEWSTATE=&';

  for( eName in postData )

  {
   
    if( eName && eName != '')

    {
        if( eName == 'hometypes[]') 
        {            
            for (var k = 0; k <  postData[eName].length; k++){           
               theData = theData + escape(eName.split("$").join(":")) + '=' + postData[eName][k] + '&';
            } 
        }
        else {
            theData = theData + escape(eName.split("$").join(":")) + '=' + postData[eName] + '&';
        }
    }  

  }
 


  if( this.XmlHttp )

  {

    if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )

    {

      var oThis = this;

      this.XmlHttp.open('POST', url, true);

      this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(); };

      this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

      this.XmlHttp.send(theData);

    }

  }

}



CallBackObject.prototype.AbortCallBack = function()

{

  if( this.XmlHttp )

    this.XmlHttp.abort();



   this.XmlHttp = null;

}



CallBackObject.prototype.OnLoading = function()

{

  // Loading

}



CallBackObject.prototype.OnLoaded = function()

{

  // Loaded

}



CallBackObject.prototype.OnInteractive = function()

{

  // Interactive

}



CallBackObject.prototype.OnComplete = function(responseText, responseXml)

{

  // Complete

}



CallBackObject.prototype.OnAbort = function()

{

  // Abort

}



CallBackObject.prototype.OnError = function(status, statusText)

{

  // Error

}



CallBackObject.prototype.ReadyStateChange = function()

{

  if( this.XmlHttp.readyState == 1 )

  {

    this.OnLoading();

  }

  else if( this.XmlHttp.readyState == 2 )

  {

    this.OnLoaded();

  }

  else if( this.XmlHttp.readyState == 3 )

  {

    this.OnInteractive();

  }

  else if( this.XmlHttp.readyState == 4 )

  {

    if( this.XmlHttp.status == 0 )

      this.OnAbort();

    else if( this.XmlHttp.status == 200 && this.XmlHttp.statusText == "OK" )

      this.OnComplete(this.XmlHttp.responseText, this.XmlHttp.responseXML);

    else

      this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText);

  }

}



// Callback Object End

//--------------------------------------------------------------------



function runInnerScripts(gridDiv) {
    var scripts = gridDiv.getElementsByTagName("script");
       
    for ( var iii = 0; iii < scripts.length; iii++) {
              
        if (!window.opera) {     
            if (scripts[iii].src!=null && scripts[iii].src != "") {            	  		
    		if(String(scripts[iii].src).indexOf(".js")!=-1){
    			continue;
    		}
                var o0 = document.createElement("script");                
                o0.src = scripts[iii].src;
                document.body.appendChild(o0);
            }
        }

        if ((scripts[iii].text != "") && (!window.opera)) { 
        if(String(scripts[iii].text).indexOf(".js")!=-1){
    			continue;
    		}
            try {            
                eval(scripts[iii].text);
            }
            catch (e) {
                continue;
            }
    
        }

        if (navigator.userAgent.indexOf("Safari") != -1) {
            if (scripts[iii].innerHTML != "") {
               
                try {
                    eval(scripts[iii].innerHTML);
                }
                catch (e) {
                    continue;
                }
            }
        }
    }
}
