Modules=new Array()

function getField(sinfo,what,def,isnumeric){
 var s="&"+what+"="
 var v=(sinfo+s+def).split(s)[1].split("&")[0]
 return (isnumeric?parseInt(v):v)
}

function addModules(list){
 var S=list.split(",")
 var s=""
 var f=""

 for(var i=0;i<S.length;i++){
	f=S[i]
	if(f.indexOf(".")<0)f+=".js"
	if(f.indexOf(":")<0)f=codebase+f
	Modules[Modules.length]=f
	s="\n<scr"+"ipt language=javascript src="+f+"></s"+"cript>"
 document.write(s)
 }
}

function getParams(){
 fusionurl="http://fusion.stolaf.edu/gca/index.cfm"

 myurl=document.location.href.split("?")[0]
 mybase=myurl.substring(0,myurl.lastIndexOf("/"))+"/"
 islocal=(myurl.indexOf("fusion.stolaf.edu")<0)
 var st=document.location.search.replace(/\?/,"&")
 codebase=getField(st,"codebase","http://www.stolaf.edu/depts/chemistry/gca/",0)
 istest=getField(st,"istest",0,1)
 isdebug=getField(st,"isdebug",0,1)||(codebase.indexOf("www.stolaf.edu")<0)
 loaddata=getField(st,"loaddata","")
 loadfilename=getField(st,"file","")
 extensions=getField(st,"ext","")
 iloadfiles=true

 if(islocal){
	codebase=""
	apyid="-nokey"
 }else if(st.indexOf("key")>=0){
	apyid="-key"
 }else{
	apyid="-nokey"
 }

	imagedir=codebase+"img/"
	//if(islocal)alert("Note, this version of GCA has no access to the server database.\nSearching the database and sending of email is not possible.")
	if(isdebug)alert("debugging:\ncodebase="+codebase+"\nimagedir="+imagedir)
	//if(!islocal)alert("remote program load initiating")
	document.write("<title>St. Olaf College Green Chemistry Assistant</title>")
	document.write("<link rel=stylesheet type=text/css href="+codebase+"styles.css>")
	addModules("apytabs"+apyid+",apymenu"+apyid)
	addModules("tabs,divs,math,chem,grid,scroller,chart,data,csolv,c120b,examples")
	if(extensions)addModules(extensions)
	addModules("gca")
	if(isdebug)addModules("debug")
	//alert("remote program load successful:\n\n"+Modules.join("\n"))
}getParams()


