
function load_coppa_lightbox(){
	$j.log('loading COPPA LIGHTBOX behaviors from behaviors/coppa_lightbox.js')
	
	if (load_age_info_lightbox==true) {
		jQuery.jsonhRequest({
      url: '/account/edit_coppa_info',
			type: "get",
      success: function(jsonResponse) {
				jQuery.facebox(jsonResponse.html);
				// hide bottom close
				jQuery("#facebox .footer").attr("style", "display:none;")
				// behaviors
        load_form_behaviors('#facebox_content');
        load_misc_behaviors('#facebox_content');
				loadCoppaFormBehaviors();
      },
			error: function(jsonResponse) {
				jQuery.facebox.close();	
			}
    });
	}
}

function loadCoppaFormBehaviors(){
	$j.log('loading COPPA LIGHTBOX FORM behaviors from behaviors/coppa_lightbox.js')
	
	jQuery('#facebox #coppa_form').submit(function(){
		jQuery.jsonhRequest({
      data: jQuery(this).serialize(),
      url: jQuery(this).attr("action"),
      success: function(jsonResponse) {
				jQuery.facebox.close();
				jQuery('#flash_container').html(jsonResponse.flash_messages);
      },
			error: function(jsonResponse) {
				jQuery.facebox(jsonResponse.html);
				// hide bottom close
				jQuery("#facebox .footer").attr("style", "display:none;")
				// behaviors
        load_form_behaviors('#facebox_content');
        load_misc_behaviors('#facebox_content');
				loadCoppaFormBehaviors();
			}
    });

		return false;
	})
}


// ON LOAD

jQuery(function() {
	load_coppa_lightbox();
});