var accel = 10;
var speed = 20;
var s_moving = 0;
var s_moved = 1;
var n_old = -1;

// New stuff
var sections = 4;	// number of sections
var s_height = 160;	// height of total column
var s_margin = 20;	// margin between sections
var fh = Math.floor(s_height/sections);		// Full height
var tpos = new Array();	// Target positions
var timeoutID8 = new Array();
// For NS4
var yoffset = 550;
var xoffset = 303;

function expandSection(n,c){
	c = !c ? 0:c;	// Choose column
	if(c==0){
		ei = 0;	
		esections = sections;
		es_height = s_height;
	}else{
		ei = sections;
		esections = sections2;
		es_height = s_height2;
	}
		
	if(s_moving == 0){
		//if(s_moved!=-1) n=-1;
		
		if(n==-1){
			s_moving = sections;
			// Reset sections to average spacing
			for(i=0;i<sections;i++){
				tpos[i] = i*fh;
				sE(gE("section"+i));
				expandIt(i);
			}

			if(c==1){
				s_moving += sections2;
				for(i=ei;i<(esections+ei);i++){
					tpos[i] = (i-ei)*fh2;
					sE(gE("section"+i));
					expandIt(i);
				}
			}
			s_moved = -1;
		}else{
			s_moving = esections;
			// Expand to show section n
			yy = 0;
			
			// Set background colour
			if(n_old >=0){
				ee= gE('cel'+n_old);
				e = gE('cell'+n_old);
				e.style.backgroundColor='white';
				e.style.border='0px';
				ee.style.border='0px';
				ee.style.backgroundColor='white';
				ee.style.color='#878126';
			}
			
			e = gE('cell'+n);
			ee = gE('cel'+n);
			e.style.backgroundColor='#fffeee';
			ee.style.backgroundColor='#9ba482';
			ee.style.border='1px solid #799427';
			e.style.border='1px solid #799427';
			e.style.borderTop='0px';
			ee.style.borderBottom='0px';
			ee.style.color='#f5fedc';
			n_old = n;

			
			
			hn = gH(gE('section'+n)); 	// Get height of section n
			hn = hn<fh ? fh:hn;			// Don't want to make smaller than the average
			snh = (es_height-hn)/(esections-1);	// Heights of remaining sections
			
			for(i=ei;i<(esections+ei);i++){
				tpos[i] = yy;
				if(i == n) yy+=hn; else yy+=snh;
				expandIt(i);
			}
			s_moved = n;
		}
	}
}

// Expand a certain section
function expandIt(n){
	window.clearTimeout(timeoutID8[n]);
	e = gE('section'+n);	
	y = gY(e);
	
	// Move to a designated position
	dy = tpos[n] - y;
	dya = dy / accel;

	if( dya < 1 && dya > 0) dya = 1;
	if( dya >-1 && dya < 0) dya =-1;
	
	y += dya;		
	
	mL(e,0,y);

	if ( Math.floor(dy) == 0) {
		mL(e,0,tpos[n]);
		s_moving--;
		if(s_moved == -1) expandSection(0);
		return;
	} else {
		timeoutID8[n] = window.setTimeout("expandIt(" + n + ")",speed);
	}
}
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;var ie=d.all?1:0;var w3c=d.getElementById?1:0;
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
function gX(e){if(l){return e.left;}else if(ie){return e.style.pixelLeft;}else{s=getComputedStyle(e,null);return parseInt(s.getPropertyValue('left'));}}
function gY(e){if(l){return e.top;}else if(ie){return e.style.pixelTop;}else{s=getComputedStyle(e,null);return parseInt(s.getPropertyValue('top'));}}
function gW(e){if(l) return e.clip.width; else return e.offsetWidth;}
function gH(e){if(l) return e.clip.height; else return e.offsetHeight;}
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x;}
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y;}
function sW(e,w,m){if(!m)m=0;l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w-m;}
function sH(e,h,m){if(!m)m=0;l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h-m;}
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML)e.innerHTML=h;}
function mL(e,x,y){sX(e,x);sY(e,y);}	// Move layer
function rL(e,w,h,m){if(ie)m=0;sW(e,w,m);sH(e,h,m);}	// Resize layer
function bW(){if(!ie) return window.innerWidth;else return document.body.clientWidth;}
function bH(){if(!ie) return window.innerHeight;else return document.body.clientHeight;}
function rO(n,i,s){e=gE(n);e.src=(s==1)?imgDir+i+"-over.gif":imgDir+i+".gif";}
function sI(n,i){e=gE(n);e.src=imgDir+i+".gif";}
function pI(){d.pli=new Array();var i,j=d.pli.length,a=pI.arguments;for(i=0;i<a.length;i++) if(a[i].indexOf("#")!=0){d.pli[j]=new Image;d.pli[j++].src=a[i];}}

