﻿
//This method is used to display DBErrorMessage to FrontEnd when user clicks 'View Details' Link

function showErrMsg(sDBErrMsg,e){
  document.getElementById("dvDBError").style.display ="block";
  document.getElementById('dvDBError').innerHTML = sDBErrMsg; 
   var oDiv = document.getElementById("dvDBError");
   if (oDiv != null)
   {
        var iDivWidth = RemoveNonNumeric (oDiv.style.width);
        if (e.clientX > (document.body.scrollWidth - iDivWidth))
            oDiv.style.left = e.clientX - iDivWidth + "px";
        else
            oDiv.style.left = e.clientX + "px";
        if(document.documentElement && document.documentElement.scrollTop) 
        {		
        oDiv.style.top = e.clientY + document.documentElement.scrollTop + "px";
        }
        else
        {
        oDiv.style.top = e.clientY + document.body.scrollTop + "px";		
        }
        oDiv.style.display = "block";
        //oDiv.style.zIndex = 1000;
   }
}

// This utility function is used to strip out non-numeric characters
// from a string
function RemoveNonNumeric (sVal)
{
	var sNewVal = "";
	for (var iPos = 0; iPos < sVal.length; iPos++)
	{
		if ((sVal.substr (iPos, 1) >= 0) &&
		    (sVal.substr (iPos, 1) <= 9))
			sNewVal += sVal.substr (iPos, 1);
	}
	
	try
	{
		return parseInt (sNewVal);
	}
	catch (e)
	{
		return 0;
	}
}


function HideDBErrorMsg()
{
    oDiv = document.getElementById("dvDBError");
	if (oDiv != null)
		oDiv.style.display = "none";
}

//TD3340 Added Trim Functionality
// Remove leading whitespace 
String.prototype.lTrim = function () { return this.replace(/^\s*/, ""); }

// Remove trailing whitespace
String.prototype.rTrim = function () { return this.replace(/\s*$/, ""); }

// Remove leading and trailing whitespace
String.prototype.trim = function () { return this.rTrim().lTrim(); }

function getParentTR(ref)
{
    ok=0; // it's just to start the loop, we don't use it to get out.
    while (!ok)
	    {
	    ref = ref.parentNode;
	    if (ref.nodeType==1) //check that the node is a tag, not text (type=3)
		    {
		    if (String(ref.nodeName)=="TR")
			    {
			    return ref;
			    }
		    }
	    }
} 