// Shared functions
function removeSpaces(strIn) {
	while(strIn.indexOf(" ")>-1) {
		strIn = strIn.replace(" ","");
	}
	return strIn;
}

function arrayContainsValue(arrayToCheck, value) {
	
	var retVal = false;
	
	for(var intArrayPosition=0; intArrayPosition < arrayToCheck.length; intArrayPosition++) {
		if(arrayToCheck[intArrayPosition]==value) {
			retVal = true;
			break;	
		}
	}
	
	return retVal;	
}

function w3cSetInnerHTML(el,content) {
	if(document.all) {
		el.innerHTML = content;
	}
	else if(document.getElementById) {
		var rng = document.createRange();
		rng.setStartBefore(el);
		var htmlFrag = rng.createContextualFragment(content);
		
		// Clear element content first
		w3cClearAllChildElements(el);
	
		// Now repopulate
		el.appendChild(htmlFrag);
	}
}

function w3cClearAllChildElements(el) {
	// Clear element content first
	while(el.hasChildNodes()) {
		el.removeChild(el.lastChild);
	}
}

function appendFunctionToOnLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
