//String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, '');
function trim(string){

    //remove leading spaces
    while(string.substring(0, 1) == " ")
        string = string.substring(1, string.length);

    //remove trailing spaces
    while(string.substring(string.length-1, 1) == " ")
        string = string.substring(0, string.length - 2) ;

    return string;
}

function showTags(TagIds)
{   
    var aTag = TagIds.split(",");
    for (var i = 0; aTag.length > i; i++)
    {
        withTag = document.getElementById(trim(aTag[i]));                                   
        if(withTag != null)
        {
            withTag.style.display = "block";
        }          
    }
    //return false;
}

function hideTags(TagIds)
{   
    var aTag = TagIds.split(",");    
    for (var i = 0; aTag.length > i; i++)
    {        
        withTag = document.getElementById(trim(aTag[i]));
        if(withTag != null)
        {
            withTag.style.display = 'none';
        }          
    }
    //return false;
}

function removeTags(myObject, myTag)
{
    var entities = myObject.getElementsByTagName(myTag);    
    for (i = 0; 0 < entities.length; )
    {
        var theContent = document.createTextNode(entities[i].innerText ? entities[i].innerText : entities[i].textContent);
        myObject.replaceChild(theContent, entities[i]);        
    }
}

function shaveContent(myObject, iStrLength)
{
    if (myObject.innerText)    
        myObject.innerText = myObject.innerText.substring(0, iStrLength);
    else
        myObject.textContent = myObject.textContent.substring(0, iStrLength);
}



/*
var COLLAPSABLE_PARENT_NAME = "collapsable";
var COLLAPSABLE_PARENT_TYPE = "div";
var COLLAPSABLE_CHILD_TYPE = "p";
var COLLAPSABLE_BRIEF_TYPE = "span";

var COLLAPSABLE_EXPAND = "<b>[More]</b>";
var COLLAPSABLE_SHRINK = "<b>[Less]</b>";

vraFoldInit = function() {
	if(document.getElementById && document.createTextNode) {
		var entries = document.getElementsByTagName(COLLAPSABLE_PARENT_TYPE);
		for(i=0;i<entries.length;i++)
			if (entries[i].className==COLLAPSABLE_PARENT_NAME)
				assignCollapse(entries[i]);
	}
}

assignCollapse = function (div) {
	var button = document.createElement('a');
	button.style.cursor='pointer';
	button.setAttribute('expand', COLLAPSABLE_EXPAND);
	button.setAttribute('shrink', COLLAPSABLE_SHRINK);
	button.setAttribute('state', -1);
	button.innerHTML = '';
	div.insertBefore(button, div.getElementsByTagName(COLLAPSABLE_CHILD_TYPE)[0]);

	button.onclick=function(){ 
		var state = -(1*this.getAttribute('state'));
		this.setAttribute('state', state);
		this.parentNode.getElementsByTagName(COLLAPSABLE_CHILD_TYPE)[0].style.display = state==1?'none':'block';
		this.parentNode.getElementsByTagName(COLLAPSABLE_BRIEF_TYPE)[0].style.display = state==1?'block':'none';
		this.innerHTML = this.getAttribute(state==1?'expand':'shrink');
	};					
	button.onclick();
}

//window.onload = vraFoldInit;

*/
