(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);		
 
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
 
      var winwidth = $(window).width();
      var winheight = $(window).height();
 
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
 
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
 
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });		
      }
    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };
})(jQuery);

// ration: 5:3
function placebox()
{

	hh = $(window).height();
	$('#age').css({top:(hh-$('#age').width())/2});
}

jQuery(document).ready(function($)
{

	$('#bg').fullBg();
	placebox();
	$(window).resize(placebox);

	
	
	$('#age input[type=text]').focus(function()
	{
		if($(this).val() == 'DD' || $(this).val() == 'MM' || $(this).val() == 'YYYY')
		{ 
			$(this).val('');
		}
	});
	$('#age input#dd').blur(function()
	{
		if($(this).val() == '')
		{ 
			$(this).val('DD');
		}
		else
		{
			$('#mm').focus();
		}
	});
	
	$('#age input#mm').blur(function()
	{
		if($(this).val() == '')
		{ 
			$(this).val('MM');
		}
		else
		{
			$('#yy').focus();
		}
	});
	$('input#yy').blur(function()
	{
		if($(this).val() == '')
		{ 
			$(this).val('YYYY');
		}
	});
});

