<!--
//Initialize
function stoperror(){return true}
if(document.location.hostname=="brisbane.apana.org.au"){window.onerror=stoperror}
nav=navigator.appName
v=parseInt(navigator.appVersion)
//alert(nav)
//alert(v)
navok=false
if((nav=="Netscape" && v>=5) || (nav=="Microsoft Internet Explorer" && v>=4)) {navok=true}



// replaces DIV by "Click for" + property  (if defined - default - "more")
function DOMhide(clickfor)   	// in DIV - set property clickfor for RHS button; clickleft for LHS inline text; clickright for RHS inline text
{
if(navok && document.getElementsByTagName("div")) // check DOM and that "Div" s exist
	{
	instrText="Part of this document has been hidden for brevity. It can be displayed with a mouseclick, and then hidden again (if you want) using [-] button that will appear on right hand margin"
	coll=document.getElementsByTagName("div")
	if (coll[0].style.display!=null)  //check that style.display works
		{
		document.body.setAttribute("divs","y")
 
		//if (dontshow!=null){dontshow.style.display="none"}
		
		for (i=0;i<coll.length;i++)
			{
			div=coll[i]
			
			if (div.getAttribute("ignorehide")==null)  // option to treat div normally
				{
				div.style.display="none"
				// if(div.getAttribute("dontshow")==null) // option to simply hide div
					{
					//div.className="div1"      // OK
					div.style.backgroundColor="#66FFFF";
					p=div.parentNode
					msg="more"
					LHS="True"   // default
					RHS="False"
					if (clickfor!=null) {msg=clickfor}
					if (div.getAttribute("clickfor")!=null)
						{msg=div.getAttribute("clickfor")}
					//if (div.getAttribute("btype")=="lhs")
						//{LHS="True"}
					if (div.getAttribute("clickleft")!=null)
						{msg=div.getAttribute("clickleft")
						LHS="True"}
					if (div.getAttribute("clickright")!=null)
						{msg=div.getAttribute("clickright")
						RHS="True"}			
					if (LHS=="True" || RHS=="True")    //  create button - opens DIV
						{
						t=document.createTextNode("Click here for "+msg)
						button=document.createElement("p")
						button.className="divbutton_LHS"      //  OK
						button.style.color="#6666aa"
						button.title=instrText
						if (document.title=="Centre for Policy and Development Systems")
							{
							button.style.marginTop=0
							button.style.marginBottom=0
							}
						if (RHS=="True") 
							{
							button.className="divbutton_RHS"      /// OK
							button.style.color="#6666aa"
							button.align="right"
							}
						} 
						else   // impossible option
						{
						t=document.createTextNode("+")
						//openmsg="+"
						button=document.createElement("button")
						button.title="Click for "+msg
						button.className="divbutton"         // XXXXXXXXXXXXXXXXXXXXX
						}
					button.appendChild(t)
					p.insertBefore(button,div)
					button.onclick=showDiv   //NB = Function - if want parameters must use =new Function(" etc")
					button2=document.createElement("button")  // button2 closes DIV
					t=document.createTextNode("-")
					button2.appendChild(t)
					button2.title="Click to hide ....."+msg
					button2.className="divbutton2"              ///  closer
					button2.style.backgroundColor="#ffcccc"
					button2.style.position="absolute"
					//button2.style.align="right"
					button2.style.right="0px"
					button2.style.top=button.style.top //"+2px"
					p.insertBefore(button2,button)
					button2.onclick=hideDiv  
					button2.style.display="none" 
					//alert("me")
					}
				} 
			
			} //end processing DIVs
		}
	collA=document.getElementsByTagName("a")  // insert openBook on bookmarked links
	for (i=0;i<collA.length;i++) 
		{
		if (collA[i].hash!="") 
			{
			collA[i].onclick=actOnBookmark
			}	
		}
	myhash=document.location.hash
	//alert("a ="+myhash)        // TO FIX
	if(myhash!="")  {openBookmark(myhash) }
	openBookmark(myhash)
	}
}

function showDiv(e){
if (!e) var e=window.event;
if (e.srcElement) button=e.srcElement 
if (e.target) button=e.target
//button=event.srcElement
button.style.display="none"
button2=button.previousSibling; button2.style.display="block" 
div=button.nextSibling; div.style.display="block"
}

function hideDiv(e){
if (!e) var e=window.event;
if (e.srcElement) button2=e.srcElement 
if (e.target) button2=e.target
//button2=event.srcElement
button2.style.display="none"
button=button2.nextSibling; button.style.display="block"
div=button.nextSibling; div.style.display="none"
}

function actOnBookmark() // called by any hyperlink in page with DIVs
{
//alert("are we doing this "+window.event.srcElement.hash)  // THE ABSWER IS 'undefined'
openBookmark(event.srcElement.hash)
}

function openBookmark(myhash)   // when seeking bookmark - open any closed parent DIVs
{
//alert(myhash)
findHash=myhash.substring(1,myhash.length)
//alert(findhash)
collBookmark=document.getElementsByName(findHash)
if(collBookmark.length>0)
	{
	bookmark=collBookmark[0]
	if(document.body.getAttribute("divs")=="y")
		{
		p=bookmark.parentElement
		while (p!=null)
			{
			tag=p.tagName
			if(tag=="DIV")
				{
				p.style.display="block"
				button=p.previousSibling
				if(button.className=="divbutton" || button.className=="divbutton_LHS")    //XXXXXXXXXXXX
					{
					button.style.display="none"
					button.previousSibling.style.display="block"
					}
				}
			p=p.parentElement
			}
		}
	bookmark.scrollIntoView(true)
	//alert("getting here")	
	}
}



function refhide()   // hide items in reference tables (except first and "end" class) - shifted to OLD PROCUDURES
{
}



function alphaindex()  // create alphabetical index for CPDS 'issues' files - insert before id=index1 - conceal manual index (id=index2)
{
if(navok && document.getElementsByTagName("td"))  // check DOM and for presence of 'td' elements
{
myarray=new Array()
iopt=0
colltd=document.getElementsByTagName("td")
for (itd=0;itd<colltd.length;itd++)
	{
	td=colltd[itd]
	if(td.cellIndex==0&&td.className!="noindex")  // check only in first column
		{
		coll=td.getElementsByTagName("a")
		address=coll[0].getAttribute("name")
		text=gettext(td)
		myarray[iopt]=text+"#"+address; iopt++
		}
	}
myarray.sort()
menu=document.createElement("select")
menu.onchange=jumpto 
opt=new Option("Alphabetical subject index")
menu.options[0]=opt
for (i=0;i<myarray.length;i++)
	{
	s=myarray[i].split("#")
	opt=new Option(s[0],"#"+s[1]) 
	menu.options[i+1]=opt
	}
index1.style.display="none" // high index - pointer
index1.parentElement.insertBefore(menu,index1)
//index2.style.display="none" // hide index - data
}
}

// function artindex()  // create article index - insert before id=index3   -- ?? shifted to old procedures - seems unnecessary

function gettext(obj)   // part of alphaindex
{
t=""
stack=new Array()
stack[0]=obj
while (stack.length>0)
	{
	e=stack[stack.length-1];stack.length--
	if(e.nodeType==3) {t+=e.nodeValue}  // check for textnode (=3)
		else
		{if(e.firstChild!=null)
			{
			c=e.childNodes
			for (i=c.length-1;i>-1;i--) {stack[stack.length]=c[i]	}
			}
		}
	}
return t
}

function jumpto ()     // performs jump when alphabetic index is selected
{
menu=event.srcElement
with (menu){
if(selectedIndex==0||options[selectedIndex].value==""){selectedIndex=0;return}
openBookmark(options[selectedIndex].value)}
}



function mailsend()
{
document.location.href="mailto:john.c"+"pds@gmail.com"
}



function SubIndex()   // create subject menu for CPDS index file - and insert into 'topParaSpan'
{
if(navok)  // check DOM 
	{
//	menuSubs=document.createElement("select") // not needed if predefined
	topParaSpan.style.visibility="visible"
	menuSubs.onchange=  showSubs 
	subjects=new  Array("Choose a Subject",  "Asia-Pacific", "Australia",  "Development","Economy + Finance + Trade", "Environment", "Education + Health", "Global","Governance + Politics + Management", "Infrastructure", "Law and Order", "Philosophy + Values + Religion",  "Queensland","Regions", "Security + Defence", "Science + Technology", "Society + Culture", "USA")
	subHeader=1        															
	subCode= new Array(subjects.length)
	subStart= new Array(subjects.length)
	for (i=0;i<subjects.length;i++)
		{
		opt=new Option(subjects[i])
		menuSubs.options[i]=opt
		subStart[i]=-1  // no refs yet to this subject
		if (i>subHeader-1)    {subCode[i]=subjects[i].substring(0,2)}         				
		}
	topParaSpan.appendChild(menuSubs)
	topParaSpan.title="Select subject area for Viewpoints and Documents"
	uncollected=true
	prevSelect=0
	}
}

function showSubs()
{
nSelect=menuSubs.selectedIndex
if (subjects[nSelect]!=""&&nSelect!=prevSelect)
	{
	if (uncollected)  		// assemble paragraphs + identify Divs/Buttons
		{
		collp=document.getElementsByTagName("p")
		pDisplay=new Array(collp.length)
		Locn=new Array(1000)
		Backpoint=new Array(1000)
		nextLocn=0
		for (nPara=0;nPara<collp.length;nPara++)
			{
			p=collp[nPara]
			pDisplay[nPara]=-1   // -1 = invalid  0 = hidden  1 = shown
			if (p.getAttribute("s")!=null)  // valid paras only
				{
				pDisplay[nPara]=0
				s=p.getAttribute("s")
				stub=new Array()
				for (i=0;i<s.length;i=i+2)  // get stub codes in para
					{
					stub[i/2]=s.substring(i,i+2)
					}
				for (i=0;i<stub.length;i++)	// check each
					{
					for (k=subHeader;subCode.length;k++)				        				
						{
						if(stub[i]==subCode[k])   
							{
							Locn[nextLocn]=nPara
							Backpoint[nextLocn]=subStart[k]
							subStart[k]=nextLocn
							nextLocn=nextLocn+1
							break
							}
						} 
					} // end check on valid para
				}  // end invalid para
			} // next para
		uncollected=false
		} 									// end assemby 
	if(prevSelect<subHeader)					// first valid subject - identify Divs / Buttons
		{
		collDiv=document.getElementsByTagName("div")   
		specials=new Array()
		preState=new Array()
		for (i=0;i<collDiv.length;i++)
			{
			d=collDiv[i]
			specials[i]=d
			preState[i]=d.style.display
			for (j=2*(i+1);j<2*(i+2);j++)    
				{
				d=d.previousSibling
				specials[j]=d
				x="block"
				if(d.style.display!="") {x=d.style.display}
				preState[j]=x
				}
			}
		}
	if(nSelect<subHeader)					// no subject - reset as original				
		{   							
		menuSubs.options[0].text  ="Choose a subject"
		for (i=0;i<collp.length;i++)				// reset paras 
			{
			if(pDisplay[i]>-1) {pDisplay[i]=0}
			collp[i].style.display="block" 
			prevSelect=0
			}
		for(i=0;i<specials.length;i++)    		 // reset divs + buttons
			{
			specials[i].style.display=preState[i]
			}
		}
	else										 // show selected subject
		{ 
		menuSubs.options[0].text  ="Show all subjects"
		if (prevSelect>subHeader-1)			// cancel previous para settings			
			{
			for (i=0;i<collp.length;i++)
				{
				if(pDisplay[i]>-1) {pDisplay[i]=0}
				collp[i].style.display="block" 
				}
			}
		nextP=subStart[nSelect]  				// new para display settings					 
		while (nextP>-1)
			{
			pDisplay[Locn[nextP]]=1
			nextP=Backpoint[nextP]
			}
		for (i=0;i<collp.length;i++)
			{
			if (pDisplay[i]==0)  {collp[i].style.display="none" }
			}
		for (i=0;i<collDiv.length;i++) {specials[i].style.display="block"}		// Show Divs, Hide Buttons
		for (i=collDiv.length;i<specials.length;i++) {specials[i].style.display="none"}
		prevSelect=nSelect
		}  // end display of subject
	}  // end valid sub choice		
}	// end inactive subject choice	
//-->