$(function() {
	$('.back').css({
		cursor:'pointer'
	});
	$('.back').click(function(){
		history.back();
	});
	/*
	$('.slideshow').each(function(){
		var data = eval('('+$(this).attr('ssData')+')');
		$('.ssImage').css({visibility:'visible'});
		$(this).cycle(data);
		$(this).height(data.height);
		$(this).width(data.width);
	});
	*/
	$('#inputEigenBedrag').focus(function() {
		$('#eigenbedrag').attr('checked', true);
	});
	var year = new Date();
	var currentyear = year.getFullYear() - 17;
	firstyear = currentyear - 100;
	$('#inputGeboortedatum').datepicker({
		changeYear: true, 
		changeMonth: true,
		yearRange: ''+firstyear+':'+currentyear+'',
		dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
		dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		dateFormat: 'dd MM yy'		
	});

	var donation = {
		current:1000,
		valid:true
	};

	$('.donationAmount input').keydown(function(e){
		var valid = [8, 46, 37, 38, 39, 40];
		var s = 48;
		if($(this).val() == ''){
			s++;
		}
		for(var i = s; i <= 57; i++){
			valid[valid.length] = i;
			valid[valid.length] = (i+48);
		}
		var found = false;
		for(var i = 0; i < valid.length; i++){
			if(e.which == valid[i]){
				found = true;
				break;
			}
		}
		if(!found){
			return false;
		}
	});

	$('.donationAmount input').keyup(function(e){
		var value = parseInt($(this).val());
		donation.current = value*100;
		donation.valid = false;
		if(value < 3){
			$('.donationWarningWrap').animate({
				height:$('.donationWarning').height()
			},200)
		} else {
			donation.valid = true;
			if($('.donationWarningWrap').height() > 0){
				$('.donationWarningWrap').css({
					height:0
				});
			}
		}
	});

	$('.donationAmount').click(function(){
		$('.donationAmount.current').removeClass('current');
		$(this).addClass('current');
		if($(this).find('input').length > 0){

		} else {
			donation.current = parseInt($(this).attr('id').replace('donate', ''));
			donation.valid = true;
		}
	});

	$('#donateButton').click(function(){
		if(donation.valid === true){
			$.ajax({
				url:'/ajax.php',
				type:'POST',
				data:{
					task:'donate',
					amount:donation.current
				},
				success:function(result){
					
				}
			});
		}
	});
});
