var scrollStart = 0;

// scroll in div (overflow=hidden)
function moveTo(container, move) {
	
	if (scrollStart == 0) {
	
		// Current div put 1 to default
		if(!location.hash)
		{
			var div = 1;
		} 
		else
		{
			var div = location.hash;
			div = div.replace('#', '');
			div = parseInt(div);
		}
	
		var next	= 0;
		var proceed = true;
		var element = null;
		
		if (move > 0) {
			next = div + 5;
			if ($(container + '-' + next) === null) {
				next = div + 4;
				move = move - 1;
				if ($(container + '-' + next) === null) {
					next = div + 3;
					move = move - 1;
					if ($(container + '-' + next) === null) {
						proceed = false;
					}
				}
			}
				
		} else if (move < 0) {
			next = div - 3;
			if ($(container + '-' + next) === null) {
				next = div - 2;
				move = move + 1;
				if ($(container + '-' + next) === null) {
					next = div - 1;
					move = move + 1;
					if ($(container + '-' + next) === null) {
						proceed = false;
					}
				}
			}
				
		}
	
		if (proceed === true) {	
			var width = -195 * move;
			div += move;
			location.hash = div;
			new Effect.Move ($('list-cases'),{ x: width, y: 0, mode: 'relative', afterFinish: stopScroll, beforeStart: startScroll});
			if (move > 0) {
				$('buttonPrev').style.display = 'block';
				var ndiv = div + 3;
				if ($(container + '-' + ndiv) === null)
					$('buttonNext').style.display = 'none';
			} else {
				$('buttonNext').style.display = 'block';
				var ndiv = div - 1;
				if ($(container + '-' + ndiv) === null)
					$('buttonPrev').style.display = 'none';
			}
		}
	}	
}

function goTo() {
	if(location.hash)
	{
		var num = location.hash;
		num = num.replace('#', '') - 1;
		
		var space = num * -195;
		new Effect.Move ($('list-cases'),{ x: space, y: 0, mode: 'relative'});
		
		if (num > 0)
			$('buttonPrev').style.display = 'block';
			
		var ndiv = num + 4;
		if ($('case-' + ndiv) === null)
			$('buttonNext').style.display = 'none';
			
		
	  	div = num;
	}
}

function startScroll() {
	scrollStart = 1;
}

function stopScroll() {
	scrollStart = 0;
}

function loadFlash(name, width, height) {
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" style="z-index: -1;" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="wplusr" align="middle" style="margin: 0; padding: 0;">');
  document.write('<param name="allowScriptAccess" value="sameDomain" />');
  document.write('<param name="movie" value="'+name+'" />');
  document.write('<param name="menu" value="false" />');
  document.write('<param name="quality" value="best" />');
  document.write('<param name="wmode" value="transparent" />');
  document.write('<param name="bgcolor" value="#ffffff" />');
  document.write('<embed src="'+name+'" menu="false" wmode="transparent" style="z-index: -1;" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="clearscreen" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="margin: 0; padding: 0;" />');
  document.write('</object>');
}

function Subscribe() {

	var error = null;
	
	if ($('input-voornaam').value == '') {	
		error = true;
		$('label-voornaam').style.color = '#b70000';
	} else {
		$('label-voornaam').style.color = '#515151';
	}
	
	if ($('input-achternaam').value == '') {	
		error = true;
		$('label-achternaam').style.color = '#b70000';
	} else {
		$('label-achternaam').style.color = '#515151';
	}
	
	if (!checkEmail($('input-email').value)) {	
		error = true;
		$('label-email').style.color = '#b70000';
	} else {
		$('label-email').style.color = '#515151';
	}
	
	if (error === null)
		document.subscribe.submit();
}

function Unsubscribe() {

	var error = null;
	
	if (!checkEmail($('input-email2').value)) {	
		error = true;
		$('label-email2').style.color = '#b70000';
	} else {
		$('label-email2').style.color = '#515151';
	}
	
	if (error === null)
		document.unsubscribe.submit();
}

function checkEmail(email) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email))
		return false;		
	return true;
}

var cur = 1;

function scrollTo() {
	
	var next	= 0;
	var proceed = true;
	var element = null;
	var move    = -1;
	
	next = cur + 1;
	if ($('case-' + next) === null) {
		move = $('list-cases').getElementsByTagName('li').length - 1;		
		next = 1;
	}

	if (proceed === true) {	
		var width = 300 * move;
		cur = next;
		new Effect.Move ($('list-cases'),{ x: width, y: 0, mode: 'relative'});
	}
	
}

function initScroll() {
	setInterval('scrollTo()', 6000);
}
