// image swap script for left panel navigation
if(document.images) {    //does the browers support the image object        
databaseson = new Image();        
databaseson.src = "/images/onlinesys_over.gif";        
whatsnewon = new Image();        
whatsnewon.src = "/images/whatsnew_over.jpg";        
mineralson = new Image();        
mineralson.src = "/images/mineral_over.gif";        
petroleumon = new Image();        
petroleumon.src = "/images/petroleum_over.gif";        
geologicalon = new Image();        
geologicalon.src = "/images/geological_over.gif";        
resourceson = new Image();        
resourceson.src = "/images/resources_over.gif"; 
environmentalon = new Image();
environmentalon.src ="/images/environmental_over.gif";  
projecton = new Image();
projecton.src = "/images/approvals_over.gif";  
statisticson = new Image();
statisticson.src = "/images/statistics_over.gif"; 
schemeon = new Image();
schemeon.src = "/images/scheme_over.gif";
databasesoff = new Image();        
databasesoff.src = "/images/onlinesys_up.gif";        
whatsnewoff = new Image();
whatsnewoff.src = "/images/whatsnew.jpg";        
mineralsoff = new Image();        
mineralsoff.src = "/images/mineral_up.gif";        
petroleumoff = new Image();        
petroleumoff.src = "/images/petroleum_up.gif";
geologicaloff = new Image();        
geologicaloff.src = "/images/geological_up.gif";        
resourcesoff = new Image();        
resourcesoff.src = "/images/resources_up.gif";  
environmentaloff = new Image ();
environmentaloff.src = "/images/environmental_up.gif";
projectoff = new Image();
projectoff.src = "/images/approvals_up.gif";
statisticsoff = new Image();
statisticsoff.src = "/images/statistics_up.gif"; 
schemeoff = new Image();
schemeoff.src = "/images/scheme.gif";
homeon = new Image();
homeon.src = "/images/home_over.gif";
eventson = new Image();
eventson.src = "/images/events_over.gif";
aboutuson = new Image();
aboutuson.src = "/images/aboutus_over.gif";
employon = new Image();
employon.src = "/images/employment_over.gif";
publicationon = new Image();
publicationon.src = "/images/publications_over.gif";
formon = new Image();
formon.src = "/images/forms_over.gif";
homeoff = new Image();
homeoff.src = "/images/home_up.gif";
eventsoff = new Image();
eventsoff.src = "/images/events_up.gif";
aboutusoff = new Image();
aboutusoff.src = "/images/aboutus_up.gif";
employoff = new Image();
employoff.src = "/images/employment_up.gif";
publicationoff = new Image();
publicationoff.src = "/images/publications_up.gif";
formoff = new Image();
formoff.src = "/images/forms_up.gif";
searchon = new Image();
searchon.src = "";
searchoff = new Image();
searchoff.src = "/images/search_button.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 topmenu */
function imageOver(img_id, id){
    objt = document.getElementById(id);
    if(objt.style.display=="none"){
        img = document.getElementById(img_id);
        img.src = "/images/plus_bc.gif";
    }
}
    
function imageOut(img_id, id){
    objt = document.getElementById(id);
    if(objt.style.display=="none"){
        img = document.getElementById(img_id);
        img.src = "/images/arrow_bc.gif";
    }
}
function findPosX(objt)
{
 // Script source:  http://www.quirksmode.org
 var curleft = 0;
 if (objt.offsetParent)
 {
  while (objt.offsetParent)
  {
   curleft += objt.offsetLeft
   objt = objt.offsetParent;
  }
 }
 else if (objt.x)
  curleft += objt.x;
 return curleft;
}
function showM2(id, anchor_id, img_id)
{
    objt = document.getElementById(id);
    objt2 = document.getElementById(anchor_id);
    img= document.getElementById(img_id);
    if(objt.style.display==""){
        objt = document.getElementById(id);
          objt.style.display="none";    
        img.src = "/images/plus_bc.gif";
    }
    else{   
        BcDivArray = getTagsByClassName("dropMenu");
        imgArray = getTagsByClassName("btnBreadCrumb");
        for(i=0; i < BcDivArray.length; i++){
            BcDivArray[i].style.display = "none";
            icon = document.getElementById('imgArrow'+(i+1));
            icon.src= "/images/arrow_bc.gif";
            img.src = "/images/arrow_bc.gif";
        }   
        objt.style.top="140px";
      objt.style.left=(findPosX(objt2)+12)+"px";
      objt.style.display="";
      img.src = "/images/cross_bc.gif";
    }
}
function showHideBlurb(id) {
    div = document.getElementById(id);
    if(div.style.display==""){
        div = document.getElementById(id);
        div.style.display = "none";    
    }
    else{
        div = document.getElementById(id);
        div.style.display = "";    
    }
}
//show hide divs for forms events and other home page elements
var ids=new Array('a1','a2','a3','a4','a5');
function switchid(id){    
    hideallids();
    showdiv(id);
}
function hideallids(){    //loop through the array and hide each element by id
    for (var i=0;i<ids.length;i++){
        hidediv(ids[i]);
    }          
}
function hidediv(id) {    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showdiv(id) {    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//news items//
var sectid=new Array('sctn1','sctn2','sctn3','sctn4');
function switchsect(id){    
    hidesectid();
    showallsect(id);
}
function hidesectid(){
    //loop through the array and hsectid each element by id
    for (var i=0;i<sectid.length;i++){
        hideallsect(sectid[i]);
    }          
}
function hideallsect(id) {
    //safe function to hsectid an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showallsect(id) {
    //safe function to show an element with a specified id          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//individual news items//
var allhdl = new Array('c1','c2','c3','c4','c5');
function switchhdlall(id){    
    hideallhdl();
    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 hideallitems(id) {
    //safe function to hsectid an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showallhdl(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//individual news items//
var depthdl = new Array('d1','d2','d3','d4','d5');
function switchdepthdl(id){    
    hidedepthdl();
    showdepthdl(id);
}
function hidedepthdl(){
    //loop through the array and hsectid each element by id
    for (var i=0;i<depthdl.length;i++){
        hidedept(depthdl[i]);
    }          
}
function hidedept(id) {
    //safe function to hsectid an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showdepthdl(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//individual news items//
var indhdl = new Array('e1','e2','e3','e4','e5');
function switchindhdl(id){    
    hideindhdl();
    showindhdl(id);
}
function hideindhdl(){
    //loop through the array and hsectid each element by id
    for (var i=0;i<indhdl.length;i++){
        hideind(indhdl[i]);
    }          
}
function hideind(id) {
    //safe function to hsectid an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showindhdl(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//individual news items//
var minhdl = new Array('f1','f2','f3','f4','f5');
function switchminhdl(id){    
    hideminhdl();
    showminhdl(id);
}
function hideminhdl(){
    //loop through the array and hsectid each element by id
    for (var i=0;i<minhdl.length;i++){
        hidemin(minhdl[i]);
    }          
}
function hidemin(id) {
    //safe function to hsectid an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showminhdl(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//headline items//
var listhdl=new Array('hdl1','hdl2','hdl3','hdl4');
function switchlist(id){    
    hidelist();
    showlist(id);
}
function hidelist(){
    //loop through the array and hlisthdl each element by id
    for (var i=0;i<listhdl.length;i++){
        hidelisthdl(listhdl[i]);
    }          
}
function hidelisthdl(id) {
    //safe function to hlisthdl an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showlist(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
//events items//
var ide=new Array('b1','b2','b3','b4');
function switchit(id){    
    hideit();
    showit(id);
}
function hideit(){
    //loop through the array and hide each element by id
    for (var i=0;i<ide.length;i++){
        hidethem(ide[i]);
    }          
}
function hidethem(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showit(id) {
    //safe function to show an element with a specified id
          
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
/*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){
}
}
/* show hide divs */
var yearId=new Array('yr1','yr2','yr3','yr4');
function SwitchYear(id){ 
HideYear(id);
ShowYear(id);
}
function HideYear(id){
//loop through the array and hide each element by id
//for (var i=0;i<yearId.length;i++){
// HideYrDiv(yearId[i]);
//} 
HideYrDiv(id) 
}
function HideYrDiv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
var yearDiv = document.getElementById(id);
yearDiv.style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function ShowYear(id) {
//safe function to show an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
}
else { // IE 4
document.all.id.style.display = 'block';
}
}
}
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, "*", "eventdaydate");
        var monthArr = getAllElementsByClassName(document, "*", "eventmonth");
        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 showHideDiv(divId, main){
    id = document.getElementById(divId);
    if(id.innerHTML == ""){
            cont = document.getElementById(main);
            cont.id = "content1";
            cont.style.marginRight = "0px";        
            h1 = document.getElementById("htitle");
            h1.style.background = "no-repeat url()";
            id = document.getElementById(divId);
            id.style.display = "none";
    }else{
            cont = document.getElementById(main);
            cont.id = "content";
            id = document.getElementById(divId);
            id.style.display = "";
    }
}
function showHideCountry(id){
    for(i=1; i < 11; i++){
        oldCountry = document.getElementById("country"+i);
        if(oldCountry.style.display==""){
            oldCountry.style.display = "none";    
        }
    }
    newCountry = document.getElementById(id);
    if(newCountry.style.display=="none"){
        newCountry = document.getElementById(id);
          newCountry.style.display="";
    }    
}
function MouseOver(id){
    document.getElementById(id).style.cursor = 'pointer';    
}
function MouseOut(id){
    document.getElementById(id).style.cursor = 'default';    
}
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 showHideIndex() {
    var pageIndex = document.getElementById('pageIndex');
    showHideImg = document.getElementById('img_index');
    if (pageIndex.style.display == 'none'){
        pageIndex.style.display = '';
        showHideImg.src = "/images/hide_index.gif";
    }else{
        pageIndex.style.display = 'none';
        showHideImg.src = "/images/show_index.gif";
    }
}
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";    
}