var doNavigation;
var currentPageVar	= 1;
var elementShow		= new Array;

var ajax_method		= "post";

function changePage ( page, manual ) {
	if ( page < 1 )
		page = 1;
	if ( page > 5 )
		page = 5;
	
	if ( page == 1 && elementShow.length < 1 )
		document.getElementById ( 'topTXT' ).style.display	= 'block';
	else
		document.getElementById ( 'topTXT' ).style.display	= 'none';

	if ( document.getElementById ( 'page' + currentPageVar ) )
		document.getElementById ( 'page' + currentPageVar ).className	= 'squars';
	
	currentPageVar = page;
	
	if ( document.getElementById ( 'page' + currentPageVar ) )
		document.getElementById ( 'page' + currentPageVar ).className	= 'squarshover';
	
	var vragenBegin	= vragenPP * ( page - 1 );
	var vragenEnd	= vragenPP * page;
	
	for ( var i = 1; i <= vragenTotaal; i++ ) {
		if ( ( elementShow.length < 1 && i > vragenBegin && i <= vragenEnd ) || elementShow [ i ] == 1 )
			document.getElementById ( 'vraagAlinea_' + i ).style.display	= 'block';
		else
			document.getElementById ( 'vraagAlinea_' + i ).style.display	= 'none';
	}
	
	if ( page == 5 || elementShow.length > 0 || elementShow [ 9999 ] == 1 ) {
		document.getElementById ( 'vraagAlinea_gegevens' ).style.display		= 'block';
	}
	else {
		if ( doNavigation ) {
			document.getElementById ( 'vraagAlinea_gegevens' ).style.display	= 'none';
		}
	}
	
	if ( manual == 1 )
		window.scrollTo ( '0', 150 );
}

function getAddress ( ) {
	var postcode1	= $( 'postcode1' ).value;
	var postcode2	= $( 'postcode2' ).value;
	var huisnummer	= $( 'huisnummer' ).value;
	
	with ( $( 'straat' ) ) {
		value		= "";
		readOnly	= false;
	}
	with ( $( 'plaats' ) ) {
		value		= "";
		readOnly	= false;
	}
	
	if ( postcode1.match ( /^[1-9]{1}[0-9]{3}$/ ) && postcode2.match ( /^[a-zA-Z]{2}$/ ) && huisnummer != "" ) {
		new Ajax.Request ( "/enquetes/ajax/adresprefill.php",
			{
				method:		ajax_method,
				
				parameters:	{
					postcode1:	postcode1,
					postcode2:	postcode2,
					huisnummer:	huisnummer
				},
				
				onComplete:	function ( transport, json ) {
					if ( json [ 'straat' ]  ) {
						with ( $( 'straat' ) ) {
							value		= json [ 'straat' ];
							readOnly	= true;
						}
					}
					if ( json [ 'woonplaats' ] ) {
						with ( $( 'plaats' ) ) {
							value		= json [ 'woonplaats' ];
							readOnly	= true;
						}
					}
				}
			}
		);
	}
}

/*
 * add the dynamic image in the div
 */
function addDynamicImg(img,left,top){
	img = img.stripTags();
	img = img.stripScripts();
	
	dynamicImgCon = true;
	
	$('dynamicImg').writeAttribute('src', img);
	$('dynamicImgCon').setStyle({
		left: left+'px',
		top: top+'px'
	});
	
	$('dynamicImgCon').show();
}

function addDefaultImg(img,left,top){
    img = img.stripTags();
	img = img.stripScripts();

	dynamicImgCon = true;

	$('dynamicImg').writeAttribute('src', img);

    $('dynamicImgCon').addClassName('noCon');

	$('dynamicImgCon').setStyle({
		left: left+'px',
		top: top+'px'
	});

	$('dynamicImgCon').show();
}
