var timerOn = false;
var timerCount = 500;
var currentMenu;



function getCookie(name) {
  //used to log out of a secure area
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; host=" + domain : "") +
    "; expires=Thu, 01-Jan-2006 00:00:01 GMT";
  }
}


function menuTimeOut(){
	//used as a backup for removing highlight from menu item
	if (timerOn && currentMenu){
		var modName = currentMenu.className;
		var pos = 0;
		pos = modName.indexOf("over");
		modName=modName.substr(0,pos);
		currentMenu.className=modName;
		currentMenu="";
		timerOn=false;
	}
}	

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace
        (" over", "");
   }
   }
  }
 }
}
//window.onload=startList;
if (window.attachEvent)
window.attachEvent("onload", startList)
else
window.onload=startList;


function search() {
	var objSearchElement = document.getElementsByTagName('INPUT')[0];
	if (objSearchElement) {

		if (objSearchElement.value == '') {
			alert('Please enter a search value.');
		} else {
		window.location=('http://search.infrastructure.gov.au/search/search.cgi?collection=infrastructure&form=simple_freight&scope=www.freightcouncils.com.au&query='+objSearchElement.value);
		}

	}
}
var searchPage = 0;

function keypress(event) {
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	} else {
		if (event) {
			keycode = event.which;
		}
	}

	if (keycode == 13) {
		search();
		return false;
	}
}


//  function wng() {
//	alert("You are now leaving the website of Infrastructure Australia.\nThe website you are entering is not maintained or funded by the Commonwealth of Australia.");
// }

// function wnggov() {
//	alert("You are now leaving the website of Infrastructure Australia.");
// }

// function wngmin() {
//	alert("You are now entering the website of the\nMinister and the Parliamentary Secretary\nfor the Department of Infrastructure, Transport,\nRegional Development and Local Government.");
//} 

function dotars() {}

	startList = function() {

	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);

	if (searchPage == 1){
		initPositions();
	}
	
	//Non Firefox browsers have the menu system controlled by javascript and stylesheets.
	//Firefox uses purely stylesheets, and due to an apparent onMouseOut bug can not get
	//the functionality provided below.  The following functionality allows the parent menu
	//item to stay highlighted even when the mouse moves over the popup items.
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("popoutmenu");
		if (navRoot) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="DD") {
					childNode=node.firstChild;

					childNode.onmouseover=function() {
						timerOn=false;
						if (currentMenu){
							if (this.className != currentMenu.className){
								//remove 'over' from classname
								var modName = currentMenu.className;
								var pos = 0;
								pos = modName.indexOf("over");
								modName=modName.substr(0,pos);
								currentMenu.className=modName;
								this.className+="over";	
								currentMenu=this;
							}
						}
						else {
							this.className+="over";
							currentMenu=this;
						}
					}

					node.onmouseover=function() {
						this.className+="over";
						timerOn=false;
					}
					node.onmouseout=function() {
						//remove 'over' from classname
						var modName = this.className;
						var pos = 0;
						pos = modName.indexOf("over");
						modName=modName.substr(0,pos);
						this.className=modName;
						timerOn=true;
						res = window.setTimeout("menuTimeOut()",timerCount);						
					}
				}
			}    
		}                           
	}
    }

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }

  if(document.getElementById)
  {
    var imageTagSmall = document.getElementById('fssmall');
    var imageTagNormal = document.getElementById('fsnormal');
    var imageTagLarge = document.getElementById('fslarge');
    var imageTagLargest = document.getElementById('fslargest');

    if(imageTagSmall && imageTagNormal && imageTagLarge && imageTagLargest){
	switch (title) {
	  case 'largest' : 
		imageTagSmall.src = '/images/DOTARS_fs_off_01.gif';
		imageTagNormal.src = '/images/DOTARS_fs_off_02.gif';
		imageTagLarge.src = '/images/DOTARS_fs_off_03.gif';
		imageTagLargest.src = '/images/DOTARS_fs_on_04.gif';
	        break;
	  case 'large' : 
		imageTagSmall.src = '/images/DOTARS_fs_off_01.gif';
		imageTagNormal.src = '/images/DOTARS_fs_off_02.gif';
		imageTagLarge.src = '/images/DOTARS_fs_on_03.gif';
        	imageTagLargest.src = '/images/DOTARS_fs_off_04.gif';
	        break;
	  case 'normal' : 
		imageTagSmall.src = '/images/DOTARS_fs_off_01.gif';
		imageTagNormal.src = '/images/DOTARS_fs_on_02.gif';
		imageTagLarge.src = '/images/DOTARS_fs_off_03.gif';
	        imageTagLargest.src = '/images/DOTARS_fs_off_04.gif';
	        break;
	  case 'small' : 
		imageTagSmall.src = '/images/DOTARS_fs_on_01.gif';
		imageTagNormal.src = '/images/DOTARS_fs_off_02.gif';
		imageTagLarge.src = '/images/DOTARS_fs_off_03.gif';
	        imageTagLargest.src = '/images/DOTARS_fs_off_04.gif';
	        break;
	}
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  return ('normal');
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
if (title == 'null') {
  title = getPreferredStyleSheet();
}

function rdoValid(oSRC, args)
	{			
		args.IsValid = false;

		if ((document.Form1.rdoThreat[0].checked) || (document.Form1.rdoThreat[1].checked) || (document.Form1.rdoThreat[2].checked) || (document.Form1.rdoThreat[3].checked) || (document.Form1.rdoThreat[4].checked) || (document.Form1.rdoThreat[5].checked) || (document.Form1.rdoThreat[6].checked) || (document.Form1.rdoThreat[7].checked) || (document.Form1.rdoThreat[8].checked)){
			args.IsValid = true;
		}
}

setActiveStyleSheet(title);
    window.onload=startList;
	
		// showHide
<!--
menu_status = new Array();

function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}

//-->