$(document).ready(function(){
	//checks if ESC is pressed, so overlay can be hided
	$(this).keyup(function(e){
		 if(e.keyCode == 27 || e.keyCode == "27"){
			 $('#overlay_all').hide();
			 $(".overlay_message").hide();
		 }
	});
			
	$("#showLogin").click(function(){
		$("#overlay_all").show();
		$("#login_form").css('zIndex', 20000);
		$("#login_form").show();
		return false;
	});	
	
	$(".closePopUp").click(function(){
		$('#overlay_all').hide();
		$(".overlay_message").hide();
	});
	
	$(".makeAppointment").click(function(){
		$("#overlay_all").show();
		$("#overlay_all").html("<div style='background-color:#fff;margin:20px auto; width: 300px; height: 200px;'>afspraak maken</div>")
		return false;
	});
	
	
	//random classes
	$('.randomBoxes').show();
	//get all randomBoxes();
	//randomBoxes = new Array();
	//$(".randomBoxes").each(function(index) {
	//	randomBoxes[index] = $(this);
	//});
	
	//showRandomBox();	
	//console.log(randomBoxes[Math.floor(Math.random()*randomBoxes.length)]);
});
currentIndex = -1;
function showRandomBox() { 
	var newIndex = Math.floor(Math.random()*randomBoxes.length);
	if(currentIndex != newIndex){
		/* not possible Ie bug 
		/*if(randomBoxes[currentIndex] != undefined){
			randomBoxes[currentIndex].fadeOut(400, function() {
				randomBoxes[newIndex].fadeIn(400);
			});
		}else{
			randomBoxes[newIndex].fadeIn(400);
		}*/
		if(randomBoxes[currentIndex] != undefined){
			randomBoxes[currentIndex].hide();
			randomBoxes[newIndex].show();
		}else{
			randomBoxes[newIndex].show();
		}
		currentIndex = newIndex;
		setTimeout('showRandomBox()', 10000);	
	}else{
		showRandomBox();
	} 
}
