gifdir="../common/"
theequation=""
thereactant=""
theproduct=""
requiresMolInfo=true

function doHessDemo(what){
	var s='This page demonstrates '+what+'.'
	+'<br><a href="javascript:doreload()">Click here</a> to see random equation, or see a specific '
	+'<a href="javascript:doHessEquation()">equation</a>, '
	+'<a href="javascript:doHessReactant()">reactant</a>, '
	+'or '
	+'<a href="javascript:doHessProduct()">product</a>.'
	document.write(s)
}

function doreload(a){
 var s=""
 if(arguments.length){
	s=(location+"").split("?")[0]+"?"+a
 }else{
	s=(location+"").split("?")[0]
 }
 setTimeout("location=\""+s+"\"",100)
}

function doHessReactant(){
 var s=prompt("Enter a reactant species.",thisreactant)
 if(s.length==0)return
 doreload(s) 
}

function doHessProduct(){
 var s=prompt("Enter a product species.",thisproduct)
 if(s.length==0)return
 doreload("|"+s) 
}

function doHessEquation(){
 var s=prompt("Enter a chemical equation in the form reactants --> products.",thisequation.replace(/\|/," --> "))
 if(s.length==0)return
 s=s.replace(/\-\-\>/,"|")
 doreload(s) 

}

function getHessInfo(isthermo){
 var s=location.search
 s=unescape(s.substring(1,s.length))
 thisequation=s
 s+="||"
 var S=s.split("|")
 thisreactant=S[0]
 thisproduct=S[1]
 if(thisreactant==""||thisproduct=="")thisequation=""
 var Eq=new Array()
 var sout=""
 var ic=0
 var n=(thisreactant+thisproduct==""?1:10)
 var nt=(thisequation==""?0:99)
 var isreactant=false
 var isproduct=false
 while(ic<n && (nt++)<100){
	Eq=new Array()
	sdebug=""
	createEquation(Eq,isthermo,0,thisequation,!requiresMolInfo)
	isreactant=(thisequation=="" && thisreactant!="" && Eq.list[thisreactant] && Eq.list[thisreactant].n<0)
	isproduct=(thisequation=="" && thisproduct!="" && Eq.list[thisproduct] && Eq.list[thisproduct].n>0)
	if(thisequation!=""
	||thisreactant=="" && thisproduct==""
	|| thisproduct=="" && isreactant
	|| thisreactant=="" && isproduct
	|| thisreactant!="" && thisproduct!="" && isreactant && isproduct 
	){
		if(sout.indexOf(Eq.show)<0){
			ic++
			doShowHessDemo(Eq)
			sout+=Eq.show
		}

	}
 }
}


