//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() {
//	var node;
//	if (document.all&&document.getElementById) {
//	navRoot = document.getElementById("nav");
//	if (navRoot !== null) {
//		alert(navRoot);
//			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 sitesearch() {
	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&scope=aaca.infrastructure.gov.au&form=simple_infrastructure&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) {
		sitesearch();
		return false;
	}
}


function wng() {
	alert("You are now leaving the website of the Department of Infrastructure, Transport, Regional Development and Local Government.\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 the Department of Infrastructure, Transport,\n Regional Development and Local Government.");
}

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();
	}
	
    }

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');

    if(imageTagSmall && imageTagNormal && imageTagLarge){
	switch (title) {
	  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';
	        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';
	        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';
	        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;
	

                                                function popupTable(url, w, h)
                                                {
                                                                var leftprop, topprop, screenX, screenY;
                                                                if(navigator.appName == "Microsoft Internet Explorer")
                                                                {
                                                                                screenY = window.screen.height;
                                                                                screenX = window.screen.availWidth;
                                                                }
                                                                else
                                                                {
                                                                                screenY = window.outerHeight
                                                                                screenX = window.outerWidth
                                                                }
                                                                
                                                                popupX = (screenX - w) / 2;
                                                                popupY = (screenY - h) / 2;
                                                                if(navigator.appName == "Microsoft Internet Explorer")
                                                                {
                                                                                leftprop = popupX;
                                                                                topprop = popupY;
                                                                }
                                                                else
                                                                {
                                                                                leftprop = (popupX - pageXOffset);
                                                                                topprop = (popupY - pageYOffset);
                                                                }
                                                   
                                                                table_window = open(url, 'tableWindow', "location=0,status=0,scrollbars=1,width=" + w + ",height=" + h);
                                                                table_window.moveTo(popupX, popupY);
                                                }

