function show(elementID){
   document.getElementById(elementID).style.display = "block";
}

function hide(elementID){
   document.getElementById(elementID).style.display = "none";
}

function removeInsertedElements(){
	insertedContainers = cssQuery('.inserted');
	for(i=0;i<insertedContainers.length;i++){
		insertedContainers[i].parentNode.removeChild(insertedContainers[i]);
	}
}

/*
 Num2Word, ouputs written number in human language format
 ARGUMENTS:
 -----------
 Nbr: num, the number to be worded. This number is converted into an integer.
 Crd: bol, flags whether output is cardinal or ordinal number. Cardinal is used when describing the order of items, like "first" or "second" place.
 */
 function Num2Word(num,fmt) {
 //_ arguments
 	num = Math.round(num).toString(); // round value
 	if (num == 0) return 'zero'; // if number given is 0, return and exit
 //_ locals
 	// word numbers
 	var wnums = [['hundred','thousand','million','billion','trillion','zillion'],['one','first','ten','','th'],['two','second','twen',0,0],['three','third','thir',0,0],['four','fourth',0,0,0],['five','fifth','fif',0,0],['six','sixth',0,0,0],['seven','seventh',0,0,0],['eight','eighth','eigh',0,0],['nine','ninth',0,0,0],['ten',],['eleven',],['twelve','twelfth'],['thirteen',],['fourteen',],['fifteen',],['sixteen',],['seventeen',],['eighteen',],['nineteen',]];
 	// digits outside triplets
 	var dot = (num.length % 3) ? num.length % 3 : 3;
 	// number of triplets in number
 	var sets = Math.ceil(num.length/3);
 	// result string, word as number
 	var rslt = '';
 //_ convert every three digits
 	for (var i = 0; i < sets; i++) { // for each set of triplets
 		// capture set of numbers up to three digits
 		var subt = num.substring((!i) ? 0 : dot + (i - 1) * 3,(!i) ? dot : dot + i * 3);
 		if (subt != 0) { // if value of set is not 0...
 			var hdec = (subt.length > 2) ? subt.charAt(0) : 0; // get hundreds digit
 			var ddec = subt.substring(Math.max(subt.length - 2,0),subt.length); // get double digits
 			var odec = subt.charAt(subt.length - 1); // get one's digit
 			// hundreds digit
 			if (hdec != 0) rslt += ' ' + wnums[hdec][0] + '-hundred ' + ((fmt && ddec == 0) ? 'th' : '');
 			// add double digit
 			if (ddec < 20 && 9 < ddec) { // if less than 20...
 				// add double digit word
 				rslt += ' ' + ((fmt) ? ((wnums[ddec][1]) ? wnums[ddec][1] : wnums[ddec][0] + 'th') : wnums[ddec][0]);
 			} else { // otherwise, add words for each digit...
 				// add "and" for last set without a tens digits
 				if ((0 < hdec || 1 < sets) && i + 1 == sets && 0 < ddec && ddec < 10) rslt += 'and ';
 				// tens digit
 				if (19 < ddec) rslt += wnums[ddec.charAt(0)][(wnums[ddec.charAt(0)][2]) ? 2 : 0] + ((i + 1 == sets && odec == 0 && fmt) ? 'tieth' : 'ty') + ((0 < odec) ? '-' : ' ');
 				// one's digit
 				if (0 < odec) rslt += wnums[odec][(i + 1 == sets && fmt) ? 1 : 0];
 			}
 			// add place for set
 			if (i + 1 < sets) rslt += ' ' + wnums[0][sets - i - 1] + ' '; // if not last set, add place
 		} else if (i + 1 == sets && fmt) { // otherwise, if this set is zero, is the last set of the loop, and the format (fmt) is cardinal
 			rslt += 'th'; // add cardinal "th"
 		}
 	}
 //_ return result
 	return rslt
 }


function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
