var position = 0;
var max = 4;
function auto_play() {
	  setTimeout(continue_play,6000);
}
function continue_play() {
	
		if ((position + 1)>=max) {
			 setTimeout(reset,2000);
		} else {
			move_right();
			setTimeout(continue_play,4000);
		}
	
}
function reset() {
	$('#banner_' + position).fadeOut(2000);	
	$('#banner_0').fadeIn(2000);	
	position = 0;
	auto_play();
}

function move_right() {
		if ((position+1) < max) {
			$('#banner_' + position).fadeOut(2000);
			$('#banner_' + (position+1)).fadeIn(2000);	
			position++;
		} else {
			$('#banner_' + position).fadeOut(2000);
			$('#banner_' + (position-1)).fadeIn(2000);
			position = 0;
		}

}




function getAge(birthDate) {
  var now = new Date();
  now.setMonth(now.getMonth()+1);
  

  function isLeap(year) {
    return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
  }

  // days since the birthdate    
  var days = Math.floor((now.getTime() - birthDate.getTime())/1000/60/60/24);

  var age = 0;
  // iterate the years
  for (var y = birthDate.getFullYear(); y <= now.getFullYear(); y++){
    var daysInYear = isLeap(y) ? 366 : 365;
    if (days >= daysInYear){
      days -= daysInYear;
      age++;
      // increment the age only if there are available enough days for the year.
    }
  }
  return age;
}


