 String.prototype.ltrim =
	function()
	{
		return this.replace(/^\s\s*/, '');
	}

String.prototype.rtrim =
	function()
	{
		return this.replace(/\s\s*$/, '');
	}
	
String.prototype.trim =
	function()
	{
		return this.rtrim().ltrim();
	}
	
String.prototype.removeSpaces =
	function()
	{
		return this.replace(/\s+/g,"");
	}
	
 function AdditionalInfoBuild(id, lp) 
 {    
     if (lp == null || lp.length == 0) 
     {
          var labelPart = "additional information for the above field";    
     }
     else 
     {
          var labelPart = lp;    
     }
     
    document.write("<div class=\"AASmall\"><img src=\"Images/Expand.gif\" alt=\"Click to show/hide " + labelPart + "\" id=\"" + id + "_ExpContImg\" class=\"AdditionalInfo\" onclick=\"AdditionalInfoDisplay('" + id + "', '" + labelPart + "')\"/><a href=\"JavaScript: AdditionalInfoDisplay('" + id + "', '" + labelPart + "')\" id=\"" + id + "_Link\" class=\"AASmall\">Show " + labelPart + "</a></div>");
 }

 function AdditionalInfoDisplay(id, labelPart) 
 {
     var imgElm = document.getElementById(id + "_ExpContImg");

     if (imgElm.src.indexOf("Expand.gif") > -1) {
         document.getElementById(id).style.display = "block";
         imgElm.src = "Images/Contract.gif"
         document.getElementById(id + "_Link").innerHTML = "Hide " + labelPart;
     }
     else {
         document.getElementById(id).style.display = "none";
         imgElm.src = "Images/Expand.gif"
         document.getElementById(id + "_Link").innerHTML = "Show " + labelPart;
     }
 }

function DisplayOptionalData(baseId, dataTag, containerTag, minLength)
{
	var bDisplay = false;

		if ( minLength == undefined )
	{
		minLength= 0;
	}
	if (document.getElementById(baseId + containerTag))
	{			
		if (document.getElementById(baseId + dataTag))
		{
				if (document.getElementById(baseId + dataTag).innerHTML.removeSpaces().length > minLength)
				{
				bDisplay = true;
			}
		}
	}
	if (bDisplay == false)
	{
		document.getElementById(baseId + containerTag).style.display = "none";
	}
}
