function navon(a, i) {
    a.childNodes[0].src = '/assets/images/nav/' + i + '_on.png';
}

function navoff(a, i, j) {
    if (i == j)
      a.childNodes[0].src = '/assets/images/nav/' + i + '_on.png';
    else
      a.childNodes[0].src = '/assets/images/nav/' + i + '_off.png';
}

homelinkreplace = function() {
    $$('a.homelink').each(function(s) {s.href = '/?s=0'});
}

navrollovers = function() {
    $$('div.nav ul li a').each(function(s) {
	s.onmouseover = function() {
	    navon(this, this.id.replace('nav_', ''));
	};
	s.onmouseout = function() {
	    navoff(this, this.id.replace('nav_', ''), _currentSection);
	}
    });
}

function replaceContent(a) {
    new Ajax.Updater('page', a,
		     { onComplete: replaceInternalLinks(),
		       parameters: {'dyn': 'true'}
		     });
}

function replaceInternalLinks() {
/*
    $$('div a').each(function(s) {
	s.onclick= function() {
	    if (this.href.substring(7+_serverName.length, 0) ==
		'http:\/\/' + _serverName) {
		replaceContent(this.href);
		return false;
	    }
	    return true;
	}
    });
*/
}

window.onload = function() { navrollovers(); replaceInternalLinks();}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
function e(coded, key, val) {
    shift=coded.length;
    link="";
    for (i=0; i<coded.length; i++) {
	if (key.indexOf(coded.charAt(i))==-1) {
          ltr = coded.charAt(i);
          link += (ltr);
      } else {
          ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length;
          link += (key.charAt(ltr));
      }
    }
    if (val)
	document.write("<a class='mail' href='mailto:"+link+"'>" + val + "</a>");
    else
	document.write("<a class='mail' href='mailto:"+link+"'>" + link + "</a>");
}



<!-- Begin
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// End -->



function _s(i, a, w) {
    a.each(function(item) { $(item).style.display = 'none'; });
    a.each(function(item) { $(item + '_a').removeClassName('nav-item-selected'); });
    $(i).style.display = 'block';
    $(i+'_a').addClassName('nav-item-selected');
    if (w && record)
	record(w);
}


function showingMenu(a, b, c, d) {

    //var e = $('nav_services');
    //alert($('maincontainer').style.left);
    //alert(c.element.style.top + ' ' + e.style.left + ' ');
    //c.element.style.top + ' ' + e.style.element.top);
    //c.element.style.left = e.style.left;
    //c.element.style.top = e.style.top + 25;
    c.element.style.left = '480px';
    c.element.style.top = '80px';
    c.focus();
}


function leaving(a, label) {
    record(label);
    window.open(a.href, 'newwin');
    return false;
}

function record(label) {
    if (pageTracker && label)
       pageTracker._trackPageview(label);
}
var _panel = 1;
function changePanel() {
    _panel++;
    if (_panel > 5) _panel = 1;
    showPanel(_panel);
}

function showPanel(p) {
    _panel = p;
    var _prevpanel = p-1;

    if (_prevpanel <= 0) _prevpanel = 5;
    new Effect.Opacity('panel_'+_prevpanel, {from: 1.0, to: 0.0, duration: 0.1});
    $('panel_'+ _prevpanel).style.display = 'none';
    $('panel_'+_panel).style.display = 'block';
    new Effect.Opacity('panel_'+ _panel, {from: 0.5, to: 1.0, duration: 0.5});
    if (p == 4) setTimeout(changePanel, 10000);
    else setTimeout(changePanel, 7000);
}
