$j(document).ready(function($) {
	window.setTimeout(function() { // instantiate meebo bar
		if (typeof Meebo != 'undefined') {
			Meebo('domReady');
		}
	}, 500);
	
	
	
	$j(document).bind('cbox_open', function(){
	    $j("div.flash_container").hide();
	});
	
	$j(document).bind('cbox_closed', function(){
	    $j("div.flash_container").show();
	});
	
	
	
	
	
	$j("a.link_login").colorbox({width:'380px', scrolling:false, inline:true, href:"#box_login"});
	$j("a.link_reset").colorbox({width:'380px', scrolling:false, inline:true, href:"#box_reset_password"});
	
	
	
	
	
	
	
	
	//test growl
	//$j.jGrowl("hello gems", { theme:'gemsEarned', life:4400, sticky:true });
	//$j.jGrowl("hello world", { theme:'', life:4400, sticky:true });
	

	/* use jquery.validate plugin on all formtastic forms */
	/* use each so that forms are validated independently, in case there are multiple forms on the same page */
	
	$j("form.formtastic").each(function() {
		$j(this).validate({

			errorPlacement: function(error, element) {
				error.insertAfter(element.siblings("label"));
			},

			errorClass: 'invalid',
			
			meta: "validate",
			
			ignoreTitle: true,
						
			
			invalidHandler: function() {
				$j.fn.colorbox.resize(); /* if form is inside a colorbox modal, then resize (to avoid scrollbars) */
			}
			
		});
	});
	
	
	
	// resize all text areas automatically
	$j("textarea").autoResize({});



});