﻿function AjaxCallback(postData, callbackFunction) 
{
  //alert(postData);
  var xml;
  var separator = "?";

  if (location.href.indexOf("?") > -1)
    separator = "&";

  var url = location.href + separator + "__AjaxCallback=" + encodeURIComponent('AjaxCallback');

  if (postData == null)
    postData = "";

  var ie = (window.navigator.appName.toLowerCase().indexOf('explorer') != -1);

  if (ie)
    xml = new ActiveXObject("Microsoft.XMLHTTP")
  else
    xml = new XMLHttpRequest();

  if (callbackFunction != null) 
  {
    xml.onreadystatechange = function()
    {
      if (xml.readyState == 4)
      {
        var result = xml.responseText;
        
        callbackFunction(result);
      }
    }
  }
  try 
  {
    xml.open("POST", url, callbackFunction != null);
  }
  catch (e) 
  {
    alert(e);
  }

  xml.send(postData);

  if (callbackFunction == null)
  {
    return xml.responseText;
  }
}

function GetWidth()
{
  var x = 0;
  if (self.innerHeight)
  {
    x = self.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
    x = document.documentElement.clientWidth;
  }
  else if (document.body)
  {
    x = document.body.clientWidth;
  }
  return x;
}

function GetHeight()
{
  var y = 0;
  if (self.innerHeight)
  {
    y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
    y = document.documentElement.clientHeight;
  }
  else if (document.body)
  {
    y = document.body.clientHeight;
  }
  return y;
}

function GetWindowHeight()
{
  var myHeight = 0;
  if (typeof (window.innerWidth) == 'number')
  {
    myHeight = window.innerHeight;
  }
  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  }
  else if (document.body && (document.body.clientWidth || document.body.clientHeight))
  {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}

function GetScrollTop()
{
  return (document.all) ? document.documentElement.scrollTop : window.pageYOffset;
}

function GetScrollLeft()
{
  return (document.all) ? document.documentElement.scrollLeft : window.pageXOffset;
}

function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;

  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}