var getFirstChar="";
var firstLetterArray=new Array(); 

var azArray= new Array();

azArray['#'] = "#";
azArray['A'] = "A";
azArray['B'] = "B";
azArray['C'] = "C";
azArray['D'] = "D";
azArray['E'] = "E";
azArray['F'] = "F";
azArray['G'] = "G";     
azArray['H'] = "H"; 
azArray['I'] = "I";  
azArray['J'] = "J";
azArray['K'] = "K";
azArray['L'] = "L";    
azArray['M'] = "M";
azArray['N'] = "N"; 
azArray['O'] = "O";  
azArray['P'] = "P";  
azArray['Q'] = "Q"; 
azArray['R'] = "R"; 
azArray['S'] = "S"; 
azArray['T'] = "T"; 
azArray['U'] = "U"; 
azArray['V'] = "V"; 
azArray['W'] = "W"; 
azArray['X'] = "X"; 
azArray['Y'] = "Y"; 
azArray['Z'] = "Z"; 

function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
} 
}
var showDetails = "show";
var hideDetails = "hide";
var selectViewString;
if (getQueryVariable("layout") == "show"){
selectViewString = "<span id=\"moveRight\"><a href=\"javascript:changeLayout(showDetails);\" class=\"showDesc\">Show details</a> ";
selectViewString += "| <a href=\"javascript:changeLayout(hideDetails);\"  class=\"hideDesc\">Show headings only</a></span>";
}
else if (getQueryVariable("layout") == "hide"){
selectViewString = "<span id=\"moveRight\"><a href=\"javascript:changeLayout(showDetails);\" class=\"showDesc1\">Show details</a> ";
selectViewString += "| <a href=\"javascript:changeLayout(hideDetails);\"  class=\"hideDesc1\">Show headings only</a></span>";
}
else{
selectViewString = "<span id=\"moveRight\"><a href=\"javascript:changeLayout(showDetails);\" class=\"showDesc\">Show details</a> ";
selectViewString += "| <a href=\"javascript:changeLayout(hideDetails);\"  class=\"hideDesc\">Show headings only</a></span>";
}
var currPathname=window.location.pathname;
var arrayPath=currPathname.split("/");
var documentRoot="dmzMetadata";
if(arrayPath.length>2){
var documentRoot=arrayPath[1];
}
var pathname=window.location.protocol+"//"+window.location.host+"/"+documentRoot;
var myBreadcrumbs="";
var myRefPoint="";
var myLevel=1;
var session_myLevel=1;
var space="&nbsp;";
function subjectLevel(myArrayInput,myLevel,myRefPoint){
var Counter=0;
aryRowDetail=new Array();
arySubjDetail=new Array();
myLevel=parseInt(session_myLevel);
myArrayInput.sort();
document.writeln("<ul class=\"navlist\">");
for(var i=0;i<myArrayInput.length;i++){
aryRowDetail=myArrayInput[i];
tempDetail=aryRowDetail[0];
arySubjDetail=tempDetail.split(",");
numberOfDocuments="";
if(arySubjDetail.length==myLevel){
eachRefPoint=aryRowDetail[0];
mySubject=arySubjDetail.pop();
subjectValue=zzLopit(mySubject,"=");
re=/,documentidentifier=/gi;
if(re.test(tempDetail)){
for(var j=0;j<aryRowDetail.length;j++){
theElementName=zzChopit(aryRowDetail[j],"=");
theElementValue=zzLopit(aryRowDetail[j],"=");
if(theElementName.toLowerCase()=="documenttitle"){
subjectValue="";
continue;
}
}
}
if(subjectValue.length>0){
if(Counter==0){
//document.writeln("<h3>Directory<\/h3>");
document.writeln("<br />");
Counter++;
}
document.writeln("<li><a href=\""+drillDown(eachRefPoint)+"\">");
document.writeln(subjectValue);
document.writeln(numberOfDocuments);
document.writeln("</a></li>");
}
}
}
document.writeln("</li>");
}
function addSpacer(myWidth){
mySpacer="<img height=1 width="+myWidth+"src=\"images/n.gif\">";
return mySpacer;
}
function drillDown(refPoint){
cDate=new Date();
timeStamp="&amp;timestamp="+Date.parse(cDate);
myLevel=parseInt(session_myLevel)+1;
conditions="&amp;myLevel="+myLevel+"&amp;myRefPoint="+refPoint;
if(myLevel>2&&window.document.filterform){
if(document.filterform.filterfield.value!=""){
conditions=conditions+"&amp;filterfield="+document.filterform.filterfield.value;
}
selindex=document.filterform.num.options.selectedIndex;
if(document.filterform.num.options[selindex].value!=""){
nrows=document.filterform.num.options[selindex].value;
conditions=conditions+"&amp;num="+nrows;
}
}
myFormAction=pathname+"/Subject?documenttitle=*"+conditions;
return myFormAction;
}
function stayOnthisLevel(refPoint){
cDate=new Date();
timeStamp="&timestamp="+Date.parse(cDate);
myLevel=parseInt(session_myLevel);
conditions="&myLevel="+myLevel+"&myRefPoint="+refPoint;
if(window.document.filterform){
if(document.filterform.filterfield.value!=""){
conditions=conditions+"&filterfield="+document.filterform.filterfield.value;
}
selindex=document.filterform.num.options.selectedIndex;
if(document.filterform.num.options[selindex].value!=""){
nrows=document.filterform.num.options[selindex].value;
conditions=conditions+"&num="+nrows;
}
}
myFormAction=pathname+"/Subject?documenttitle=*"+conditions;
window.location.href=myFormAction;
}
function gotoTheDocument(myDocument){
cDate=new Date();
timeStamp="&timestamp="+Date.parse(cDate);
window.location.href=myDocument;
return;
}
function readResultset(myArrayInput){
sortCol(myArrayInput,3);
breadCrumbCount=-1;
documentCount=0;
filterCount=0;
if(session_myLevel=="1")breadCrumbCount=0;
breadCrumbBuffer=new StringBuffer();
filterBuffer=new StringBuffer();
documentBuffer=new StringBuffer();
subjectBuffer=new StringBuffer();
commentBuffer=new StringBuffer();
breadCrumbBuffer.append("");
documentBuffer.append("");
subjectBuffer.append("");
commentBuffer.append("");
if(window.session_myRefPoint){
breadCrumbs=session_myRefPoint;
aryRevDetail=breadCrumbs.split(",");
aryRevDetail.reverse();
valueDetail=aryRevDetail.join(",");
breadCrumbs=breadCrumbs.replace(/,cn=/g," > ");
breadCrumbs=breadCrumbs.replace("cn=","");
breadCrumbs=breadCrumbs.replace(",","");
breadCrumbBuffer.append(mainBackLevel(breadCrumbs,'button2'));
breadCrumbBuffer.append("<br>");
}
if(myArrayInput.length==0){
filterBuffer.append("<div class=\"clb\"><br>Sorry, no catalogued documents were found within this category.</div>");
filterBuffer.append("<br>Suggestions:");
filterBuffer.append("<blockquote>- Make sure you navigated through the categories correctly.<br>- Try different categories.<br>- Try more general categories.<br>- Try Catalogued Search as provided above.<br>- Try Google search engine.</blockquote>");
filterBuffer.append("<br>");
filterBuffer.append("<blockquote>");
filterBuffer.append("<form method=\"get\" action=\"http://www.google.com/u/NTG\">");
filterBuffer.append("<table bgcolor=\"#FFFFFF\" cellspacing=\"0\" border=\"0\">");
filterBuffer.append("<tr valign=middle>");
filterBuffer.append("<td> <a href=\"http://www.google.com/\">");
filterBuffer.append("<img src=\"http://www.google.com/images/poweredby/poweredby_FFFFFF.gif\" border=\"0\"></a>");
filterBuffer.append("</td>");
filterBuffer.append("<td nowrap>");
filterBuffer.append("<input alt=\"GoogleSearchInput\" type=\"text\" name=\"q\" size=\"31\" maxlength=\"255\" value=\"\" />");
filterBuffer.append("<input alt=\"GoogleSearchSubmit\" type=\"submit\" name=\"sa\" value=\"Google Search\" />");
filterBuffer.append("<input alt=\"GoogleSearchHiddenInput\" type=\"hidden\" name=\"domains\" value=\"www.nt.gov.au\" />");
filterBuffer.append("<br />");
filterBuffer.append("<input alt=\"siteSearchRadio\" type=\"radio\" name=\"sitesearch\" value=\"www.nt.gov.au\" checked />");
filterBuffer.append("<font face=\"Arial, Helvetica, sans-serif\" size=\"1\"><font face=\"arial,sans-serif\" size=\"-1\">");
filterBuffer.append("Search the NT Government website   </font></font>");
filterBuffer.append("<input alt=\"siteSearchRadioNT\" type=\"radio\" name=\"sitesearch\" value=\"\" />");
filterBuffer.append("<font face=\"arial,sans-serif\" size=\"-1\">Search WWW ");
filterBuffer.append("</font><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\">with ");
filterBuffer.append("<a href=\"http://www.google.com\">Google</a></font>");
filterBuffer.append("</td>");
filterBuffer.append("</tr>");
filterBuffer.append("</table>");
filterBuffer.append("</form>");
filterBuffer.append("</blockquote>");
}else{
filterBuffer.append("<form name=\"filterform\" method=\"post\" action=\"javascript:stayOnthisLevel('"+session_myRefPoint+"')\">");
filterBuffer.append((myArrayInput.length)+" document(s) found.");
filterBuffer.append("  Filter keyword(s) within result set: ");
filterBuffer.append("  <input alt=\"FilterKeywordInput\" type=\"text\" name=\"filterfield\" />");
filterBuffer.append("  <select name=num>");
filterBuffer.append("    <option value=\"\" selected>- Default -");
filterBuffer.append("    <option value=\"10\">10 results");
filterBuffer.append("    <option value=\"20\">20 results");
filterBuffer.append("    <option value=\"30\">30 results");
filterBuffer.append("    <option value=\"50\">50 results");
filterBuffer.append("    <option value=\"100\">100 results");
filterBuffer.append("  </select>");
filterBuffer.append("  <button onclick=\":javascript:stayOnthisLevel('"+session_myRefPoint+"')\">Go</button>");
filterBuffer.append("</form>");
filterBuffer.append("<script>initialfocus();</script>");
}
seenUrl={};
for(var i=0;i<myArrayInput.length;i++){
breadCrumbs="";
documentlocation="";
description="";
documenttitle="";
documentauthor="";
lastmodifiedtime="";
createdtime="";
myInfo="";
myDepartmentNumber="";
mydocumenttitle="";
myPreviousBreadCrumbs="";
aryRowDetail=myArrayInput[i];
for(var j=0;j<aryRowDetail.length;j++){
if(j==0){
breadCrumbs=aryRowDetail[j];
aryRevDetail=breadCrumbs.split(",");
aryRevDetail.reverse();
valueDetail=aryRevDetail.join(",");
breadCrumbs=breadCrumbs.replace(/,cn=/g," > ");
breadCrumbs=breadCrumbs.replace("cn=","");
}else{
theElementName=zzChopit(aryRowDetail[j],"=");
theElementValue=zzLopit(aryRowDetail[j],"=");
switch(theElementName.toLowerCase()){
case"documentlocation":
documentlocation=theElementValue;
break;
case"description":
description=theElementValue;
break;
case"documenttitle":
documenttitle=theElementValue;
mydocumenttitle=theElementValue;
break;
case"documentauthor":
documentauthor=theElementValue.replace("cn=","");
break;
case"lastmodifiedtime":
lastmodifiedtime=theElementValue;
break;
case"createdtime":
createdtime=theElementValue;
break;
case"info":
myInfo=theElementValue;
break;
case"departmentnumber":
myDepartmentNumber=theElementValue;
break;
default:
break;
}
}
}
if(!seenUrl[documentlocation]){
seenUrl[documentlocation]=true;
}else{
filterCount+=1;
continue;
}
documentCount+=1;
breadCrumbs=zzChopit(breadCrumbs,",documentidentifier=");
breadCrumbs=breadCrumbs.replace(",","");
documentBuffer.append(addSpacer("90%"));


if (getFirstChar != documenttitle.substring(0,1) && getQueryVariable("opt") == 6){
    tempChar = documenttitle.substring(0,1);
    azArray[tempChar.toUpperCase()] = "<a href=#" + documenttitle.substring(0,1) + " class=\"firstLetterLink\">" + documenttitle.substring(0,1) + "</a>";
    firstLetterArray.push("<a href=#" + documenttitle.substring(0,1) + " class=\"firstLetterLink\">&nbsp;" + documenttitle.substring(0,1) + "&nbsp;</a>");
    documentBuffer.append("<br><br><a name=\"" + documenttitle.substring(0,1) + "\"></a><font color='#EB641E'><b>" + documenttitle.substring(0,1) + "</b></font>");
}
getFirstChar=documenttitle.substring(0,1);

documentBuffer.append("<div class=\"clb\"><a href=\"javascript:gotoTheDocument('"+documentlocation+"')\" class=\"button4\">"+documenttitle+"</a></div>");
documentBuffer.append("<div id=\"normal_layout\">");
documentBuffer.append(description);
if(documentlocation.length>80){
   docshortname=documentlocation.substring(0,70)+"...";
}else{
   docshortname=documentlocation;
}
documentBuffer.append("<br><span class=\"lcomd\"><a href=\"javascript:gotoTheDocument('"+documentlocation+"')\" class=\"button3\">"+docshortname+"</a></span>");
documentBuffer.append("<hr size=\"1\">");
documentBuffer.append("<br>");
documentBuffer.append("</div>");
}
}
function showBreadCrumbBuffer(){
document.writeln(breadCrumbBuffer);
}
function showFilterBuffer(){
document.writeln(filterBuffer);
}
function showDocumentBuffer(){
document.writeln(selectViewString);
if (getQueryVariable("opt") == 6){
   for (var i in azArray) {
      document.writeln(azArray[i]);
   }
}
if (getQueryVariable("opt") != 6){
   document.write("<br><br>");
}
document.writeln(documentBuffer+"<br>");
document.writeln(subjectBuffer);
   if (window.session_layout == "hide"){
      hidediv("normal_layout");
   }
}
function changeLayout(displayStatus){


if(displayStatus == "show"){
showdiv("normal_layout");

  if (window.session_layout){
      var QueryStringWithoutLayout = zzChopit(window.location.search.substring(1),"layout");
      window.location.href="Subject?" + QueryStringWithoutLayout + "layout=show";
   }
   else{
   	 window.location.href="Subject?" + window.location.search.substring(1) + "&layout=show";
   }


}
else{
hidediv("normal_layout");


   if (window.session_layout){
	var QueryStringWithoutLayout = zzChopit(window.location.search.substring(1),"layout");
      window.location.href="Subject?" + QueryStringWithoutLayout + "layout=hide";
   }
   else{
   	 window.location.href="Subject?" + window.location.search.substring(1) + "&layout=hide";
   }
 

}
}




