function _$(name) {
	return document.getElementsByName(name);
}
function $_(name) {
	return document.getElementById(name);
}
function hidden(ids) {

	var arr = new Array();
	arr = ids.split(",");
	for ( var i = 0; i < arr.length; i++) {
		$(arr[i]).style.display = "none";
	}
}
function show(ids) {
	var arr = new Array();
	arr = ids.split(",");
	for ( var i = 0; i < arr.length; i++) {
		$(arr[i]).style.display = "";
	}
}
function toggle(id) {
	var array = new Array();
	array = id.split(",");
	for ( var i = 0; i < array.length; i++) {
		el = document.getElementById(array[i]);
		var display = el.style.display ? "" : "none";
		el.style.display = display;
	}
}
function revealModal(divID) {
	window.onscroll = function() {
		$(divID).style.top = document.body.scrollTop;
	};
	$(divID).style.display = "block";
	$(divID).style.top = document.body.scrollTop;
}
function hideModal(divID) {
	$(divID).style.display = "none";
}
function gowait() {
	$("main").style.visibility = "hidden";
	$("wait").style.visibility = "visible";
}
function doRerender() {
	$("main").style.visibility = "visible";
	$("wait").style.visibility = "hidden";
}
function disableObj(obj, flag) {
	if (flag == 1) {
		obj.disabled = true;
	} else {
		obj.disabled = false;
	}
}
function linkEnter(objLink, e) {
	e = e || window.event;
	if (e.keyCode == 13) {
		objLink.click();
		return false;
	} else {
		return true;
	}
}
function openNewWindow(page) {
	var load = window
			.open(
					page,
					'',
					'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}
function submitenter(myfield, e) {
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	} else {
		if (e) {
			keycode = e.which;
		} else {
			return true;
		}
	}
	if (keycode == 13) {
		myfield.form.submit();
		return false;
	} else {
		return true;
	}
}
function changeTab(nameTab, numberItem, curr) {
	for (i = 1; i <= numberItem; i++) {
		$(nameTab + i).className = "";
	}
	$(curr).className = "selected";
}
var __currentObj = null;
var __onclickColor = "#97AAB1";
var __onmouseoverColor = "#ebebeb";
var _backgroundColor;
var _color = "#E5E5E5";
function __onclick(obj) {
	if (__currentObj != null) {
		__currentObj.style.backgroundColor = _backgroundColor;
	} else {
		obj.style.backgroundColor = "#97AAB1";
	}
	__currentObj = obj;
}
function __onmouseover(obj) {
	_backgroundColor = obj.style.backgroundColor;
	obj.style.backgroundColor = _color;
}
function __onmouseout(obj) {
	obj.style.backgroundColor = _backgroundColor;
}
function buttonImage(obj, src) {
	obj.src = src;
}
function disableButton(obj) {
	obj.disabled = true;
	// $("divModal").style.display = 'block';
}
function enableButton(obj) {
	obj.disabled = false;
	$("divModal").style.display = 'none';
}
function doSetBackColor(obj, f) {
	if (f == 1) {
		return obj.style.background = "#F5F6BE";
	} else {
		if (f == 0) {
			return obj.style.background = "#FFFFFF";
		}
	}
}
function doValidateInputText(txtObj, typeData, fBG, content, minLength) {
	// typeData 1:isNumber,2:isEmail;3:isDate;4:isChar
	var message = "";
	var value = txtObj.value;
	var length = value.length;
	var flag = false;
	doSetBackColor(txtObj, 0);
	if (value == "") {
		message += "B\u1ea1n ph\u1ea3i nh\u1eadp " + content + " !<br />";
	} else {
		if (length < minLength) {
			message += "B\u1ea1n ph\u1ea3i nh\u1eadp " + content + " "
					+ minLength + " k\xfd t\u1ef1 tr\u1edf l\xean !<br />";
		} else {
			switch (typeData) {
			case 1:
				if (!isNumber(value)) {
					flag = true;
				}
				break;
			case 2:
				if (!emailCheck(value)) {
					flag = true;
				}
				break;
			default:
				break;
			}
			if (flag) {
				message += content + " kh\xf4ng h\u1ee3p l\u1ec7  !<br />";
			}
		}
	}
	if (message != "") {
		doSetBackColor(txtObj, fBG);
	}
	return message;
}
// Message Error
function doOncomplete(flag) {
	if (flag) {
		show("div_message_error");
	} else {
		hidden("div_message_error");
	}
}
// Entrust

// Safe submit
/**
 * This is better safe submit. It does not disable submit buttons, so the
 * appropriate name/value pair still gets sent without all that silly hidden
 * form field nonsense.
 */
function safeSubmitGood(f) {
	if (!f._submitted) {
		f._submitted = true;
		return true;
	}
	return false;
}
/*
 * -------------------------------------------------------------------------------
 * 09/23/03 - jgould Function for preventing multiple submit. It both submits
 * the form and ensures the form can not be submit again by reassigning the
 * funciton to a function that does nothing. It also disables the buttons (this
 * part only works in IE). f - the form the buttons are in
 * -------------------------------------------------------------------------------
 */
function safeSubmit(f) {
	for (i = 1; i < f.elements.length; i++) {
		if (f.elements[i].type == 'button' || f.elements[i].type == 'submit') {
			f.elements[i].disabled = true;
		}
	}
	// if(f.elements[i].type == 'submit')
	// f.submit();
	// safeSubmit = blockIt;
	// return false;
}

/*
 * -------------------------------------------------------------------------------
 * 09/23/03 - jgould Dummy function that is used in conjunciton with
 * safeSubmit(f) to prevent multiple submits.
 * -------------------------------------------------------------------------------
 */
function blockIt(f) {
	return false;
}

// Test page loading

var ld = (document.all);

var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

if (ie4 || ns6) {
	document
			.write('<div id="loading" class="loading" style="display: block"></div>');
}

if (ns6)
	ld = document.getElementById("loading");
else if (ie4)
	ld = document.all.loading;

function init() {
	// alert(document.getElementById("loading"));
	if (document.getElementById("loading") != null) {
		document.getElementById("loading").style.display = "none";
	}
	if (document.all != null) {
		if (document.all.loading != null) {
			document.all.loading.style.display = "none";
		}
	}
}
function functionprintA4(id) {
	var width=700;
	if(id=='printA4')
	{
		width=700;
	}
	else 
	{
		width=200;
	}
		
	var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";

	disp_setting += "scrollbars=yes,width="+width+", height=680, left=200, top=5";

	var content_vlue = $(id).innerHTML;

	var docprint = window.open("", "", disp_setting);

	docprint.document.open();

	docprint.document.write("<html><head>");

	docprint.document
			.write("<link rel='stylesheet' type='text/css' href='#{nav.path}/css/print.css'/>");

	docprint.document.write("</head><body onLoad=\"self.print()\">");

	docprint.document.write(content_vlue);

	docprint.document.write("</body></html>");

	docprint.document.close();

	docprint.focus();
	
}
function functionprintThermal(id) {

	var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";

	disp_setting += "scrollbars=yes,width=200, height=680, left=200, top=0";

	var content_vlue = $(id).innerHTML;

	var docprint = window.open("", "", disp_setting);

	docprint.document.open();

	docprint.document.write("<html><head>");

	docprint.document
			.write("<link rel='stylesheet' type='text/css' href='#{nav.path}/css/print.css'/>");

	docprint.document.write("</head><body onLoad=\"self.print()\">");

	docprint.document.write(content_vlue);

	docprint.document.write("</body></html>");

	docprint.document.close();

	docprint.focus();

}
function displayHDSD( x)
{
	
	if(x==0)
	{
		document.getElementById('printA4HDSD').style.display='';
		document.getElementById('printThermalHDSD').style.display='none';
		document.getElementById('printButton').title='printA4';
	}
	else if(x==1)
	{
		document.getElementById('printA4HDSD').style.display='none';
		document.getElementById('printThermalHDSD').style.display='';
		document.getElementById('printButton').title='printThermal';
	}	
	else
	{	
		document.getElementById('printA4HDSD').style.display='none';
		document.getElementById('printThermalHDSD').style.display='none';
		document.getElementById('printButton').title='';
	}
		
	
		
}
function numbersonly(e) {
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode!=8){ //if the key isn’t the backspace key (which we should allow)
		if (unicode<48||unicode>57) //if not a number return false //disable key press
			return false;
	}
}