<!--
loaded = false;

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Utilities

function preload(objname,imgsrc){
	eval(objname+' = new Image()');
	eval(objname+'.src = "'+imgsrc+'"');
}
function imgSwap(imgname,imgobj,divnames){
	if(document.layers && divnames != null){
		divnames = divnames.split(',');
		var d = '';
		for(var i=0; i<divnames.length; i++){
			d += 'document.'+divnames[i]+'.';
		}
		eval(d+'document.images["'+imgname+'"].src = '+imgobj+'.src');
	}else{
		document.images[imgname].src = eval(imgobj+'.src');
	}
}
function setStatus(msg){
	window.status = msg;
	return true;
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Detect Constructor

Detect = function() {
	var agent = navigator.userAgent.toLowerCase(); 
	this._mac = agent.indexOf('mac') != -1;
	this._win = !this._mac;
	this._w3c = document.getElementById;
	this._iex = document.all;
	this._ns4 = document.layers;
}
Detect.prototype.getObj = function(name){
	if(this._w3c){
		return document.getElementById(name);
	}else if(this._iex){
		return document.all[name];
	}else if(this._ns4){
		return this.getObjNS4(document,name);
	}
}
Detect.prototype.getObjNS4 = function(obj, name){
	var d = obj.layers;
	var result,temp;
	for(var i=0; i<d.length; i++){
		if(d[i].id == name){
		 	result = d[i];
		}else if(d[i].layers.length){
			var temp = this.getObjNS4(d[i],name);
		}
		if(temp){
			result = temp;
		}
	}
	return result;
}
Detect.prototype.getStyle = function(obj){
	return (this._ns4) ? obj : obj.style;
}
Detect.prototype.getWindowWidth = function(){
	return this._iex ? document.body.clientWidth : window.innerWidth;
}
Detect.prototype.getWindowHeight = function(){
	return this._iex ? document.body.clientHeight : window.innerHeight;
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// MakeDiv Constructor --> inherit from Detect

MakeDiv = function(name){
	if(name){
		this._inherit = Detect; this._inherit(name);
		this._id  = name;
		this._el  = this.getObj(this._id);
		this._css = this.getStyle(this._el);
		this._obj = name+'Object'; eval(this._obj+'=this');
		this._timer = null;
		this._tweenRunning = false;
		return this;
	}
}
MakeDiv.prototype = new Detect();

MakeDiv.prototype.getLeft = function(){
	return parseInt(this._css.left || 0);
}
MakeDiv.prototype.getTop = function(){
	return parseInt(this._css.top || 0);
}
MakeDiv.prototype.getWidth = function(){
	if(this._ns4){
		 return this._el.document.width;
	}else{
		return this._el.offsetWidth;
	}
}	
MakeDiv.prototype.getHeight = function(){
	if(this._ns4){
		 return this._el.document.height;
	}else{
		return this._el.offsetHeight;
	}
}
MakeDiv.prototype.moveTo = function(x,y){
	if(this._ns4){
		this._el.moveTo(x,y);
	}else{
		this._css.left = x;
		this._css.top  = y;
	}
}
MakeDiv.prototype.tweenTo = function(method, start, distance, _time, timer){
		if(!this._tweenRunning){
		this._tweenTime = 0;
		var s = '['+start.toString()+']';
		var d = '['+distance.toString()+']';
		//sec 
		if((timer == null) || (timer==0)) timer=1; 
		this._timer = setInterval(this._obj+'.tweenTo('+method+','+s+','+d+','+_time+','+timer+')', timer); //sec
		this._tweenRunning = true;
	}
	if(++this._tweenTime > _time){
		this.clearTween();
	}else{
		var x = method(this._tweenTime, start[0], distance[0], _time);
		var y = method(this._tweenTime, start[1], distance[1], _time);
		this.moveTo(x,y);
	}
}
MakeDiv.prototype.clearTween = function(){
	clearInterval(this._timer);
	this._timer = null;
	this._tweenRunning = false;
}
easeOutQuad = function(t, b, c, d){
	t /= d;
	return -c * t*(t-2) + b;
}
easeOutExpo = function(t, b, c, d){
	return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b;
}

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// MenuDiv Constructor --> inherit from MakeDiv

MenuDiv = function(name){
	if(name){
		this._inherit = MakeDiv; this._inherit(name);
		this._basex = this.getLeft();
		this._basey = this.getTop();
	}
}
MenuDiv.prototype = new MakeDiv();

// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Open Menu Functions

function showMenu(num, timer){
	if (num<=menuLen)
	if(loaded){
		curMenu = (curMenu==num) ? 0 : num;
		clearTimeout(subtimer);
		subtimer = null;
		if(curMenu != 0){
			var subHeight = eval('API.s'+num).getHeight();
			subtimer = setTimeout('showSub('+num+', '+timer+')', timer); //sec  time before showing sub
		}
		for(var i=1; i<=menuLen; i++){
			imgSwap('i'+i, 'i'+i+'_off', 'navigation, n'+i);
			var ymove = (i<=num || curMenu==0) ? 0 : subHeight;
			var n = eval('API.n'+i);
			var s = eval('API.s'+i);
			var sx = n._basex;
			var sy = n.getTop();
			var dx = 0;
			var dy = (n._basey-n.getTop())+ymove;
			n.clearTween();
			if((timer == null) || (timer==0)) {timer=1;timer2=1;}
			else {timer2=timer; }
			n.tweenTo(easeOutExpo, [sx,sy], [dx,dy], timer2, timer); //sec
			s.clearTween();
			s.moveTo(s._basex, s._basey);
		}
	}
}
function showSub(num, timer){
	var s = eval('API.s'+num);
	var sx = s.getLeft();
	var sy = s._basey;
	var dx = s.getWidth();
	var dy = 0;
	s.clearTween();
	if((timer == null) || (timer==0)) { timer=1;timer2=1; }
	else timer2=timer;
	
	s.tweenTo(easeOutQuad, [sx,sy], [dx,dy], timer2, timer); //sec
	imgSwap('i'+num, 'i'+num+'_on', 'navigation, n'+num);
}


// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Preload navigation images

var dir = template_images_lang_path;

preload('i1_off', dir+'nav_iist_off.gif');
preload('i2_off', dir+'nav_aips_off.gif');
preload('i3_off', dir+'nav_aisr_off.gif');
preload('i4_off', dir+'nav_contact_off.gif');

preload('i1_on', dir+'nav_iist_on.gif');
preload('i2_on', dir+'nav_aips_on.gif');
preload('i3_on', dir+'nav_aisr_on.gif');
preload('i4_on', dir+'nav_contact_on.gif');
var MAXMENU=5;
// Build the navigation, called onload

function createObjects(cur){
	menuLen = 4; // the number of top level menu links. Not zero based
	curMenu = 0;
	subtimer = null;
	API = new Detect();
	
	// Create 'MenuDiv' objects
	API.navigation = new MenuDiv('navigation');
	for(var i=1; i<=menuLen; i++){
		eval('API.n'+i+' = new MenuDiv("n'+i+'")');
		eval('API.s'+i+' = new MenuDiv("s'+i+'")');
	}
	// objects created, scripts can now be called
	loaded = true;

	// a menu can be forced open onload by passing it's id number in as an argument
	
	if(cur != null){
		showMenu(cur,1);
	}	
}
//-->