Page = {
	initialize: function(){
		if(Globals.isIE())Page.activateEmbedObjects();
		rollover.init();
	}
}

Page.activateEmbedObjects = function(){
	var obj = document.getElementsByTagName('object');
	for(i=0; i<obj.length; i++)obj[i].outerHTML = obj[i].outerHTML;
}


rollover = {
	root: null,
	d: null,
	a: null,
	c: null,
	currentDiv: null,
	currentLink: null,
	bg: null,
	over: false
}

rollover.init = function(){
	with(rollover){
		root = document.getElementById('tpl-page');
		d = document.getElementById('tpl-navigation');
		a = d.getElementsByTagName('ul')[0].getElementsByTagName('a');
		c = Globals.getElementsByClassName('NaviRollOver');
		
		for(k=0; k<a.length; k++){
			a[k].onmouseover = rollover.mouseover;
			a[k].onmouseout = rollover.mouseout;
		}
		
		if(_d = document.getElementById('tpl-start-navigation')){
			if(_a = _d.getElementsByTagName('ul')[0].getElementsByTagName('a')) {
				for(k=0; k<_a.length; k++){
					if(_a[k].id!="sel") {
						_a[k].onmouseover = function(){
							for(i=0;i<_a.length;i++)if(_a[i]==this)break;
							var n = i/(_a.length-1);
							var src = n>0 && n<1 ? '' : n;
							this.style.background = 'url(fileadmin/raulestiftung/img/templates/start_navi_over_'+src+'.jpg) no-repeat';
						}
						
						_a[k].onmouseout = function(){
							for(i=0;i<_a.length;i++)if(_a[i]==this)break;
							var n = i/(_a.length-1);
							var src = n>0 && n<1 ? '' : n;
							this.style.background = 'url(fileadmin/raulestiftung/img/templates/start_navi_out_'+src+'.jpg) no-repeat';
						}
						
						for(i=0;i<_a.length;i++)if(_a[i]==_a[k])break;
						var n = i/(_a.length-1);
						var src = n>0 && n<1 ? '' : n;
						_a[k].style.background = 'url(fileadmin/raulestiftung/img/templates/start_navi_out_'+src+'.jpg) no-repeat';
					} 
					else {
						for(i=0;i<_a.length;i++)if(_a[i]==_a[k])break;
						var n = i/(_a.length-1);
						var src = n>0 && n<1 ? '' : n;
						_a[k].style.background = 'url(fileadmin/raulestiftung/img/templates/start_navi_over_'+src+'.jpg) no-repeat';
					}
				}
			}
		}
	}
}

rollover.mouseover = function(e){
	with(rollover){
		
		for(i=0;i<a.length;i++)if(a[i]==this)break;
		currentLink = this;
		
		var n = i/(a.length-1);
		var src = n>0 && n<1 ? '' : n;
		this.style.background = bg = 'url(fileadmin/raulestiftung/img/templates/link_over_'+src+'.jpg) no-repeat 1px';
		
		if(rollover.currentDiv = c[i]){
			var $ = Globals.getStyle(c[i]);
			
			var w = parseInt(Globals.getStyle(this).width); // NaviElement-Breite eines Links
			var over = parseInt($.width);
			if(navigator.userAgent.indexOf('MSIE 5')<0)over+=parseInt($.paddingLeft); //mouseOver-Div Breite
			var max = a.length*w-over;
			var pos = w*i+(w-over)/2;
			
			pos = pos<0 ? 0 : pos>=max ? max : pos;
			
			c[i].style.display = 'block';
			c[i].style.left = pos+'px';
			
			c[i].onmouseover = function(){
				with(rollover)currentLink.style.background=bg;
				this.style.display = 'block'
			};
			c[i].onmouseout = function(){
				with(rollover)currentLink.style.background='none';
				this.style.display = 'none'
			};
		}
	}
}

rollover.mouseout = function(){
	with(rollover){
		for(l=0; l<c.length; l++){
			c[l].style.display = 'none';
			a[l].style.background = 'none';
		}
	}
}
