// JScript File
function Utility_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


function Utility_clientWidth() {
	return Utility_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	) - 9;
}
function Utility_clientHeight() {
	return Utility_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function Utility_scrollLeft() {
	return Utility_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function Utility_scrollTop() {
	return Utility_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function Utility_objHeight(obj) 
{
    alert(document.getElementById('divMessageBody').offsetHeight);
    if (obj == '[object]')
    {
        return obj.offsetHeight;
    }
    else
    {
       return document.getElementById('divMessageBody').offsetHeight;
    }
}
function Utility_objWidth(obj) 
{
    if (obj == '[object]')
    {
        return obj.offsetWidth;
    }
    else
    {
       return document.getElementById('divMessageBody').offsetWidth;
    }
}
// #############################################################################
// get left position of elm
function fetch_object_posleft(elm)
{
	var left = elm.offsetLeft;
	while((elm = elm.offsetParent) != null)
	{
		left += elm.offsetLeft;
	}
	return left;
}

// #############################################################################
// get top position of elm
function fetch_object_postop(elm)
{
	var top = elm.offsetTop;
	while((elm = elm.offsetParent) != null)
	{
		top += elm.offsetTop;
	}
	return top;
}
function IsObject(objectID)
{
    if(typeof(objectID)=='object') return true;
    return false;
}
// Send the TextArea object and max limit of text to accept.
function TextAreaLimit(_this, maxlimit)
{
    if (_this.value.length > maxlimit) 
        _this.value = _this.value.substring(0, maxlimit);
    //Future Else statement for a text limit counter
    //else 
    //    countfield.value = maxlimit - field.value.length;
}
// Just call the method to validate the data. Pass true if you allow decimals and false if you do not.
// - Returns true if Numeric, false if it is not.

//Microsoft fix for radio buttons not grouping inside a datalist
function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}
//Simple check to see if they are using IE
function isIE()
{
    return document.all?true:false;
}
//Pass value as string, validates if the value is empty
// - Returns boolean
function isEmpty(value)
{
    try
    { 
        value = value.replace(/^\s+|\s+$/g,"");
    }
    catch(e) {}
    if ( (value == null) || (value == ""))
    {
        return true;
    }
    return false;
}

