// adds a class to an element
function addClass(theElement, theClass) {
	if (!checkClass(theElement, theClass)) {
		theElement.className += ' ' + theClass;
	}	
}

// removes a class from an element
function removeClass(theElement, theClass) {
   var pattern = new RegExp('\s*' + theClass);
   theElement.className = theElement.className.replace(pattern, '');
}

// checks if an element has a class
function checkClass(theElement, thePattern)
{
   var theClass = theElement.className;
   var pattern = new RegExp('\s*' + thePattern);

   if (pattern.test(theClass)) {
      return true;
   }
   else {
      return false;
   }
}

function toggleSection(sectionStr, vElement) {
	try{
		var section = document.getElementById("Section" + sectionStr);
		if (section != null) {
			if (checkClass(section, 'invisible')) {
				removeClass(section, 'invisible');
				if (vElement != null) {
					vElement.setAttribute("title", "Click here to collapse this section");
					removeClass(vElement, 'plusSign');
					addClass(vElement, 'minusSign');
					//vElement.style.background = "url(../img/list-minus.gif) no-repeat scroll 0 2px";
					//vElement.style.backgroundImage = "url(../img/list-minus.gif)";
				}
			} else {
				addClass(section, 'invisible');
				if (vElement != null) {
					vElement.setAttribute("title", "Click here to expand this section");
					removeClass(vElement, 'minusSign');
					addClass(vElement, 'plusSign');
					//vElement.style.background = "url(../img/list-plus.gif) no-repeat scroll 0 2px";
					//vElement.style.backgroundImage = "url(../img/list-plus.gif)";
				}
			}
		}
	}catch(e){}
}
function ltrim(string) {
   return string.replace(/^\s+/, "");
}

function rtrim(string) {
   return string.replace(/\s+$/, "");
}

function trim(string) {
   return rtrim(ltrim(string));
}
    // adds a class to an element
    function addClass(theElement, theClass) {
        if (!checkClass(theElement, theClass)) {
            theElement.className += ' ' + theClass;
        }
    }

    // removes a class from an element
    function removeClass(theElement, theClass) {
       var pattern = new RegExp('\s*' + theClass);
       theElement.className = theElement.className.replace(pattern, '');
    }
