﻿function print_in_new_window(id, dir) {
	var element = document.getElementById(id);

	window.chi

	var win = myRef = window.open('', 'mywin',
'left=20,top=20,width=600,height=500,toolbar=0,resizable=0');

	
	win.document.clear();

	win.document.writeln('<style type="text/css">');
	win.document.writeln('.noprint');
	win.document.writeln('{');
	win.document.writeln('	display: none;');
	win.document.writeln('}');
	win.document.writeln('</style>');

	if (dir) {
		win.document.writeln("<span dir='" + dir + "'>");
	}

	win.document.writeln(element.innerHTML);

//	win.document.writeln(element.);
	
//	alert(element.innerHTML);

	if (dir) {
		win.document.writeln("</span>");
	}
	win.print();
}
function correctCurrency(inp, event) {
	var newChar = '';

	if (event != null) {
		if (event.altKey || event.ctrlKey || (event.keyCode == 0))
			return true;

		var newChar = String.fromCharCode(event.keyCode);

		if ((newChar < '0') || (newChar > '9'))
			return true;
	}
	var val = inp.value + ""; //  + newChar;

	while (val.indexOf(",") >= 0)
		val = val.replace(",", "");

	var s = '';
	var count = 0;

	for (var i = 0; i < val.length; i++) {
		var c = val.charAt(val.length - 1 - i);

		s = c + s;

		if (i % 3 == 2)
			s = ',' + s;
	}

	if (s.charAt(0) == ',')
		s = s.substring(1, s.length);

	inp.value = s;

	return false;
}
