jQuery(function($){
    
    $('a#login').click(function(event){
        event.preventDefault();
        
        $(this).colorbox({
            href:$(this).attr('href')+'.modal',
            onComplete:function(){$.colorbox.resize();}
        });
    });
    
	$('.modal.login-box form').prepend( $('<input type="hidden" />').attr('name','modal').val('yes') );
	
	$('.positioner-modal form.login').live('submit',function(e){
		e.preventDefault();
		
		$.post( $(this).attr('action'), $(this).serialize(), function(json) {
			if ( json.message == 'success' ) {
				location.reload();
			}
			else {
				$('.positioner-modal form.login div.login-errors').text( json.message + ' ' ).append(
					$('<a />').attr('href','./forgot/').text('Forgot your password?')
				).show();
			
				$.colorbox.resize();
			}
			
		}, 'json');

	});
});
