

    //Fills the given element with the httpObject's response text as innerHTML.
	function FillWithResponse(element, httpObject)
	{
	  if (httpObject.readyState == 4 && element)
	  {
	    element.innerHTML = httpObject.responseText;
	  }
	}

	function RemoveArrayEntry(arr, idx)
	{
	  var result = new Array();
	  for (var _idx = 0; _idx < selectedDS.length; ++_idx)
	  {
	    if (idx != _idx)
	      result.push(arr[_idx]);
	  }
	  return result;
	}

	function GetHTTPObject()
	{
		var httpObject;
		/*@cc_on
		@if (@_jscript_version >= 5)
			try
			{
				httpObject = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					httpObject = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e2)
				{
					httpObject = false;
				}
			}
		@else
		httpObject = false;
		@end @*/
		if (!httpObject && typeof XMLHttpRequest != 'undefined')
		{
		  try
		  {
		    httpObject = new XMLHttpRequest();
		  }
		  catch (e)
		  {
		    httpObject = false;
		  }
		}
		return httpObject;
	}

    function IsPositiveInt(val)
    {
      var hasPositiveNumber = false;
      for (i = 0; i < val.length; ++i)
      {
        var ch = val.charAt(i);
		if (ch <"0" || ch  > "9")
		  return false;
		else
		  if (ch != "0")
		    hasPositiveNumber = true;
	  }
	  return hasPositiveNumber;
    }

	function $(id)
	{
	  return document.getElementById(id);
	}

    function SetValue(formElement, value)
    {
         options = formElement.options;
         if (options)
         {
           for (i = 0; i < options.length; ++i)
             if (options[i].value == value)
               options[i].selected = true;
         }
         formElement.value = value;
    }

    function GetValue(formElement)
    {
        options = formElement.options;
        if (options)
          return options[options.selectedIndex].value;

        return formElement.value;
    }

    function ClearOptions(options)
    {
      while(options.length > 0)
      {
        options[options.length - 1] = null;
      }
    }

    function SetOpacity(element, value)
    {
	  element.style.opacity = value;
	  ieVal =Math.round(value * 100, 0);
	  element.style.filter = 'alpha(opacity=' + ieVal + ')';
	}

    function IndexOf(arr, value)
    {
      for (var idx = 0; idx < arr.length; ++idx)
      {
        if (arr[idx] == value)
          return idx;
      }
      return -1;
    }

	function KeyCode(evt)
	{
	  if (!evt)
	  {
	    return event.keyCode;
	  }
	  else
	  {
	    return evt.keyCode;
	  }
	}

    function UrlEncode(str)
    {
      return escape(str)
       .replace(/\+/g, '%2B')
          .replace(/\"/g,'%22')
             .replace(/\'/g, '%27');
    }

    function Fader(name, element)
    {

      this.name = name;
      this.element = element;
    }

    Fader.prototype.FadeIn = function(duration)
    {
      SetOpacity(this.element, 0);
      this.element.style.display = "block";
      this.duration = duration;
      var dt = new Date;
      this.start = dt.getTime();
      this.FadeInStep(this.name);
    }


  Fader.prototype.FadeInStep = function (name)
  {
    var dt = new Date();
    var time = dt.getTime();
    var internal_fader = eval(name);
    if (time -  internal_fader.start >= internal_fader.duration)
      SetOpacity(internal_fader.element, 1.0);
    else
    {
      opacity = (time - internal_fader.start) / internal_fader.duration;
      SetOpacity(internal_fader.element, opacity);
      setTimeout(name + ".FadeInStep('" + name + "')", 10);
    }
}

 Fader.prototype.FadeOut = function(duration)
    {
      SetOpacity(this.element, 1.0);
      this.duration = duration;
      var dt = new Date;
      this.start = dt.getTime();
      this.FadeOutStep(this.name);
    }


  Fader.prototype.FadeOutStep = function (name)
  {
    var dt = new Date();
    var time = dt.getTime();
    var internal_fader = eval(name);
    if (time -  internal_fader.start >= internal_fader.duration)
    {
      SetOpacity(internal_fader.element, 0.0);
      internal_fader.element.style.display = "none";
    }
    else
    {
      opacity = (time - internal_fader.start) / internal_fader.duration;
      opacity = 1.0 - opacity;
      SetOpacity(internal_fader.element, opacity);
      setTimeout(name + ".FadeOutStep('" + name + "')", 10);
    }
}

