﻿function numbersOnly(e)
{
	//alert(e.keyCode);
	var numCheck;
	//allow following keys
	switch (e.keyCode)
	{
		case 8:		//backspace
		case 9:   //tab
		case 13:	//enter
		case 16:	//shift
		case 17:	//control
		case 18:	//alt
		case 35:	//end
		case 36:	//home
		case 37:	//left arrow
		case 39:  //right arrow
		case 45:	//insert
		case 46:	//delete
			CtrlKeyPressed = e.keyCode == 17;
			numCheck = true;
			break;
		case 67:	//c	 used for CTRL-C - copy
		case 86:	//v	 used for CTRL-V - paste
		case 88:	//x	 used for CTRL-X - cut
			if (CtrlKeyPressed)
				numCheck = true;
		  else
				numCheck = false;
			CtrlKeyPressed = false;
			break;
		default:
			numCheck = (e.keyCode>= 48 && e.keyCode <=57) || (e.keyCode>= 96 && e.keyCode <=105);
	}
	return numCheck;
}

//for those text boxes that are defined as number boxes - 
//make sure a 0 is placed in a textbox when user deletes the contents and leaves that text box without typing a value
//thus gaurenteing a value 
function checkValue(textBox)
{
	if (textBox.value == '')
		textBox.value = "0";
}

//trim both right and left blank spaces
function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,'');
}

function printPage_DivsOnly(src)
{
  // We break the closing script tag in half to prevent
  // the HTML parser from seeing it as a part of
  // the *main* page.
  return "<html>\n" +
    "<head>\n" +
    "<title>Temporary Printing Window</title>\n" +
    "<script>\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='step1()'>\n" +
    "<div>" + src + "'</div>\n" +
    "</body>\n" +
    "</html>\n";
}

function printDiv(div)
{
	link = "about:blank";
	var pw = window.open(link, "_new");
	pw.document.open();
	pw.document.write(printPage_DivsOnly(div.innerHTML));
	pw.document.close();
}









