// JavaScript Document
function opensearchpage(path){
	productname = prompt("Pls Enter The Item Name","");
	
	if(productname == null)	{}
	else	{
	var spage = path + '?productname=' + productname;
	searchwindow=dhtmlmodal.open('Quick Search', 'iframe', spage, '.: Quick Search :.', 'width=850px,height=500px,center=1,resize=0,scrolling=1')
	document.getElementById('itemid_txt').value = ''
	}
} function openprintpage(path){
	cashtendered = prompt("Cash Tendered","");
	
	if(cashtendered == null)	{
		alert('PRINTING CANCELLED');		
		return;
		}
	if(cashtendered == '')	{
		alert('INVALID VALUE, PRINTING CANCELLED');
		return;
		}
	if(isNaN(cashtendered))	{
		alert('INVALID VALUE, PRINTING CANCELLED');		
		return;
		}
	
	thetotal = document.orderform.totspan.value;
	change = (cashtendered * 1) - (thetotal*1);
	bar = document.getElementById('toptop');
	bar.innerHTML = '<font color="##000000">Change is : </font>' + change;
	var IsMedicare;
	var paid;	IsMedicare = 'N';	
	
	if(document.orderform.IsPaid.checked)	{
	paid = 'N';			
	}	else	{
	paid = 'Y';	
	}	var collectedby = document.orderform.collectedby.value;
	var orderedby = document.orderform.orderedby.value;	
	var quan_string = "";
	var form_field;
	var form_name;
	
	if(collectedby == '')	{
		collectedby = 'N.A';
	}
	
	if(orderedby == '')	{
		orderedby = 'N.A';	
	}	
	
	for(var i = 0; i < document.orderform.elements.length;++ i)	{
		form_field = document.orderform.elements[i];
		form_name = form_field.name;
		
		if(form_name.substring(0,4) == "txt_")	{
			quan_string = quan_string + "," + form_field.value;	
		}
	}
	
	path = path + '&IsMedicare=' + IsMedicare + '&IsPaid=' + paid + '&CollectedBy=' + collectedby + '&OrderedBy=' + orderedby + '&CashTendered=' + cashtendered + '&quan_string=' + quan_string;
	window.showModalDialog(path, '.: Receipt :.', 'dialogWidth:250px; dialogHeight:500px')
	/*searchwindow=dhtmlmodal.open('Receipt', 'iframe', path, '.: Receipt :.', 'width=250px,height=500px,center=1,resize=0,scrolling=1')*/
} function printHidden(url) {
document.body.insertAdjacentHTML("beforeEnd",
"<iframe name=printHiddenFrame width=0 height=0></iframe>");
var doc = printHiddenFrame.document;
doc.open();
doc.write("<body onload=\"parent.onprintHiddenFrame()\">");
doc.write("<iframe name=printMe width=0 height=0 src=\"" +
url + "\"></iframe>");
doc.write("</body>");
doc.close();
}function onprintHiddenFrame() {
function onfinish() {
printHiddenFrame.outerHTML = "";
if ( window.onprintcomplete ) window.onprintcomplete();
}
printFrame(printHiddenFrame.printMe, onfinish);
}function connectparent(itemid)	{
		parent.document.allform.itemid_txt.value = itemid;
		parent.document.allform.submit();
}