function anim(i){
	this.initted=false;
	this.timeout=false;
	this.start(i);
}
anim.prototype={
init:function(i){
	var x,ct;
	this.images=[];
	for(x=0,ct=i.length;x<ct;x++){
		this.images[x]=new Image();
		this.images[x].src='/headimage.nb?nb%5Bid%5D='+i[x];
	}
},
step:function(){
	var obj=this;
	this.image++;
	if(this.image==this.images.length){
		this.image=0;
	}
	this.next=this.frame;
	this.frame=1-this.frame;
	this.frames[this.frame].css('zIndex',3);
	this.frames[this.next].css('zIndex',2);
	this.frames[this.frame].empty();
	this.frames[this.frame].append(this.images[this.image]);
	this.frames[this.frame].fadeIn(2000,function() { obj.frames[obj.next].hide(); });
	this.timeout=setTimeout(function(){ obj.step(); },5000);
},
stop:function(){
	if(this.timeout) {
		clearTimeout(this.timeout);
		this.timeout=false;
		this.frames[this.next].hide();
		this.frames[this.frame].hide();
	}
},
start:function(i){
	if(!this.initted) {
		this.initted=true;
		this.init(i);
	}
	var obj=this;
	this.image=0;
	this.frame=1;
	this.next=0;
	this.frames=[];
	this.frames[0]=$('<div/>');
	this.frames[1]=$('<div/>');
	var l=$('div#header');
	$.each(this.frames,function(j) {
		this.addClass('flash');
		this.appendTo(l);
	});
	this.frames[1].css('zIndex',3);
	this.frames[0].css('zIndex',2);
	this.frames[1].append(this.images[0]);
	this.frames[0].hide();
	if(this.images.length>1) {
		this.timeout=setTimeout(function(){ obj.step(); },3000);
	}
}
}
function treeview() {
	if (document.getElementById) {
		this.c=document.getElementById('treeview');
		var s=[],sp=0,x,ct,e=this.c.childNodes,obj=this;
		if (/#[_0-9]+$/.test(document.location.href)) {
			s=document.location.href; s=s.substr(s.indexOf('#')+1);
			s=s.split('_');
		}
		this.active = false;
		for (x=0,ct=e.length; x<ct; x++) {
			if (e[x].childNodes.length>1) {
				e[x].onmouseover=function() {
					this.className='h';
				}
				e[x].onmouseout=function() {
					this.className='';
				}
				e[x].onclick=function(e) {
					obj.catclick(e,this);
				}
				e[x].style.cursor=/MSIE 5/.test(navigator.userAgent)?'hand':'pointer';
				e[x].ul = e[x].childNodes[1];
				e[x].handle = false;
				if (s[sp] == x) {
					sp ++;
					e[x].ul.style.display="block";
					this.active = e[x];
				} else {
					e[x].ul.style.display="none";
				}
			}
		}
		e=this.c.getElementsByTagName('a');
		for (x=0,ct=e.length; x<ct; x++) {
			e[x].onclick=function() {
				return obj.linkclick(this);
			};
		}
	}
}
treeview.prototype = {
catclick:function(e,ele) {
	if (document.all) e = window.event;
	if (((e.srcElement?e.srcElement:e.target)==ele) || ((e.srcElement?e.srcElement:e.target)==ele.childNodes[0])) {
		if ((ele.ul.style.display=='block')||(ele.ul.style.display=='inline-block')) {
			ele.ul.style.display='none';
			if (ele.handle) {
				clearInterval(ele.handle);
				ele.handle = false;
			}
			this.active = false;
		} else {
			if (this.active) {
				this.active.ul.style.display = 'none';
			}
			this.active = ele;
			if (navigator.userAgent.indexOf("MSIE") != -1) {
				ele.ul.style.visibility='hidden';
				ele.ul.style.display='inline-block';
				try {
					ele.ul.filters[0].Apply();
					ele.ul.filters[0].Play();
				} catch(e) { }
				ele.ul.style.visibility='visible';
			} else {
				if (ele.handle) {
					clearInterval(ele.handle);
				}
				ele.ul.style.opacity='0';
				ele.ul.style.mozOpacity='0';
				ele.ul.style.display='block';
				ele.fadestart = new Date().getTime();
				var obj = this;
				ele.handle = setInterval(function() {
					obj.fadestep(ele);
				}, 20);
			}
		}
	}
	window._paged.reset();
},
fadestep:function(ele) {
	var c = (new Date().getTime() - ele.fadestart) / 400;
	if (c >= 1) {
		clearInterval(ele.handle);
		ele.handle=false;
		c = 100;
	}
	ele.ul.style.opacity=c;
	ele.ul.style.mozOpacity=c;
},
buildlist:function() {
	var r='',x,ct,e=this.c.childNodes;
	for(x=0,ct=e.length;x<ct;x++) {
		if(e[x].ul && ((e[x].ul.style.display=='block')||(e[x].ul.style.display=='inline-block'))) {
			if (r) r+='_';
			r+=x;
		}
	}
	return r;
},
linkclick:function(ele) {
	var l=this.buildlist();
	if (/#[_0-9]+$/.test(document.location.href)) {
		var s = document.location.href;
		s = s.substr(s.indexOf('#')+1);
		if (s != l) {
			document.location.href="#"+l;
		}
	} else {
		document.location.href="#"+l;
	}
	return true;
}
}

function paged() {
	window._paged=new pagedele($('#text'));
}
function pagedele(ele) {
	this.ele=ele;
	this.reset(true)
}
pagedele.prototype.reset=function(init) {
	ele=this.ele;
	var obj=this;
	if (!init) {
		$('div#padder',ele).remove();
		if (this.up) {
			this.up.remove()
			this.up=false;
		}
		if (this.down) {
			this.down.remove()
			this.down=false;
		}
	}
	this.pagefull=ele.height();
	this.max=ele.get(0).scrollHeight;
	if(this.max>this.pagefull) {
		var o=this.max%this.pagefull;
		this.maxscroll=Math.ceil(this.max/this.pagefull)*this.pagefull-this.pagefull;
		if (o>0) $('<div id="padder" style="height:'+(this.pagefull-o)+'px"></div>').appendTo(ele);
		ele.css({
			overflow:'hidden'
		});
		this.down=$('<div class="scroller">Next ►</div>');
		this.down.css({
			top:(ele.get(0).offsetTop+obj.pagefull+4)+'px',
			left:ele.get(0).offsetLeft+'px'
		});
		this.down.bind('mouseover',function() { $(this).addClass('scrollover'); });
		this.down.bind('mouseout',function() { $(this).removeClass('scrollover'); });
		this.down.bind('click',function() {
			ele.attr({
				scrollTop:ele.scrollTop()+obj.pagefull
			});
			obj.updatebuttons();
		});
		this.up=$('<div class="scroller disabled">Back ◄</div>');
		this.up.css({
			top:(ele.get(0).offsetTop+obj.pagefull+4)+'px',
			left:(ele.get(0).offsetLeft+10)+'px'
		});
		this.up.bind('mouseover',function() { $(this).addClass('scrollover'); });
		this.up.bind('mouseout',function() { $(this).removeClass('scrollover'); });
		this.up.bind('click',function() {
			ele.attr({
				scrollTop:ele.scrollTop()-obj.pagefull
			});
			obj.updatebuttons();
		});
		$('#nav').append(this.down);
		$('#nav').append(this.up);
	}
}
pagedele.prototype.updatebuttons=function() {
	if(this.ele.get(0).scrollTop==0) {
		this.up.addClass('disabled');
	} else {
		this.up.removeClass('disabled');
	}
	if(this.ele.get(0).scrollTop==this.maxscroll) {
		this.down.addClass('disabled');
	} else {
		this.down.removeClass('disabled');
	}
}

