// image swap script for left panel navigation
if(document.images) {    //does the browers support the image object        
databaseson = new Image();        
databaseson.src = "/images/nav_OnlineDataSystems.gif";        
whatsnewon = new Image();        
whatsnewon.src = "/images/nav_Home_on.gif";        
mineralson = new Image();        
mineralson.src = "/images/nav_MineralServices_on.gif";        
petroleumon = new Image();        
petroleumon.src = "/images/nav_PetroleumGeothermal_on.gif";        
geologicalon = new Image();        
geologicalon.src = "/images/nav_GeologicalSurveyWA_on.gif";        
resourceson = new Image();        
resourceson.src = "/images/nav_ResourcesSafety_on.gif"; 
environmentalon = new Image();
environmentalon.src ="/images/nav_EnvironmentalServices_on.gif";  
projecton = new Image();
projecton.src = "/images/nav_ApprovalsLicences_on.gif";  
statisticson = new Image();
statisticson.src = "/images/nav_ResourceStatistics_on.gif"; 
schemeon = new Image();
schemeon.src = "/images/nav_ExplorationIncentiveScheme_on.gif";
databasesoff = new Image();        
databasesoff.src = "/images/nav_OnlineDataSystems.gif";        
whatsnewoff = new Image();
whatsnewoff.src = "/images/nav_Home.gif";        
mineralsoff = new Image();        
mineralsoff.src = "/images/nav_MineralServices.gif";        
petroleumoff = new Image();        
petroleumoff.src = "/images/nav_PetroleumGeothermal.gif";
geologicaloff = new Image();        
geologicaloff.src = "/images/nav_GeologicalSurveyWA.gif";        
resourcesoff = new Image();        
resourcesoff.src = "/images/nav_ResourcesSafety.gif";  
environmentaloff = new Image ();
environmentaloff.src = "/images/nav_EnvironmentalServices.gif";
projectoff = new Image();
projectoff.src = "/images/nav_ApprovalsLicences.gif";
statisticsoff = new Image();
statisticsoff.src = "/images/nav_ResourceStatistics.gif"; 
schemeoff = new Image();
schemeoff.src = "/images/nav_ExplorationIncentiveScheme.gif";
homeon = new Image();
homeon.src = "/images/nav_Home_on.gif";
eventson = new Image();
eventson.src = "/images/nav_Events_on.gif";
aboutuson = new Image();
aboutuson.src = "/images/nav_AboutUs_on.gif";
employon = new Image();
employon.src = "/images/nav_Employment_on.gif";
publicationon = new Image();
publicationon.src = "/images/nav_Publications_on.gif";
formon = new Image();
formon.src = "/images/nav_FormsRegulations_on.gif";
homeoff = new Image();
homeoff.src = "";
eventsoff = new Image();
eventsoff.src = "/images/nav_Events.gif";
aboutusoff = new Image();
aboutusoff.src = "/images/nav_AboutUs.gif";
employoff = new Image();
employoff.src = "/images/nav_Employment.gif";
publicationoff = new Image();
publicationoff.src = "/images/nav_Publications.gif";
formoff = new Image();
formoff.src = "/images/nav_FormsRegulations.gif";
searchon = new Image();
searchon.src = "";
searchoff = new Image();
searchoff.src = "";
royaltieson = new Image();
royaltieson.src = "/images/nav_Royalties_on.gif";
royaltiesoff = new Image();
royaltiesoff.src = "/images/nav_Royalties.gif";
educationon = new Image();
educationon.src = "/images/nav_Education_on.gif";
educationoff = new Image();
educationoff.src = "/images/nav_Education.gif";

}
//Function to 'active' images.
function imgOn(imgName){    
 if(document.images){            
  document[imgName].src = eval(imgName + "on").src;        
 }    
}
//function to deactivate images
function imgOff(imgName){
 if(document.images){            
  document[imgName].src = eval(imgName + "off").src;        
 }    
}
/*drop sidemenu */
function showMenu(id){    /*this shows the menu in conjunction with the onmouseover and out in the actual pages themselves*/
obj = document.getElementById(id);
/*obj.style.display="none";*/
if (obj.style.visiblity == 'hidden'){
 obj.style.visiblity = 'visible';
}else{
  obj.style.visibility = 'visible';
 }
}
function hideMenu(id){    /*this hides the menu in conjunction with the onmouseover and out in the actual pages themselves*/
  obj = document.getElementById(id);
  obj.style.visibility = "hidden";
}
//events and news items//
function showitem(choseone) {
var listitem = document.getElementsByTagName("div");
for(var x=0; x < listitem.length; x++){
 name = listitem[x].getAttribute("name");
 if (name == 'listitem'){
  if (listitem[x].id == choseone){
   listitem[x].style.display = 'block';}
  else {
   listitem[x].style.display = 'none';}
  }
 }
}
/*drop sidemenu */
function showMenu(id){    /*this shows the menu in conjunction with the onmouseover and out in the actual pages themselves*/
obj = document.getElementById(id);
obj.style.display="";
 if (document.getElementById(id).style.display == 'none') {
  document.getElementById(id).style.display = 'block';
 }else{
  document.getElementById(id).style.display = 'block';
 }
 navStyle();
}
function hideMenu(id){    /*this hides the menu in conjunction with the onmouseover and out in the actual pages themselves*/
 obj = document.getElementById(id);
 obj.style.display = "none";
}
function getTagsByClassName(clsName){
var retVal = new Array();
var elements = document.getElementsByTagName("*");
 for(var i = 0;i < elements.length;i++){
  if(elements[i].className.indexOf(" ") >= 0){
    var classes = elements[i].className.split(" ");
    for(var j = 0;j < classes.length;j++){
     if(classes[j] == clsName)
      retVal.push(elements[i]);
     }
    }else if(elements[i].className == clsName)
     retVal.push(elements[i]);
  }
 return retVal;
}
//news archives items//
function checkStatus() {
var divValue = getQueryVariable("imonth");
if(typeof(divValue)=="undefined"){
    openTopDiv();
}else{
    currentNavDiv = document.getElementById(divValue);
    currentNavDiv.style.display = "block";
}
var pageIndex = document.getElementById('pageIndex');
    if (pageIndex == undefined){
        return false;
    }else{
    var items = pageIndex.getElementsByTagName('p');
    if(items.length<2){
        pageIndex.style.display = 'none';
        showHideImg = document.getElementById('img_index');
        showHideImg.style.display = 'none';
    }
  }
}
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]; }
}
}
function openTopDiv() {
try{
divYear = getElementsByClassName(document, "*", "invisible");
if(typeof(divYear)!="undefined"){
    firstDiv = document.getElementById(divYear);
    divYear.style.display = 'block'; }
}catch(e){
}
}
function navStyle(){
var nav = document.getElementById("leftpanel");
var arrMenuItems = getAllElementsByClassName(document, "*", "menuitems"); 
for(i=0; i<arrMenuItems.length; i++){ 
 var arrDD = arrMenuItems[i].getElementsByTagName("dd");
  for(j=0; j<arrDD.length; j++){
   var lastItem = (arrDD.length - 1);
   if(j==lastItem){
    arrDD[j].style.borderBottom="none";
   }
  }
 }
}
function displayDates() {
 var fullDateArr = getAllElementsByClassName(document, "*", "eventdaydate1");
 var monthArr = getAllElementsByClassName(document, "*", "eventmonth1");
 for(i=0; i<fullDateArr.length; i++){
  var fullText = fullDateArr[i].innerHTML;
  var splitText = fullText.split(" ");        
  fullDateArr[i].innerHTML = splitText[0];
  var monthNum = splitText[1];
  var month;
  switch(monthNum){
   case "01":
    month = 'January';
    break;
   case "02":
    month = 'February';
    break;
   case "03":
    month = 'March';
    break;
   case "04":
    month = 'April';
    break;
   case "05":
    month = 'May';
    break;
   case "06":
    month = 'June';
    break;
   case "07":
    month = 'July';
    break;
   case "08":
    month = 'August';
    break;
   case "09":
    month = 'September';
    break;
   case "10":
    month = 'October';
    break;
   case "11":
    month = 'November';
    break;
   case "12":
    month = 'December';
    break;
   default:'unkown'}
  monthArr[i].innerHTML = month;
 }
}
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return arrReturnElements[0];
} 
function getAllElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return arrReturnElements;
} 
// show hide title
function pageIndexDisplay(){
onlineSys(); 
displayDates();
 var pageIndex = document.getElementById('pageIndex');
   if (pageIndex == undefined){
    return false;
   }else{
   var items = pageIndex.getElementsByTagName('p');
   if(items.length<2){
    pageIndex.style.display = 'none';
    showHideImg = document.getElementById('img_index');
    showHideImg.style.display = 'none';
  }
 }
}
function showHideDiv(divId, main){
 id = document.getElementById(divId);
  if(id.innerHTML == ""){
   cont = document.getElementById(main);
   cont.id = "content1";
   cont.style.marginRight = "0px";        
   id = document.getElementById(divId);
   id.style.display = "none";
  }else{
   cont = document.getElementById(main);
   cont.id = "content";
   id = document.getElementById(divId);
   id.style.display = "";
 }
}
function showHideIndex() {
 var pageIndex = document.getElementById('pageIndex');
 showHideImg = document.getElementById('img_index');
  if(pageIndex.style.display == 'none'){
   pageIndex.style.display = '';
   showHideImg.src = "";
  }else{
   pageIndex.style.display = 'none';
   showHideImg.src = "";
 }
}
function onlineSys() {
var app = getQueryVariable("app");
 if(typeof(app)=="undefined"){
  return false;
 }else{
   var currentDiv = document.getElementById(app);
   currentDiv.style.display = "";
 }
}
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];}
 }
}
function GotoWindow(url){
 if (navigator.appName == "Netscape") {
  alert("WARNING!!: You are using Netscape. This may not produce the best results. We recommend you use IE4.+")
   var LWnd = window.open(url,"LegalWindow","width=800,height=500,resizable=yes,scrollbars=yes,top=75,left=15,status=yes");
  }else{    
    var LWnd = window.open(url,"LegalWindow","width=800,height=500,resizable=yes,scrollbars=yes,top=75,left=15,status=yes");  }
} 
function HiWindow(url) {
 var scrwidth = screen.availWidth - 8
 var scrheight = screen.availHeight - 50
 if (navigator.appName == "Netscape") {
    var hWnd = window.open(url,"HiWindow","width=" + scrwidth + ",height=" + scrheight + ",resizable=yes,scrollbars=yes,top=0,left=0,status=yes");
 } else {    
 var hWnd = window.open(url,"HiWindow","width=" + scrwidth + ",height=" + scrheight + ",resizable=yes,scrollbars=yes,top=0,left=0,status=yes");
 } 
 //if (hWnd.focus != null) hWnd.focus();
}
function titleDisplay(img){
 var image = document.getElementById(img);
 image.style.display = "block";    
}
function titleHide(img){
 var image = document.getElementById(img);
 image.style.display = "none";    
} 
function clearFormText(field){
 if (field.defaultValue == field.value) field.value = '';
 else if (field.value == '') field.value = field.defaultValue;
}
//individual news items//
var allhdl = new Array('c1','c2','c3','c4');
var hdldept = new Array('d1','d2','d3','d4');
var hdlind = new Array('e1','e2','e3','e4');
var hdlmin = new Array('f1','f2','f3','f4');
function switchhdlall(id){    
 hideallhdl();
 showallhdl(id);}
function switchdepthdl(id){    
 hidedept();
 showallhdl(id); }
function switchindhdl(id){    
 hideind();
 showallhdl(id); }
function switchminhdl(id){    
 hidemin();
 showallhdl(id); }
function hideallhdl(){    //loop through the array and hsectid each element by id
 for (var i=0;i<allhdl.length;i++){
  hideallitems(allhdl[i]);
 }          
}
function hidedept(){    //loop through the array and hsectid each element by id
 for (var i=0;i<hdldept.length;i++){
  hideallitems(hdldept[i]);
 }          
}
function hideind(){    //loop through the array and hsectid each element by id
 for (var i=0;i<hdlind.length;i++){
  hideallitems(hdlind[i]);
 }          
}
function hidemin(){    //loop through the array and hsectid each element by id
 for (var i=0;i<hdlmin.length;i++){
  hideallitems(hdlmin[i]);
 }          
}
function hideallitems(id) {    //safe function to hsectid an element with a specified id
 if (document.getElementById) { // DOM3 = IE5, NS6
  document.getElementById(id).style.display = 'none';
 }
}
function showallhdl(id) {    //safe function to show an element with a specified i        
 if (document.getElementById) { // DOM3 = IE5, NS6
  document.getElementById(id).style.display = 'block';
 }
}
