var timeOut = 15;
var width1 = 0;
var width2 = 630;
var clickable = 1;

/*
- Data ophalen
- div vullen
- div plaatsen
- scrollen
- id swappen

*/

function scroll_editorial() {
		var edit1 = $('editorial1');
		var edit2 = $('editorial2');

	if (width2==0) {
		$('editorial2').id='editorial3';
		$('editorial1').id='editorial2';
		$('editorial3').id='editorial1';
		if (timer) clearTimeout(timer);	
		clickable = 1;
	} else {
	
		if (direction=='next') {
			width1-=10;
			width2-=10;
		} else {
			width1+=10;
			width2+=10;
		}
		
		edit1.style.left = width1+'px';	
		edit2.style.left = width2+'px';
		
		timer = setTimeout('scroll_editorial()', timeOut);
		clickable = 0;
	}
}


var direction;

function move_editorial(direc) {
	
	
	if (clickable==1) {	
		direction = direc;
		
		if(direc=='next') {
			currentkey++;	
		}
		
		if(direc=='prev') {
			currentkey--;	
		}
		
		
	
		if(currentkey==0) {
			$('prev_button').style.display='none';	
		} else {
			$('prev_button').style.display='block';	
		}
		
		if(currentkey==editorids.length-1) {
			$('next_button').style.display='none';	
		} else {
			$('next_button').style.display='block';	
		}
	
		var url = '/extra/editorial/'+editorids[currentkey];
	
		new Ajax.Request(	url, { 
				method: 'get',
				parameters: '',
				onComplete: show
			}
		);
	}
}

function show(data) {
	$('editorial2').innerHTML = data.responseText;

	if (direction=='next') {
		$('editorial2').style.left = '630px';
		width1 = 0;
		width2 = 650;
	} else {
		$('editorial2').style.left = '-630px';
		width1 = 0;
		width2 = -650;
	}
	
		var divH = document.getElementById('editorial2').offsetHeight;
		$('contentdiv1').style.height=(divH+20)+'px';
		$('contentdiv2').style.height=divH+'px';
		//$('buttons').style.marginTop=(divH+15)+'px';
	
	scroll_editorial();
}

function init_editorial() {
		var divH = document.getElementById('editorial1').offsetHeight;
		$('contentdiv1').style.height=(divH+20)+'px';
		$('contentdiv2').style.height=divH+'px';
		//$('buttons').style.marginTop=(divH+15)+'px';	
}
