$("#telephone").bind('click',function(){
	$(this).val('');
	$("#telephone").unbind('click');
});

$("#email").bind('click',function(){
	$(this).val('');
	$("#email").unbind('click');
});

$("#voornaam").bind('click',function(){
	$(this).val('');
	$("#voornaam").unbind('click');
});

$("#tussenv").bind('click',function(){
	$(this).val('');
	$("#tussenv").unbind('click');
});

$("#achternaam").bind('click',function(){
	$(this).val('');
	$("#achternaam").unbind('click');
});

$("#afspraak-maken").bind('click',function(){
	$('#standard-view').fadeOut(400, function(){
		$('#afspraak-view').fadeIn();
	});
});

$("#aanmelden-nieuwsbrief").bind('click',function(){
	$('#standard-view').fadeOut(400, function(){
		$('#nieuwsbrief-view').fadeIn();
	});
});
	

$(".checkbox").bind('click', function(){
	var value = $(this).attr('id');
	if($("#adres").val() != value){
		$(".checkbox").attr('src','/img/checkbox_false.png');
		$(this).attr('src','/img/checkbox_true.png');
		$("#adres").val(value);
		$("#sex").val(value);
	}
});

$('.close').bind('click', function(){
	if($('#nieuwsbrief-view').is(":visible")){
		$('#nieuwsbrief-view').fadeOut(400, function(){
			$('#standard-view').fadeIn();
		});
	} else {
		$('#afspraak-view').fadeOut(400, function(){
			$('#standard-view').fadeIn();
		});
	}
});

var busy = false;
var HomeTimeInterval = 5000;

$(window).resize(resizeIt);

function resizeIt() {
	if ($.browser.msie && parseInt($.browser.version) == 6) {
		$("#photo_overview").width($("#container").width()-240);
		$("#photo_container").width($("#container").width()-240);
		
	} else 
	if ($.browser.msie && parseInt($.browser.version) == 8) {
		$("#photo_overview").width($("#container").width()-240);
	} else 
	if ($.browser.msie && parseInt($.browser.version) == 7) {
		$("#photo_overview").width($("#container").width()-240);
		$("#photo_container").width($("#container").width()-240);
	} else {
		$("#photo_overview").width($("#container").width()-240);
	}
}
resizeIt();

var moveHome = setTimeout(goRight, HomeTimeInterval);
$('#arrow-right').bind('click', goRight);

function goRight(e){
	clearTimeout(moveHome);
	moveHome = setTimeout(goRight, HomeTimeInterval);
	if(!busy){
		busy = true;
		$('#photos_canvas').animate({marginLeft: - $('#photos_canvas :last').attr('width')},0);
		$('#photos_canvas').prepend($('#photos_canvas :last'));
		$('#photos_canvas').animate({marginLeft:0},1000, function(){
			busy = false;
		});
	}
}

$('#arrow-left').bind('click', function(){
	clearTimeout(moveHome);
	moveHome = setTimeout(goRight, HomeTimeInterval);
	if(!busy){
		busy = true;
		$('#photos_canvas').animate({marginLeft: - $('#photos_canvas :first').attr('width')},1000, function(){
			$('#photos_canvas').append($('#photos_canvas :first'));
			$('#photos_canvas').animate({marginLeft:0},0);
			busy = false;
		});
	}
});
