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;

var currentMenu = null;
function SwitchMenu(obj){

  /** close any other open menu **/
  var isOtherMenu = (obj != currentMenu);
  if (currentMenu != null && isOtherMenu && document.getElementById){
    var element = document.getElementById(currentMenu);
    if (element.style.display == "block") {
      element.style.display = "none";
		}
  }

  /** toggle the clicked menu **/
	if (document.getElementById){
		var element = document.getElementById(obj);
		if (element.style.display != "block") {
			element.style.display = "block";
      currentMenu = obj;
		}
		else {
			element.style.display = "none";
      currentMenu = null;
		}
	}
}

function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0

	this.ie5=((this.ver.indexOf("MSIE 5")>-1 || this.ver.indexOf("MSIE 6")>-1) && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

function makefavorite(){
	bw = new verifyCompatibleBrowser()
	if (bw.ie4 || bw.ie5) {
    window.external.AddFavorite('http://www.eldersweather.com.au','Elders Limited Weather')
	}
	else if (bw.ns4 || bw.ns5) {
		window.open('http://wool.elders.com.au/makehomepage/bookmark.asp','popup','scrollbars=yes,menubar=yes,location=no,toolbar=no,status=no,resizable=no,width=388,height=290,screenX=0,screenY=0')
	}
}

function makehomepage(link){
	bw=new verifyCompatibleBrowser()
	if (bw.ie4 || bw.ie5) {
    //oHomePage.setHomePage('http://www.elders.com.au/');
    link.style.behavior='url(#default#homepage)';
    link.setHomePage('http://www.eldersweather.com.au');
	}
	else if (bw.ns4 || bw.ns5) {
		window.open('http://wool.elders.com.au/makehomepage/default.asp','popup','scrollbars=yes,menubar=yes,location=no,toolbar=no,status=no,resizable=no,width=388,height=290,screenX=0,screenY=0')
	}
}

var mbW=250;
var mbO=[],mbP=[],mbA,mbT,mbTf;

function mbSet(m,c) {
if (document.getElementById&&document.createElement) {
	var m=document.getElementById(m);
	m.className=c;
	var e,f,i,j;

	var e=m.firstChild;
	while (e) {
		if (e.tagName=='LI') {
			var div=document.createElement('div');
			while (e.firstChild) {
				div.appendChild(e.firstChild);
			}
			e.appendChild(div);
		}
		e=e.nextSibling;
	}

	e=m.getElementsByTagName('a');
	if (!mbTf) mbTf=new Function('mbHAT();');
	for (i=0;i<e.length;i++) {
		e[i].onmouseout=e[i].onblur=mbTf;
	}

	m=m.getElementsByTagName('ul');
	for (i=0;i<m.length;i++) {
		if (j=m[i].id) {
			mbO[j]=m[i];
			e=m[i].parentNode;
			f=e.parentNode.getAttribute('id');
			if (mbO[f]) {
				mbP[j]=f;
			}
			f=new Function('mbS(\''+j+'\');');
			e=e.getElementsByTagName('a');
			for (c=0;c<e.length;c++) {
				e[c].onmouseover=e[c].onfocus=f;
			}
			mbH(j);
		}
	}
}}

function mbHA() {
	if (mbA) {
		while (mbA) mbH(mbA);
		mbHE('visible');
	}
}

function mbHAT() {
	if (!mbT) mbT=setTimeout('mbHA();', mbW);
}

function mbTC() {
	if (mbT) {
		clearTimeout(mbT);
		mbT=null;
	}
}

function mbS(m) {
	mbTC();
	if (mbA) while (mbA&&m!=mbA&&mbP[m]!=mbA) mbH(mbA);
	else mbHE('hidden');

	mbSH(m,'visible');
	mbA=m;
}

function mbH(m) {
	if (m==mbA) mbA=mbP[m];
	mbSH(m,'hidden');
	mbT=null;
}

function mbSH(m,v) {
	mbO[m].parentNode.firstChild.className=v;
	mbO[m].style.visibility=v;
}

function mbHE(v) {
	//mbHEV(v,document.getElementsByTagName('select'));
}

function mbHEV(v,e) {
	for (var i=0;i<e.length;i++) e[i].style.visibility=v;
}

var headerSearchDefaultText = 'Site Search ...';

function upfrontInit()
{
    upfront_installCascadingMenu('nav');
    upfront_installHeaderSearch('navmeta-search');
    upfront_installMetaAgentLocator('meta-agent-locator');
    upfront_installFooterRelocator('frm-footer-nav');
}

function upfront_installCascadingMenu(navId)
{
    if (document.getElementById(navId))
        mbSet(navId, 'mb');
}

function upfront_installHeaderSearch(frmId)
{
    frm = document.getElementById(frmId);
    if (!frm)
        return;

    inputs = frm.getElementsByTagName('input');
    elt = null;
    for (i = 0; i < inputs.length; i++) {
        if (inputs[i].type == 'text') {
            elt = inputs[i];
            break;
        }
    }
    if (!elt)
        return;

    frm.qElt = elt;
    elt.defaultText = headerSearchDefaultText;

    elt.onfocus = function()
    {
        if (this.value == this.defaultText)
            this.value = '';
    }

    elt.onblur = function()
    {
        if (this.value.length == 0)
            this.value = this.defaultText;
    }

    frm.onsubmit = function()
    {
        this.qElt.onfocus();
    }

    elt.onblur();
}

function upfront_installMetaAgentLocator(frmId)
{
    frm = document.getElementById(frmId);
    if (!frm)
        return;

    inputs = frm.getElementsByTagName('input');
    selects = frm.getElementsByTagName('select');

    newWidth = 0;
    for (i = 0; i < inputs.length; i++) {
        if (inputs[i].type == 'text') {
            newWidth = inputs[i].offsetWidth;
        }
    }

    if (newWidth > 0) {
        for (i = 0; i < selects.length; i++) {
            selects[i].style.width = newWidth + 'px';
        }
        for (i = 0; i < inputs.length; i++) {
            if (inputs[i].type == 'submit') {
                inputs[i].style.width = newWidth + 'px';
            }
        }
    }
}

function upfront_installFooterRelocator(frmId)
{
    frm = document.getElementById(frmId);
    if (!frm)
        return;

    frm.url.onchange = function(e)
    {
        if (this.value.length == 0)
            return;

        document.location = this.value;
    }
}
