﻿/*
What it does:  This file is intended to be used for those wizards where Barcode is to be
               placed on templates. For example id badges, property id tags, Hi-Tech valve
               tags etc. It is conditionally included on the wizard page.
               This file will help us keep minimum functions within the wizard.asp page.

Referred by : wizarda.asp
*/


/* Barcode Specific function starts */
xnumber=0
function GetBarcode(ystnum, ybarcodefonts, ynochk) {
	var xchkdigit, k;
	xtextnumber = ystnum 
	return xtextnumber;
}

function generateCheckDigit(textstr) {
	var	xkeystr39 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
	var xchkdigit = 0;
	var xchar;
	textstr = textstr.toUpperCase();
	for (k=0;k<textstr.length;k++) {
		xchar = textstr.charAt(k)
		if (xkeystr39.indexOf(xchar) >= 0) {
			xchkdigit = xchkdigit + xkeystr39.indexOf(xchar) 
		}
	}
	xchkdigit = xchkdigit % 43
	return xkeystr39.charAt(xchkdigit)
}

function ChangeBarcode(objnum) {
var tmpfont=null
	okflag = true;
	if (objnum <= 0) return;
	
	xbctype = true
	
	xbarcodefonts = currobj.listbarcode.options[currobj.listbarcode.selectedIndex].value
	xnochk = true
	xhuman = true

	tmpfont=xbarcodefonts
	if (xbctype) {
		if (xbarcodefonts.indexOf("39") >=0 ) {
		}
	} else {
		tmpfont="Code39OneText"
	}
	
	xvalue = currobj.barcode.value.toUpperCase()
	currobj.barcode.value = xvalue

	xtext = GetBarcode(xvalue, xbarcodefonts, xnochk);
	if (div_prompt[objnum].toUpperCase().indexOf('BARCODE') < 0) {
		xtext = xtext.split("*").join("")
	}

	div_text[objnum] = xtext
	div_font[objnum] = xbarcodefonts
	changeText(div_text[objnum], objnum)
		
	ng_barcode = xbctype;	
	if (!xbctype) {
	} else {
		ng_barcodefonts = xbarcodefonts;
	}
	ng_nochk = xnochk;	ng_human = xhuman ;	
	ng_index = 0

	//Following code added for Hi-Tech valve tags
	var yindex=getobjectno('HUMANREADABLE')
	if (yindex!=-1) {
		div_text[yindex] = div_text[objnum]
		changeText(div_text[yindex], yindex)
	}
}
/* Barcode Specific function ends */
