document.write("<title>divgraph.js Examples</title>")

exampledir="img"

Farray=new Array([]
	,["#adddata","GRadddata"]
	,["#addfunction","GRaddfunction"]
	,["#addpoint","GRaddpoint"]
	,["#addtext","GRaddtext"]
	,["#alert","GRalert"]
	,["#cleargraph","GRcleargraph"]
	,["#closegraphdocument","GRclosegraphdocument"]
	,["#closegraphwindow","GRclosegraphwindow"]
	,["#copy","GRcopy"]
	,["#datacolor","GRdatacolor"]
	,["#debug","GRdebugwrite"]
	,["#div","GRdiv"]
	,["#divinfo","GRdivinfo"]
	,["#divmove","GRdivmove"]
	,["#divshow","GRdivshow"]
	,["#divwrite","GRdivwrite"]
	,["#dotics","GRdotics"]
	,["#drawgraph","GRdrawgraph"]
	,["#findparen","GRfindparen"]
	,["#fixpower","GRfixpower"]
	,["#getdata","GRgetdata"]
	,["#getinfo","GRgetinfo"]
	,["#getleast","GRgetleastsquares"]
	,["#getnewwindow","GRgetnewwindow"]
	,["#getoffset","GRgetoffset"]
	,["#graph","GRgraph"]
	,["#graphpoint","GRgraphpoint"]
	,["#init","GRinit"]
	,["#initdivs","GRinitdivs"]
	,["#inrange","GRinrange"]
	,["#labelof","GRlabelof"]
	,["#LSQ","GRLSQ"]
	,["#LSR","GRLSR"]
	,["#mouseevent","GRmouseevent"]
	,["#ndig","GRndig"]
	,["#newdata","GRnewdata"]
	,["#newdiv","GRnewdiv"]
	,["#newlabel","GRnewlabel"]
	,["#newpt","GRnewpt"]
	,["#newstyle","GRnewstyle"]
	,["#opengraphframe","GRopengraphframe"]
	,["#opengraphwindow","GRopengraphwindow"]
	,["#prompt","GRprompt"]
	,["#ptof","GRptof"]
	,["#rect","GRrect"]
	,["#replot","GRreplot"]
	,["#resize","GRresize"]
	,["#roundoff","GRroundoff"]
	,["#setgraph","GRsetgraph"]
	,["#setgraphwindow","GRsetgraphwindow"]
	,["#show","GRshow"]
	,["#sort","GRsort"]
	,["#spline","GRspline"]
	,["#xof","GRxof"]
	,["#yof","GRyof"]
	,["#10","GR10"]
)

function cleararrays(){
	Info=new Array()
	Data=new Array()
	Table=new Array()
	Examples=new Array()
}cleararrays()

Text=new Array()
Functions=new Array()
Title=new Array()
sdefer=""
scode=""
opt="menubar,scrollbars,width=600,height=400,left=100,top=30"

function docode(example){
	var sm=""+Math.random()
	sm=sm.substring(3,10)
	var w=open("","DT_"+sm,opt)
	var doc=w.document.open()
	s="Example "+example+": "+Title[example]
	doc.writeln("<h2>"+s+"</h2>")
	doc.writeln("<h3>Clip the following and save it as an HTML file in the directory containing divgraph.js and its associated image files to produce the example shown.</h3><pre>")
	doc.writeln("&lt;html>\n&lt;head>")
	doc.writeln("&lt;title>"+s+"&lt;/title>")
	doc.writeln("&lt;script type=text/javascript src=divgraph.js>&lt;/script>")
	writec(doc,"&lt;script type=text/javascript>\n")
	doc.writeln("function doexample(){")
	doc.writeln(fixfunc(eval("document.example"+example+".code.value")))
	doc.writeln("}")
	if(Functions[example]!=null)doc.writeln(fixfunc(Functions[example]))
	writec(doc,"&lt;/script>\n&lt;/head>\n&lt;body>")
	writec(doc,"&lt;form name=example"+example+">\n"+(Text[example]!=null?Text[example]:""))
	writec(doc,"&lt;br>\nUsing a button:")
	writec(doc,"&lt;input type=button value=Graph onclick=doexample()>\n&lt;/form>")
	writec(doc,"\nOr, not using a form:\n\n&lt;a href=javascript:doexample()>Graph&lt;/a>")
	writec(doc,"&lt;/body>&lt;/html>")
	doc.close()
}

function doexample(example){
	scode=eval("document.example"+example+".code.value")
	eval(scode)
	//setTimeout("doevalscode()",100)
	//NN7: scope of setTimeout doesn't allow for global?
}

function dosetup(n,title,note,code,data){
	var cc=50
	var cr=(code==null?0:nlines(code))
	var i=Table.length
	var s="<HR><a name="+n+"><H3>Example "+n+": "+title+"</H3></a><p><b>"+note+"</b><p>"
	var st=""
	if(cr){
		Table[i]='\n<td valign=top align=center width=200>Example '+n+'<br><a name="+n+"top href=#'+n+'><img width=156 height=175 src='+exampledir+'/ex'+n+'.gif><br>'+title+'</a>'+
		"<p><a href=javascript:doexample('"+n+"')>Execute JavaScript</a>"+
		"<br><a href=javascript:docode('"+n+"')>View the code</a><p>&nbsp;"
		s+="<form name=example"+n+"><table><tr>"+Table[i]+
		"<td valign=top><p>"+(data==null?"":data)+"<textarea name=code rows="+cr+" cols="+cc+">"
		+code+"</textarea><p>Change this code, then click on the \"Execute JavaScript\" link, to see the effect.</table></form>"
		st="#"+n
		i=s.indexOf(st)
		s=s.substring(0,i)+"javascript:doexample('"+n+"')"+s.substring(i+st.length,s.length)
	}
	(cr && data==null?Examples[Examples.length]=s:document.writeln(s))
	Title[n]=title
}

function exampletext(example,text,defer){Text[example]=text;if(!defer)showtext(example)}

function examplefunc(example,funclist){
	Functions[example]=""
	for(var i=1;i<arguments.length;i++)Functions[example]+=arguments[i].toString()+"\n"
}

function fixfunc(f){
	var s=f.replace(/</g,"&lt;")
	var r=""
	var sf=""
	for(var i=1;i<Farray.length;i++){
		r=new RegExp(Farray[i][1]+"\\(","g")
		if(Farray[i][0].length){
			sf="target=_nfunc href=function.htm"+Farray[i][0]
			s=s.replace(r,"<a "+sf+">"+Farray[i][1]+"</a>(")	
		}
	}
	return s
}

function nlines(s){var A=s.split("\n");return A.length+1}

function showall(objName,doc){
	if(nlines>nmax || depth==depthmax)return ""
	nlines++
	depth++
	var s = ""
	var obj=eval(objName)
	if(obj==null)return
	for(var i in obj){
		var st=objName+"."+i+" = "+obj[i]
		writec(doc,st)
		i=""+i
		if(st.indexOf(" = [")>=0
			&& i.indexOf("G")!=0
			&& i.indexOf("previous")<0
			&& i.indexOf("next")<0
			&& i.indexOf("bove")<0
			&& i.indexOf("elow")<0
			&& i.indexOf("arent")<0
			&& i!="document"
			&& i!="window"
			){
			if(isNaN(i)){
				if(i!="all"){
					showall(objName+"."+i,doc)
				}
			}else{
				if(objName!="document.all"){
					showall(objName+"["+i+"]",doc)
				}
			}
		}
	}
	depth--
}

function showdocinfo(what){
	GRinitdivs()
	if(arguments.length<1)what=(GR.isnn4||GR.isnn6?"document":"document.all")
	depth=0
	nmax=300
	nlines=0
	depthmax=(GR.isnn4||GR.isnn6?5:2)
	var sm=""+Math.random()
	sm=sm.substring(3,10)
	var w=open("","DT_"+sm,opt)
	doc=w.document.open()
	doc.writeln("<pre>")
	showall(what,doc)
	doc.writeln("</pre>")
	doc.close()
}

function showexamples(dodefer){
	document.writeln("<body>")
	document.writeln("<table>")
	if(dodefer){
		for(var i=0;i<Table.length;i++)document.writeln((i%3==0?"<tr>":"")+Table[i])
		document.writeln((Examples.length==1?"<td valign=top>":"\n</table>"))
	}
	for(var i=0;i<Examples.length;i++)(dodefer?sdefer+=Examples[i]:document.writeln(Examples[i]))
	if(Examples.length==1)document.writeln("\n</table>")
	document.writeln("</body>")
}

function showfunc(){
	for(var i=0;i<arguments.length;i++)document.writeln("<pre>"+fixfunc(arguments[i].toString())+"</pre>")
}

function showtext(example){document.writeln(Text[example])}

function writec(doc,sc){doc.writeln(sc.replace(/</g,"&lt;"))}

function writefunc(func){
	var sm=""+Math.random()
	sm=sm.substring(3,10)
	var w=open("","DT_"+sm,opt)
	doc=w.document.open()
	doc.writeln("<a href=javascript:close()>Close</a><p><pre>")
	doc.writeln(fixfunc(func.toString()))
	doc.writeln("</pre>")
	doc.close()
}






