function initajaxes() {
    jQuery("a.ajax").live("click", function (event) {
        event.preventDefault();
        jQuery.get(this.href);
        jQuery("#ajax-spinner").show().css({
          position: "absolute",
          left: event.pageX + 20,
          top: event.pageY + 40
        });
      });
      
    jQuery(".toggle-button").live("click", function (event) {
        event.preventDefault();
        jQuery(event.target).parent().children('.toggle-box').toggle();
        jQuery(event.target).parent().parent().children('.toggle-fadebox').fadeToggle("fast","linear");
    });
      
}


function birthdaystaturary () {
      da = new Date();
      y = jQuery('#frm-birthday').children('.byear').attr('value');
      m = jQuery('#frm-birthday').children('.bmonth').attr('value');
      d = jQuery('#frm-birthday').children('.bday').attr('value');
      try {
        db = new Date(
          (y=='' ? 1900 : y),
          (m=='' ? 12 : m-1),
          (d=='' ? 28 : d));
      }
      catch (err) {
        db = new Date('1900');  
      }
//      alert(db);
//      alert(da.isBefore(db.add('y',18)));
      res = da.isBefore(db.add('y',18));
      jQuery('#statutary-box').toggle(res);
      jQuery('input[id=frm-statutary]').attr('checked',res);
};

jQuery(document).ready(function(){
/*  jQuery('.edit-helper').bind('focus',function(){
    var val1 = jQuery(this).attr('title');
    var val2 = jQuery(this).attr('value');
    if(val1==val2) {
      jQuery(this).attr('value', '');
      jQuery(this).toggleClass('edit-helper-edit', true);
    } 
  });
  jQuery('.edit-helper').bind('blur',function(){
    var val1 = jQuery(this).attr('title');
    var val2 = jQuery(this).attr('value');
    if(val2=='') {
      jQuery(this).attr('value', val1);
      jQuery(this).toggleClass('edit-helper-edit', false);
    }
  });*/


  jQuery('.bday').bind('change',birthdaystaturary);
  jQuery('.bmonth').bind('change',birthdaystaturary);
  jQuery('.byear').bind('change',birthdaystaturary);
  
/*  jQuery('#frm-birthday').bind('blur',function(){
     if(Date.isValid(jQuery(this).attr('value'),'d.M.yyyy')) {
        db = Date.parseString(jQuery(this).attr('value'),'d.M.yyyy');
        da = new Date();
        jQuery('#statutary-box').toggle(da.isBefore(db.add('y',18)));
     }
     else {
       alert('Neplatné zadání data narození!');
//       jQuery('#frm-birthday').focus();
     }
     
  });*/

  birthdaystaturary();
  
/*  if (jQuery('#frm-birthday')) {
    if(Date.isValid(jQuery('#frm-birthday').attr('value'),'d.M.yyyy')) {
      db = Date.parseString(jQuery('#frm-birthday').attr('value'),'d.M.yyyy');
      da = new Date();
      jQuery('#statutary-box').toggle(da.isBefore(db.add('y',18)));
    }
    else
      jQuery('#statutary-box').toggle(false);
  }  */
})
