var hasInnerText;


	function initialisation()
	{
		hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	}


	function setElementsText(el, text)
	{
		if(hasInnerText)
			$(el).innerText = text;
		else
			$(el).textContent = text;
	}
	
	function getElementsText(el)
	{
		return (hasInnerText) ?  $(el).innerText : $(el).textContent;
	}
	
	//utilities --> move to external script file for use by others
	
	/* Compares ASCII values of characters to determine wether 
	the param is a valid positive number*/
	function isPosInteger(inputVal) 
	{
		inputStr = inputVal.toString();
		for (var i = 0; i < inputStr.length; i++) 
		{
			var oneChar = inputStr.charAt(i);
			if (oneChar < "0" || oneChar > "9") 
			{
				return false;
			}
		}
		return true;
	}
	
	function isValidNumberBetweenRange(n, min, max)
	{
		n = n.value;
		
		if(!n)
			return;
		
		n = n.replace("$", "").replace(",", "");
		
		var intn = parseInt(n);
		if(isPosInteger(n) && (intn >= min) && (intn <= max) )
		{
			return true;
		}
		
		return false;
	}
	
	function CommaFormatted(amount)
	{
		
		var delimiter = ","; // replace comma if desired
		amount = new String(amount);
		var a = amount.split('.',2)
		var d = a[1];
		var i = parseInt(a[0]);
		
		if(isNaN(i)) { return ''; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		var n = new String(i);
		var a = [];
		while(n.length > 3)
		{
			var nn = n.substr(n.length-3);
			a.unshift(nn);
			n = n.substr(0,n.length-3);
		}
		if(n.length > 0) { a.unshift(n); }
		n = a.join(delimiter);
		if(d){if(d.length < 1) { amount = n; }
		else { amount = n + '.' + d; }}
		else { amount = n; }
		amount = minus + amount;
		return amount;
}	