
	$(document).ready(function()
	{
	   swfobject.embedSWF('/swf/header.swf', 'header_visual_replace_me', '960', '140', '8.0.0', null, { home: '1' });
	
		//	SHOW/HIDE STAF FORM
		
		$('#showStaf').click(function(){
			$.nvsOverlay.show({speed: 1000, transparancy: 0.60 }); 
			$.nvsPopup.show();

			$('#nvs_popup').html($('#staf').html());
			
			replaceSubmitButton(".frm-staf");
			
			$('#nvs_popup .close').click(function()
			{
				$('#nvs_popup_container').fadeTo('fast', 0).remove();
				$.nvsOverlay.hide();
				$('#nvs_popup_container').remove();
				
				return false;
			});
			
			$('.frm-staf .sbmt_replaced').click(function(){
				$(this).parents('form').submit();
			});
			
			// SUBMIT AND VALIDATE THE FORM
			
			$('.frm-staf').submit(function()
			{	
				// validate empty fields
				$("input[value='']", this).addClass('error');
				$("input[value!='']", this).removeClass('error');

				// validate email fields
				if (!validateEmail($("input[name='staf_email']", this)))
				{
					$("input[name='staf_email']", this).addClass('error');
				}
				else
				{
					$("input[name='staf_email']", this).removeClass('error');
				}
				
				if (!validateEmail($("input[name='staf_relatie_email']", this)))
				{
					$("input[name='staf_relatie_email']", this).addClass('error');
				}
				else
				{
					$("input[name='staf_relatie_email']", this).removeClass('error');
				}

				// do not continue with errors
				if ($("input", this).hasClass('error')) return false;

				poststr = $('.frm-staf').serialize();
				
				$.ajax(
				{
					type: 'POST',
					url: '/ajax/staf.ajax.php',
					data: poststr,
					success: function(msg)
					{
 						$('#nvs_popup div').css({ display: 'none' });
						$('#nvs_popup .success').fadeIn();
					}
				});

				return false;


			});
			
			return false;

		});
		
		
		//	JAVASCRIPT HIDE / SHOW ELEMENTS
		//	HIDE FUNCTION
		
		$('.hide').css({ display: 'none' });
		
		// SHOW 'FUNCTION'
		
        // JB: Functie werkt niet fijn (plaats op de kaart bepaling in IE) 
		//$('#property-overview').css({ display: 'block' });
		
		
		
		
		//	REPLACE SUBMIT BUTTONS
		
		replaceSubmitButton(".frm-newsletter");

		
		//	SHOW NAV META (STAF + PRINT)
		
		$('.nav-meta').css({ display: 'block' });
		
		if(window.print){
			$('.nav-meta #showPrint').click(function(){ window.print(); return false; });
		}
		
		
		//	EXTERNAL LINKS: USE rel=external
		
		$('a[@rel$=external]').click(function()
		{
			this.target = '_blank';
		})
		.addClass('external');
		
		// JAAR SELECTEREN NIEUWSARCHIEF
		
		$('#nieuwsarchief-select-jaar').change(function()
		{	
			$('#nieuwsarchief-select-form').submit();
		});
		
	});
	
	
	//	FUNCTION FOR REPLACING SUBMIT BUTTONS WITH TEXT
	/*
	function replaceSubmitButton(button)
	{
		if ($(button).length > 0)
		{
			$(button).replaceWith(
				$('<a></a>').html($(button).val()).click(function()
				{
					$(this).parents('form').submit();
				})
				.addClass('sbmt_replaced')
			);
		}
	}
	*/
	function replaceSubmitButton(obj)
    {
        var obj = $(obj);
   
        if (obj.length > 0)
        {
            $("input[type='submit']", obj).replaceWith(
                $('<a></a>').html($("input[type='submit']", obj).val()).click(function()
                {
                    obj.submit();
                })
                .addClass('sbmt_replaced')
            );
           
            $('input,select', obj).keypress(function(e)
            {
                if (e.which == 13)
                {
                    obj.submit();
                }
            });
        }
    }

	
	/* FUNCTION FOR VALIDATING EMAIL */
	
	function validateEmail(elm)
	{
		regexp_mail = /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		return regexp_mail.test($(elm).val());
	}


