<!--
init();
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
if (clientPC.indexOf('opera') != -1) {
	var is_opera = true;
	var is_opera_preseven = (window.opera && !document.childNodes);
	var is_opera_seven = (window.opera && document.childNodes);
}

function init() {
flag2nd = 0;
flagalpha = 0;
bufferchar = ' ';
linenum = 0;
}
function set2nd() {
if (flag2nd == 1) { flag2nd = 0; } else { flag2nd = 1; }
}
function setalpha() {
	if (flag2nd == 1)
	{
		flagalpha = 2;
		flag2nd = 0;
	} else {
		if ((flagalpha == 1) || (flagalpha == 2)) { flagalpha = 0; } else { flagalpha = 1; }
	}
}

keyFunctions = new Array(
	-1,0,-1,
	-1,-1,-1,
	3,5,-1,
	-1,-1,-1,
	-1,-1,-1,
	
	-1,-1,-1,
	7,-1,-1,
	-1,-1,-1,
	
	'~X',-1,'~X',
	8,11,-1,
	
	13,17,'~A',
	19,21,'~B',
	22,24,'~C',
	27,51,-1,
	-1,-1,-1,
	
	'~{^-1}',53,'~D',
	'~sin(','~sin{^-1}(','~E',
	'~cos(','~cos{^-1}(','~F',
	'~tan(','~tan{^-1}(','~G',
	'~^','~{pi}','~H',

	'~{^2}','~‚(','~I',
	'~,','~{E}','~J',
	'~(','~{','~K',
	'~)','~}','~L',
	'~/','~{e}','~M',
	
	'~log(','~10^(','~N',
	'~7','~u','~O',
	'~8','~v','~P',
	'~9','~w','~Q',
	'~*','~[','~R',
	
	'~ln(','~{e}^(','~S',
	'~4','~{L4}','~T',
	'~5','~{L5}','~U',
	'~6','~{L6}','~V',
	'~-','~]','~W',
	
	'~ₒ',-1,'~X',
	'~1','~{L1}','~Y',
	'~2','~{L2}','~Z',
	'~3','~{L3}','~θ',
	'~+',-1,'~"',
	
	-1,-1,-1,
	'~0',55,'~ ',
	'~.','~{i}','~:',
	'~{-}','~Ans','~?',
	'\n',-1,-1
	);
var menus = new Array();
menus[0] = new Array(
	'PLOTS TYPE MARK',1,
	'1:Plot1(','~Plot1(',
	'2:Plot2(','~Plot2(',
	'3:Plot3(','~Plot3(',
	'4:PlotsOff','~PlotsOff',
	'5:PlotsOn','~PlotsOn'
	);
menus[1] = new Array(
	'PLOTS TYPE MARK',2,
	'1:Scatter','~Scatter',
	'2:xyLine','~xyLine',
	'3:Histogram','~Histogram',
	'4:ModBoxPlot','~ModBoxPlot',
	'5:BoxPlot','~BoxPlot',
	'6:NormBoxPlot','~NormBoxPlot'
	);
menus[2] = new Array(
	'PLOTS TYPE MARK',0,
	'1:□','~□',
	'2:┼','~┼',
	'3:∙','~∙'
	);
menus[3] = new Array(
	'ZOOM MEMORY','4',
	'1:ZBox','~ZBox',
	'2:Zoom In','~Zoom In',
	'3:Zoom Out','~Zoom Out',
	'4:ZDecimal','~ZDecimal',
	'5:ZSquare','~ZSquare',
	'6:ZStandard','~ZStandard',
	'7:ZTrig','~ZTrig',
	'8:ZInteger','~ZInteger',
	'9:ZoomStat','~ZoomStat',
	'0:ZoomFit','~ZoomFit'
	);
menus[4] = new Array(
	'ZOOM MEMORY','3',
	'1:ZPrevious','~ZPrevious',
	'2:ZSto','~ZSto',
	'3:ZRcl','~ZRcl'
	);
menus[5] = new Array(
	'DEFAULT EXTRA',6,
	'RectGC','~RectGC',
	'CoordOn','~CoordOn',
	'GridOff','~GridOff',
	'AxesOn','~AxesOn',
	'LabelOff','~LabelOff',
	'ExprOn','~ExprOn'
	);
menus[6] = new Array(
	'DEFAULT EXTRA',5,
	'PolarGC','~PolarGC',
	'CoordOff','~CoordOff',
	'GridOn','~GridOn',
	'AxesOff','~AxesOff',
	'LabelOn','~LabelOn',
	'ExprOff','~ExprOff'
	);
menus[7] = new Array(
	'Normal','~Normal',
	'Sci','~Sci',
	'Eng','~Eng',
	'Float','~Float',
	'0','~Fix 0',
	'1','~Fix 1',
	'2','~Fix 2',
	'3','~Fix 3',
	'4','~Fix 4',
	'5','~Fix 5',
	'6','~Fix 6',
	'7','~Fix 7',
	'8','~Fix 8',
	'9','~Fix 9',
	'Radian','~Radian',
	'Degree','~Degree',
	'Func','~Func',
	'Par','~Par',
	'Pol','~Pol',
	'Seq','~Seq',
	'Connected','~Connected',
	'Dot','~Dot',
	'Sequential','~Sequential',
	'Simul','~Simul',
	'Real','~Real',
	'a+bi','~a+bi',
	're^θi','~r{e}^θ{i}',
	'Full','~Full',
	'Horiz','~Horiz',
	'G-T','~G-T'
	);
menus[8] = new Array(
	'EDIT CALC TESTS',9,
	'SortA(','~SortA(',
	'SortD(','~SortD(',
	'ClrList','~ClrList ',
	'SetUpEditor','~SetUpEditor '
	);
menus[9] = new Array(
	'EDIT CALC TESTS',10,
	'1: 1-Var Stats','1-Var Stats ',
	'2: 2-Var Stats','2-Var Stats ',
	'3: Med-Med','~Med-Med ',
	'4: LinReg(ax+b)', '~LinReg(ax+b) ',
	'5: QuadReg','~QuadReg ',
	'6: CubicReg','~CubicReg ',
	'7: QuartReg','~QuartReg ',
	'8: LinReg(a+bx) ','~LinReg(a+bx) ',
	'9: LnReg ','~LnReg ',
	'0: ExpReg ','~ExpReg ',
	'A: PwrReg ','~PwrReg ',
	'B: Logistic ','~Logistic ',
	'C: SinReg ','~SinReg ',
	'D: Manual-Fit','~Manual-Fit '
	);
menus[10] = new Array(
	'EDIT CALC TESTS',8,
	'1: Z-Test(','~Z-Test(',
	'2: T-Test(','~T-Test(',
	'3: 2-SampZTest(','~2-SampZTest(',
	'4: 2-SampTTest ','~2-SampTTest ',
	'5: 1-PropZTest(','~1-PropZTest(',
	'6: 2-PropZTest(','~2-PropZTest(',
	'7: ZInterval ','~ZInterval ',
	'8: TInterval ','~TInterval ',
	'9: 2-SampZInt(','~2-SampZInt(',
	'0: 2-SampTInt(','~2-SampTInt(',
	'A: 1-PropZInt(','~1-PropZInt(',
	'B: 2-PropZInt(','~2-PropZInt(',
	'C: chi^2-Test(','~chi^2-Test(',
	'D: chi^2GOF-Test(','~chi^2GOF-Test(',
	'E: 2-SampFTest ','~2-SampFTest ',
	'F: LinRegTTest ','~LinRegTTest ',
	'G: LinRegTInt ','~LinRegTInt ',
	'H: ANOVA(','~ANOVA('
	);
menus[11] = new Array(
	'OPS MATH',12,
	'1: SortA(','~SortA(',
	'2: SortD(','~SortD(',
	'3: dim(','~dim(',
	'4: Fill(','~Fill(',
	'5: seq(','~seq(',
	'6: cumSum(','~cumSum(',
	'7: deltaList(','~DeltaList(',
	'8: Select(','~Select(',
	'9: augment(','~augment(',
	'0: List►matr(','~List►matr(',
	'A: Matr►list(','~Matr►list(',
	'B: ∟','~∟'
	);
menus[12] = new Array(
	'OPS MATH',11,
	'1: min(','~min(',
	'2: max(','~max(',
	'3: mean(','~mean(',
	'4: median(','~median(',
	'5: sum(','~median(',
	'6: prod(','~median(',
	'7: stdDev(','~stdDev(',
	'8: variance(','~variance('
	);
menus[13] = new Array(
	'MATH NUM CPX PRB',14,
	'1: ►Frac', '~►Frac',
	'2: ►Dev', '~►Dec',
	'3: <sup>3</sup>','~{^3}',
	'4: <sup>3</sup>&#8730;(','~{^3}&#8730;(',
	'5: <sup>x</sup>&#8730;(','~{^x}&#8730;(',
	'6: fMin(','~fMin(',
	'7: fMax(','~fMax(',
	'8: nDeriv(','~nDeriv(',
	'9: fnInt(','~fnInt(',
	'0: solve(','~solve('
	);
menus[14] = new Array(
	'MATH NUM CPX PRB',15,
	'1: abs(','~abs(',
	'2: round(','~round(',
	'3: iPart(','~iPart(',
	'4: fPart(','~fPart(',
	'5: int(','~int(',
	'6: min(','~min(',
	'7: max(','~max(',
	'8: lcm(','~lcm(',
	'9: gcd(','~gcd('
	);
menus[15] = new Array(
	'MATH NUM CPX PRB',16,
	'1: conj(','~conj(',
	'2: real(','~real(',
	'3: imag(','~imag(',
	'4: angle(','~angle(',
	'5: abs(','~abs(',
	'6: ►Rect(','~►Rect(',
	'7: ►Polar(','~►Polar('
	);
menus[16] = new Array(
	'MATH NUM CPX PRB',13,
	'1: rand','~rand',
	'2: nPr ','~nPr ',
	'3: nCr ','~nCr ',
	'4: !','~!',
	'5: randInt(','~randInt(',
	'6: randNorm(','~randNorm(',
	'7: randBin(','~randBin('
	);
menus[17] = new Array(
	'TEST LOGIC',18,
	'1: =','~=',
	'2: ≠','~≠',
	'3: >','~>',
	'4: ≥','~≥',
	'5: <','~<',
	'6: ≤','~≤'
	);
menus[18] = new Array(
	'TEST LOGIC',19,
	'1: and','~ and ',
	'2: or','~ or ',
	'3: xor','~ xor ',
	'4: not(','~not('
	);
menus[19] = new Array(
	'NAMES MATH',20,
	'1: [A]','~[A]',
	'2: [B]','~[B]',
	'3: [C]','~[C]',
	'4: [D]','~[D]',
	'5: [E]','~[E]',
	'6: [F]','~[F]',
	'7: [G]','~[G]',
	'8: [H]','~[H]',
	'9: [I]','~[I]',
	'0: [J]','~[J]'
	);
menus[20] = new Array(
	'NAMES MATH',21,
	'1: det(','~det(',
	'2: {~T}','~{^T}',
	'3: dim(','~dim(',
	'4: Fill(','~Fill(',
	'5: identity(','~identity(',
	'6: randM(','~randM(',
	'7: augment(','~augment(',
	'8: Matr►list(','~Matr►list(',
	'9: List►matr(','~List►matr(',
	'0: cumSum(','~cumSum(',
	'A: ref(','~ref(',
	'B: rref(','~rref(',
	'C: rowSwap(','~rowSwap(',
	'D: row+(','~row+(',
	'E: *row(','~*row(',
	'F: *row+(','~*row+('
	);
menus[21] = new Array(
	'ANGLE',-1,
	'1: º','~º',
	'2: \'','~\'',
	'3: ^r','~{^r}',
	'4: ►DMS','~►DMS',
	'5: R►Pr(','~R►Pr(',
	'6: R►Pθ(','~R►Pθ(',
	'7: R►Px(','~R►Px(',
	'8: R►Py(','~R►Py('
	);
menus[22] = new Array(
	'CTL I/O',23,
	'1: If','~If ',
	'2: Then','~Then',
	'3: Else','~Else',
	'4: For(','~For(',
	'5: While ','~While ',
	'6: Repeat ','~Repeat ',
	'7: End','~End',
	'8: Pause ','~Pause ',
	'9: Lbl ','~Lbl ',
	'0: Goto ','~Goto ',
	'A: IS>(','~IS>(',
	'B: DS<(','~DS<(',
	'C: Menu(','~Menu(',
	'D: prgm','~prgm',
	'E: Return','~Return',
	'F: Stop','~Stop',
	'G: DelVar ','~DelVar ',
	'H: GraphStyle(','~GraphStyle(',
	'I: OpenLib(','~OpenLib(',
	'J: ExecLib ','~ExecLib '
	);
menus[23] = new Array(
	'CTL I/O',22,
	'1: Input','~Input ',
	'2: Prompt','~Prompt ',
	'3: Disp','~Disp ',
	'4: DispGraph','~DispGraph',
	'5: DispTable','~DispTable',
	'6: Output(','~Output(',
	'7: getKey','~getKey',
	'8: ClrHome','~ClrHome',
	'9: ClrTable','~ClrTable',
	'0: GetCalc(','~GetCalc(',
	'A: Get(','~Get(',
	'B: Send(','~Send('
	);
menus[24] = new Array(
	'DRAW POINTS STO',25,
	'1: ClrDraw','~ClrDraw',
	'2: Line(','~Line(',
	'3: Horizontal','~Horizontal ',
	'4: Vertical','~Vertical ',
	'5: Tangent(','~Tangent(',
	'6: DrawF ','~DrawF ',
	'7: Shade(','~Shade(',
	'8: DrawInv ','~DrawInv ',
	'9: Circle(','~Circle(',
	'0: Text(','~Text('
	);
menus[25] = new Array(
	'DRAW POINTS STO',26,
	'1: Pt-On(','~Pt-On(',
	'2: Pt-Off(','~Pt-Off(',
	'3: Pt-Change(','~Pt-Change(',
	'4: Pxl-On(','~Pxl-On(',
	'5: Pxl-Off(','~Pxl-Off(',
	'6: Pxl-Change(','~Pxl-Change(',
	'7: Pxl-Test(','~Pxl-Test('
	);
menus[26] = new Array(
	'DRAW POINTS STO',24,
	'1: StorePic ','~StorePic ',
	'2: RecallPic ','~RecallPic ',
	'3: StoreGDB ','~StoreGDB ',
	'4: RecallGDB ','~RecallGDB'
	);
menus[27] = new Array(
	'VARS YVARS',-1,
	'[Not yet available]',-1
	);
menus[51] = new Array(
	'DISTR DRAW',52,
	'1: normalpdf(','~normalpdf(',
	'2: normalcdf(','~normalcdf(',
	'3: invNorm(','~invNorm',
	'4: invT(','~invT(',
	'5: tpdf(','~tpdf(',
	'6: tcdf(','~tcdf(',
	'7: chi^2pdf(','~chi^2pdf(',
	'8: chi^2cdf(','~chi^2cdf(',
	'9: Fpdf(','~Fpdf(',
	'0: Fcdf(','~Fcdf(',
	'A: binompdf(','~binompdf(',
	'B: binomcdf(','~binomcdf(',
	'C: poissonpdf(','~poissonpdf(',
	'D: poissoncdf(','~poissoncdf(',
	'E: geometpdf(','~geometpdf(',
	'F: geometcdf(','~geometcdf('
	);
menus[52] = new Array(
	'DISTR DRAW',51,
	'1: ShadeNorm(','~ShadeNorm(',
	'2: Shade_t(','~Shade_t(',
	'3: Shadechi^2(','~Shadechi^2(',
	'4: ShadeF(','~ShadeF('
	);
menus[53] = new Array(
	'CATALOG',-1,
	'[Not yet available]',-1
	);
function keyPress(menu) {
	if (flag2nd == 1) {
		newtext = keyFunctions[(3*menu)+1];
	}
	if (flagalpha != 0 ) {
		newtext = keyFunctions[(3*menu)+2];
	}
	if (flagalpha+flag2nd == 0) {
		newtext = keyFunctions[3*menu];
	}
	if (typeof(newtext) == 'string'){
		if (newtext.substr(0,1) == '~') {
			insertTags('','',newtext.substr(1,newtext.length-1));
		}
	} else {
		if (newtext == -1) clearMenu();
			else 
		setMenu(newtext);
	}
	flag2nd = 0;
	if (flagalpha != 2)  {flagalpha = 0;}
}

function clearMenu(){
	var box = document.editor.mainscreen;
	box.options.length = 0;
}
function setMenu(number)
{
	var box = document.editor.mainscreen;
	var list = menus[number];
	box.options.length = 0;
	for(i=0;i<list.length;i+=2)
	{
		box.options[i/2] = new Option(list[i],list[i+1]);
	}
}
function setupMenu() {
	var box = document.editor.mainscreen;
	var number = box.options[box.selectedIndex].value;
	if (number.substr(0,1) == '~') {
		insertTags('','',number.substr(1,number.length-1));
		clearMenu();
	} else {
		if (number+0 == -1) clearMenu();
		if (number+0 != -1) setMenu(number);
	}
}
function toggleLayer(whichLayer)				//simple show/hide
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
if (style2.display == "block")
{
	style2.display = "none";
} else {
	style2.display = "block";
}
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
if (style2.display == "block")
{
	style2.display = "none";
} else {
	style2.display = "block";
}
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
if (style2.display == "block")
{
	style2.display = "none";
} else {
	style2.display = "block";
}
}
}

function showdiv(pass) {
	var divs = document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		if (divs[i].id == pass)
		{
			if (document.getElementById) // DOM3 = IE5, NS6
			{
				thisvis = divs[i].style.display;
				if (thisvis == "none") divs[i].style.display="block";// show/hide
				if (thisvis == "block") divs[i].style.display="none";// show/hide
			}
			else if (document.layers) // Netscape 4
			{
				thisvis = document.layers[divs[i]].display;
				if (thisvis == "none") document.layers[divs[i]].display="block";// show/hide
				if (thisvis == "block") document.layers[divs[i]].display="none";// show/hide
			}
			else // IE 4
			{
				thisvis = document.all.divs[i].display;
				if (thisvis == "none") document.all.divs[i].display="block";// show/hide
				if (thisvis == "block") document.all.divs[i].display="none";// show/hide
			}
		} else {
			if (divs[i].id.match(/^\d+$/))
			{
				//alert(divs[i].id);
				if (document.getElementById)
					divs[i].style.display="none";
				else if (document.layers) // Netscape 4
					document.divs[i].display = 'none';
				else // IE 4
					document.all.divs[i].display = 'none';
			}
		}
	}
}
function keycheck(e) {
 if (window.event)
    key= window.event.keyCode;
 else if (e)
    key = e.which;
 else
	key = null;
if (key) {
rowcol = getPos();
row = parseInt(rowcol/9999, 10);
col = rowcol - 9999*row;
}
if (key == 13)
{
	if (col > 6)
	{
		insertTags('','','\n' + pad(row,4) + ' :');
	}
	key = false;
} else if (key == 8)
{
	if (col==7) {
		bkspcText(7);
		key = false;
	} else if (col<7) {
		key = false;
	}
} else {
	//alert(key);
}
	if (document.editor.progdata.value == '')
	{
		document.editor.progdata.value = '0001 :';
	}
    return key;
}

function countInstances(string, word) {
  var substrings = string.split(word);
  return substrings.length - 1;
}

// apply tagOpen/tagClose to selection in textarea,
// use sampleText instead of selection if there is none
// copied and adapted from phpBB & Wikipedia / Wikicities
function insertTags(tagOpen, tagClose, sampleText) {

	var txtarea = document.editor.progdata;
	// IE
	if(document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if(!theSelection) { theSelection=sampleText;}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		var scrollTop=txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if(!myText) { myText=sampleText;}
		if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
		  txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();

		var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
		txtarea.selectionStart=cPos;
		txtarea.selectionEnd=cPos;
		txtarea.scrollTop=scrollTop;

	// All others
	} else {
		var copy_alertText=alertText;
		var re1=new RegExp("\\$1","g");
		var re2=new RegExp("\\$2","g");
		copy_alertText=copy_alertText.replace(re1,sampleText);
		copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
		var text;
		if (sampleText) {
			text=prompt(copy_alertText);
		} else {
			text="";
		}
		if(!text) { text=sampleText;}
		text=tagOpen+text+tagClose;
		document.infoform.infobox.value=text;
		// in Safari this causes scrolling
		if(!is_safari) {
			txtarea.focus();
		}
		noOverwrite=true;
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}
function pad(number,length) {
    var str = '' + number;
    while (str.length < length)
        str = '0' + str;
    return str;
}
function bkspcText(chars) {

	var txtarea = document.editor.progdata;
	// IE
	if(document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if(!theSelection) { theSelection=sampleText;}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		var scrollTop=txtarea.scrollTop;

		txtarea.value = txtarea.value.substring(0, startPos-chars) + txtarea.value.substring(startPos, txtarea.value.length);
		txtarea.focus();

		var cPos=startPos-chars;
		txtarea.selectionStart=cPos;
		txtarea.selectionEnd=cPos;
		txtarea.scrollTop=scrollTop;

	// All others
	} else {
		var copy_alertText=alertText;
		var re1=new RegExp("\\$1","g");
		var re2=new RegExp("\\$2","g");
		copy_alertText=copy_alertText.replace(re1,sampleText);
		copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
		var text;
		if (sampleText) {
			text=prompt(copy_alertText);
		} else {
			text="";
		}
		if(!text) { text=sampleText;}
		text=tagOpen+text+tagClose;
		document.infoform.infobox.value=text;
		// in Safari this causes scrolling
		if(!is_safari) {
			txtarea.focus();
		}
		noOverwrite=true;
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}
function getPos()
{
	var txtarea = document.editor.progdata;
	// Mozilla
	if(txtarea.selectionStart || txtarea.selectionStart == '0') post =  txtarea.value.substring(0, txtarea.selectionStart);
	row = countInstances(post,'\n')+1;
	column=0;
	i=post.length;
	while ((i > 0) && (post.substr(i,1) != '\n'))
	{ i--; column++;}
	return (9999*row)+column;
}
function stripLineNums()
{
	document.editor.progdata.value = document.editor.progdata.value.replace(/[0-9]{4,4} :/g,':');
	//document.editor.progdata.value = document.editor.progdata.value.substring(1,document.editor.progdata.value.length);
	return true;
}
function addLineNums()
{
	document.editor.progdata.value = '0001 :' + document.editor.progdata.value;
	thislinenum = 2;
	for(i=0;i<document.editor.progdata.value.length;i++)
	{
		if (document.editor.progdata.value.substr(i,1) == "\n")
		{
			document.editor.progdata.value = document.editor.progdata.value.substring(0,i) + '\n' + pad(thislinenum,4) + ' ' + document.editor.progdata.value.substring(i+1,document.editor.progdata.value.length);
			thislinenum++;
		}
	}
	return true;
}
function confirmDel() {
	fRet = confirm('Are you sure?');
	return fRet;
}
delflagon=0;
function delflag() {
	delflagon=1;
}
function checkViewVis() {
	if (document.perms.permview.value==1)
	{
		document.perms.permviewmore.value = '';
	} else {
		document.perms.permviewmore.value = '----n/a----';
	}
}
function checkEditVis() {
	if (document.perms.permedit.value==1)
	{
		document.perms.permeditmore.value = '';
	} else {
		document.perms.permeditmore.value = '----n/a----';
	}
}
// -->
