function empty_recursive(el){ $(el).attr('busy', 'y'); $(el).val($(el).val().substring(0, $(el).val().length-1)); if($(el).val() != ''){ setTimeout(function(){ empty_recursive($(el)); }, 2); } else{ $(el).change(); $(el).attr('busy', 'n'); } }
function refill_recursive(el){ $(el).attr('busy', 'y'); $(el).val($(el).attr('defVal').substring(0, $(el).val().length+1)); if($(el).val() != $(el).attr('defVal')){ setTimeout(function(){ refill_recursive($(el)); }, 2); } else{ $(el).change(); $(el).attr('busy', 'n'); } }		

$(function(){
	$('input[type=text], input[type=password], textarea').not('.excl').each(function(){ var c = $(this); if($(this).val().length > 0){ if(!$(this).attr('defVal') || $(this).attr('defVal').length <= 0) $(this).attr('defVal', $(this).val()); if($(this).parents('form').find('input[type=submit]').click(function(){ if(c.val() == c.attr('defVal')) c.val(''); })); $(this).focus(function(){ if($(this).val() == $(this).attr('defVal')){ empty_recursive($(this)); } }); $(this).blur(function(){ if($(this).val() == ''){ refill_recursive($(this)); } }); } });


	
	var prtimers = new Array();
	$('#projecten-list h2').hide().css({top: '-5px', height:'0px'});
	$('#projecten-list h2').each(function(){
		var el = $(this);
		var i = prtimers.length;
		prtimers[i] = setTimeout(function(){
			$(el).show().animate({
				height: 40+'px',
				top: -40+'px'
			}, 500);
		}, i*150);
	});
	
	var ajaxsendformchecksstdcallback = function(correct, error, element){ if(correct){ $(element).removeClass('error'); $(element).parents('.text-input, .textarea').removeClass('error'); } else{ $(element).addClass('error'); $(element).parents('.text-input, .textarea').addClass('error');$(element).parents('form').find('.err').show(); }; $(element).blur(); }
	$('form.mailons').each(function(){
		new ajaxSendForm({
			baseUrl: 	base,
			attachTo: 	$(this),
			succes: 	function(data, attachedTo, url, method){ $(attachedTo).html(data); rcnow(); }
		})		.addCheck('email', 		checkEmail, 	ajaxsendformchecksstdcallback)
				.addCheck('naam', 		checkNonEmpty, 	ajaxsendformchecksstdcallback)
				.addCheck('bericht', 	checkNonEmpty, 	ajaxsendformchecksstdcallback);
	});
	var listAccordion = function(){
		var c = this;
		var list = $('.archief');
		var upTime = 800;
		var downTime = 800;
		this.init = function(){
			list.find('ul').hide();	
			list.find('>li').click(function(){
				$(list).find('>li').removeClass('active');
				list.find('ul').slideUp(upTime);
				$(this).find('ul').slideDown(downTime);
				$(this).addClass('active');
			});
			list.find('>li ul').click(function(e){ e.stopPropagation(); });
			list.find('.active ul').show();
		}
		c.init();
	}
	
	new listAccordion();
	$("a.fancylink").fancybox();
	//$("a.fancylink").fancyZoom({scaleImg: true, closeOnclick: true});
	
	
	$("#browsable").scrollable();
});
