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(eventTarget, eventArgument)
{ 
  try {updateHiddenFields();} catch(e) {}
  var theData = 'IsCallBack=true&';
  var theform = document.forms[0];
  var thePage = window.location.pathname;
  var eName = '';
  //if (thePage.indexOf('.aspx', 0) > 0)
		thePage = thePage + window.location.search;
  //else
		//thePage = thePage + 'default.aspx' + window.location.search;
  var eTarget;
  try{
     var elem = document.getElementById(eventTarget.split("$").join("_"));
     if (elem.type=="image"){
         theData = escape(elem.name.split("$").join(":")) + '.X=' + window.event.offsetX + '&' + escape(elem.name.split("$").join(":")) + '.Y=' + window.event.offsetY + '&';
     }
  }catch(e){}
  eventTarget = eventTarget.split("_").join(":");
  theData += '__EVENTTARGET='  + escape(eventTarget.split("$").join(":")) + '&';
  theData += '__EVENTARGUMENT=' + eventArgument + '&';
  theData += '__VIEWSTATE='    + escape(theform.__VIEWSTATE.value).replace(new RegExp('\\+', 'g'), '%2b') + '&';
  if (theform.__EVENTVALIDATION){theData += '__EVENTVALIDATION='    + escape(theform.__EVENTVALIDATION.value).replace(new RegExp('\\+', 'g'), '%2b') + '&';}
   //debugger;
  for( var i=0; i<theform.elements.length; i++ )
  {
    eName = theform.elements[i].name;
    if( eName && eName != '')
    {
      if( eName == '__EVENTTARGET' || eName == '__EVENTARGUMENT' || eName == '__VIEWSTATE' || eName == '__EVENTVALIDATION' || eName == '__dnnVariable')
      {
        // Do Nothing
      }
      else
      { var emptyDDlist = (theform.elements[i].type=="select-one" && theform.elements[i].value=='')
        if( (theform.elements[i].type!="checkbox" && theform.elements[i].type!="radio" && theform.elements[i].type!="submit" && theform.elements[i].type!="button" && !emptyDDlist) || (theform.elements[i].checked && !theform.elements[i].disabled))
         { 
			try{
				theData = theData + escape(eName) + '=' + theform.elements[i].value.replace(new RegExp('\\+', 'g'), '%2b');
				if( i != theform.elements.length - 1 ) {theData = theData + '&';}
				}catch(e){}
           
        }
      }
    }
  }
  if( this.XmlHttp )
  {
    if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
    {
      var oThis = this;
      this.XmlHttp.open('POST', thePage, true);
      this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(); }
      this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  if (typeof showCBdata!='undefined'){if (showCBdata){alert(theData);}}
      this.XmlHttp.send(theData);
    }
  }
}

CallBackObject.prototype.AbortCallBack = function()
{
  if( this.XmlHttp )
    this.XmlHttp.abort();
}

CallBackObject.prototype.OnLoading = function()
{
    // Loading
    //Insert "loadingImg" DIV
    var loadImg=document.getElementById('loadingImg')
    if (loadImg==null){
    loadImg = document.createElement('div');
    loadImg.id='loadingImg';
//    loadImg.style.position='absolute';
//    loadImg.setAttribute((document.all ? 'className' : 'class'), "loadingbox");
    document.body.appendChild(loadImg);
    } 
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
    var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
    var dsoctop=document.all? iebody.scrollTop : pageYOffset;
    var top = dsoctop+(getWindowHeight()*.4);
    var left = dsocleft+(getWindowWidth()*.4);
    loadImg.innerHTML = "<div class='loadingbox' className='loadingbox' style='top:"+top+"px;left:"+left+"px;'><img src='"+loadingImg+"'> Processing...</div>";
}

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, responseText)
{
  // 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);
  }
}

//***************End Callback Script*************************
function getWindowHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
   myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function getWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

//__doPostBack('initialize','');
//__DoCallBack('initialize','');

