Array.prototype.remove=function(dx)
{
  if(isNaN(dx)||dx>this.length){return false;}
  var n = 0;
  for(i=0;i<this.length;i++)
  {
    if(this[i]!=this[dx])
      this[n++]=this[i];
  }
  this.length-=1;
};

Array.prototype.add=function(objToAdd)
{
  this[this.length] = objToAdd;
};

function LTrim(s)
{
  var i=0;
  var j=0;

  for(i=0; i<=s.length-1; i++)
  {
    if((s.substring(i,i+1) != ' ') && (s.charCodeAt(i) != 160))
    {
      j=i;
      break;
    }
  }
  return s.substring(j, s.length);
}

function RTrim(s)
{
  var j=0;

  for(var i=s.length-1; i>-1; i--)
    if(s.substring(i,i+1) != ' '){
      j=i;
      break;
    }
  return s.substring(0, j+1);
}

function Trim(s)
{
  return LTrim(RTrim(s));
}

function UrlEncode(strTextIn)
{
  var plaintext = strTextIn + '';

  // The Javascript escape and unescape functions do not correspond
  // with what browsers actually do...
  var SAFECHARS = "0123456789" +          // Numeric
          "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +  // Alphabetci
          "abcdefghijklmnopqrstuvwxyz" +
          "-_.!~*'()";          // RFC2396 Mark characters
  var HEX = "0123456789ABCDEF";

  var encoded = "";
  for (var i = 0; i < plaintext.length; i++ ) {
    var ch = plaintext.charAt(i);
      if (ch == " ") {
        encoded += "+";        // x-www-urlencoded, rather than %20
    } else if (SAFECHARS.indexOf(ch) != -1) {
        encoded += ch;
    } else {
        var charCode = ch.charCodeAt(0);
      if (charCode > 255) {
        encoded += "+";
      } else {
        encoded += "%";
        encoded += HEX.charAt((charCode >> 4) & 0xF);
        encoded += HEX.charAt(charCode & 0xF);
      }
    }
  } // for

  return encoded;
}

function UrlDecode(strTextIn)
{
  // Replace + with ' '
  // Replace %xx with equivalent character
  var encoded = strTextIn + '';
  var plaintext = "";
  var i = 0;
  while (i < (encoded.length-2)) {
      var ch = encoded.charAt(i);
    if (ch == "+") {
        plaintext += " ";
      i++;
    } else if (ch == "%" && encoded.charAt(i+1) != "%") {
        plaintext += unescape( encoded.substr(i,3) );
      i += 3;
   } else {
      plaintext += ch;
      i++;
   }
  } // while
  if (i < encoded.length) {
     plaintext += encoded.substr(i,encoded.length-i);
  }
  return unescape(plaintext);
}

function isTrue(val)
{
	if((val == true) || (val == 1) || (val == "true"))
		return true;
	return false;
}

function getNoCacheUrlParam()
{
	var x = (Math.random() + '');
	return x.substr(2, 6);
}

function isdefined(param)
{
	return (param + '' != 'undefined');
}

function format00(was)
{
	if(isNaN(was))
		return "";

	was = String(was);
	if(was.length == 1)
	{
		was = "0" + was;
	}
	return was;
}

function InspectObject(obj)
{
	var msg = "";
	for (var prop in obj)
		msg += "obj." + prop + " = " + obj[prop] + "\r\n"

  OpenDebugWindow();
  msg = msg.replace(/</g,"&lt;");
  msg = msg.replace(/>/g,"&gt;");
  hndlDebug.document.body.innerHTML += ("<hr><pre>" + msg + "<br>");
}
function OutputDebugString(sLine)
{
	OpenDebugWindow();
  sLine = sLine.replace(/</g,"&lt;");
  sLine = sLine.replace(/>/g,"&gt;");
  var now = new Date();
	hndlDebug.document.body.innerHTML += (now.getHours() + ":" + format00(now.getMinutes()) + ":" + format00(now.getSeconds()) + "." + now.getMilliseconds() + ": " + sLine + "<br>");
}

var hndlDebug = null;
function OpenDebugWindow()
{
  if((hndlDebug == null) || (hndlDebug.closed)) {
    hndlDebug = window.open("", "DebugWindow", "height=500,width=700,menubar=no,scrollbars=yes");
		hndlDebug.document.write("<html><head><title>JavaScript Debugger</title><style> body, pre { font-family: 'Microsoft Sans Serif', Arial, sans-serif; font-size: 8pt; }</style></head><body><pre>");
	}
}

function max(v1, v2)
{
	if(parseFloat(v1) > parseFloat(v2))
		return v1;
	return v2;
}

function min(v1, v2)
{
	if(parseFloat(v1) < parseFloat(v2))
		return v1;
	return v2;
}

