$(document).ready(function()
{
	$("a.zoom").fancybox();

	$("a.zoom1").fancybox({
		'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000'
	});

	$("a.zoom2").fancybox({
		'zoomSpeedIn'		:	500,
		'zoomSpeedOut'		:	500,
		'overlayShow'		:	false
	});
	
	
	if ($('div#notLoggedInMessage').size() == 1)
	{
		$('div#notLoggedInMessage')
			.dialog({
                autoOpen: 		false,
				dialogClass:	'roffaLoginMessage',
                buttons: {
				'Inloggen': function() {
					$(this).dialog('close');
					if ($('#roffa_email').size() ==1)
					{
						window.location.href = '#loginFormAnchor';
						$('#roffa_email')[0].focus();
					}
				},
				'Aanmelden': function() {
					$(this).dialog('close');
					window.location.href = '/aanmelden.php';
				}
			}

        });

	}
});

function removeInlineFormErrors(theScope)
{
	// Reset error indicaties
	$('.errorField', theScope)
		.removeClass('errorField');

	$('span.errorDescription', theScope)
		.remove();
	
	$('span.formValidationIcon')
		.removeClass('formFieldValidated formFieldNotValidated')
}

function updateValidationIcon(theField, status)
{
	if ($(theField).prev('span.formValidationIcon').size() == 1)
	{
		$(theField)
			.prev('span.formValidationIcon')
			.addClass(status? 'formFieldValidated': 'formFieldNotValidated');
	}
}

function updateFieldErrorMessage(fieldName, errorMsg)
{
	$('input[name=' + fieldName + '], textarea[name=' + fieldName + '], select[name=' + fieldName + ']').each(function(){
		$('label[for=' + $(this).attr('id') + ']')
			.next('span.errorDescription')
			.remove();
			
		$('<span class="errorDescription">' + errorMsg + '</span>')
			.insertAfter($('label[for=' + $(this).attr('id') + ']'));
	});
	
	
	Cufon('span.errorDescription');
}
