<!--script type="text/javascript"-->
var $ = jQuery;

function displayExternal(frame, div)
{
	document.getElementById(div).innerHTML = document.getElementById(frame).contentWindow.document.body.innerHTML;
}

function containsValidCharsOnly(sText, ValidChars)
{
	var IsNumber = true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++)
	{
		Char = sText.charAt(i);

		if (ValidChars.indexOf(Char) == -1)
		{
			IsNumber = false;
		}
	}

	return IsNumber;
}

function isNumeric(sText)
{
	return containsValidCharsOnly(sText, "0123456789.");
}

//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license

if (!Array.prototype.every)
{
  Array.prototype.every = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this &&
          !fun.call(thisp, this[i], i, this))
        return false;
    }

    return true;
  };
}


//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

function pressButtonOnEnter(field, event, buttonID)
{
	try
	{
		var keyCode = event.keyCode;

		if (keyCode == 13)
		{
			var obj = document.getElementById(buttonID);

			obj.click();

			return false;
		}
		else
		{
			return true;
		}
	}
	catch (e)
	{
		alert(e.message);

		return false;
	}
}

function getRadioValue(obj)
{
	for (var i=0; i < obj.length; i++)
	{
		if (obj[i].checked)
		{
			return obj[i].value;
		}
	}
}

function toggleDisplay(obj)
{
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}
