function newTableToggle(idTD,langHide,langShow){
	var td = document.getElementById(idTD);
	//var img = document.getElementById(idImg);
	if(td != null){
		var isHidden = td.style.display == "none" ? langHide : langShow;
		//img.src = isHidden ? "images/icon_hide.gif" : "images/icon_show.gif";
		//img.alt = isHidden ? langHide : langShow;
		td.style.display = isHidden ? "" : "none";
	}
}
function CallPrint(strid)
{
 var prtContent = document.getElementById(strid);
 var WinPrint = window.open('','','left=0,top=0,menubar=1,toolbar=0,scrollbars=1,status=0,resizable=1');
 WinPrint.document.write("<Title>.:: Print Preview .::</Title><LINK href='styles/style_im_2.css' type='text/css' rel='stylesheet'>");
 WinPrint.document.write(prtContent.innerHTML);
 WinPrint.document.close();
 WinPrint.focus();
 WinPrint.print();
 //WinPrint.close();
 prtContent.innerHTML=strOldOne;
 }
function getWords(num)
{
	num=round_decimals(num,2);
	var nm=num.split('.');
		if(nm.length>1 && nm[1]!=00)
		{
			var dec=Num2Word(nm[1]);
		}
	var intgr=Num2Word(nm[0]);
	if(nm.length>1 && nm[1]!=00)
	{
		return intgr + ' and ' + dec;
	}
	else
	{
		return intgr;
	}
}
function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()

    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {

        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0

        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }

    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length

    if (pad_total > 0) {

        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
        }
    return value_string
}


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
	rslt=rslt.replace(/^\s*|\s*$/g,"");
	return rslt
}
