/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * CSS for the flash messenger that appears at the top of the page, when something 
 * has triggered a message to be displayed (make friend, login, logout, etc ...)
 * 
 * LICENSE: Some license information
 *
 * @copyright   2008 Hebrew Immigrant Aid Society
 * @version     Release: @package_version@
 * @link        http://
 * @author      Cory Collier <cory@hydrastudio.com>
 * @since       December 26, 2008
 */

// ON document ready ...
$( document ).ready( function()
{
	// ITERATE through each of the close links in messages ...
	$.each($('#messages .close'), function()
    {
		// ADD an event handler to remove the item, when it is clicked
		$( this ).click(
            function()
            {
    			$( this ).parent().fadeOut(
                    'slow',
                    function()
                    {
                        $(this).remove(); // remove item after fade out
            
                        alertCount = $('#messages div').size(); // count items
                        
                        if ( alertCount <= 0 ) // if no items, remove parent overlay (transparent PNG)
                        {
                            $('#messages').remove();
                        }
                    }
                ); // close fadeOut
                
                return false;
            }
        );
	});
    
    //  Remove messages when clicking anywhere on the page
    $('body').bind('click', function()
    {
       $('#messages').fadeOut('slow', function()
        {
            $(this).remove();
        });
        
        $('body').unbind('click');
    });
    
    //  FADE messages out after a set amount of time
    $('#messages > div').each(function()
    {
        var cc = $(this);
        fadeMessage = function()
        {
            // messageObj.parent().fadeTo("slow", 0.9);
            cc.parent().fadeOut('slow', function()
            {
                $(this).remove();
            });
        }
        
        window.setTimeout(fadeMessage, 7000);        
    });
    
    // ITERATE through each of the pop links...
    $.each($('.pop'), function()
    {
        // ADD an event handler to show / hide item
        $( this ).toggle(
            function()
            {
                $(document).find( $( this ).attr('href') ).fadeIn('fast');
            },
            function()
            {
                $(document).find( $( this ).attr('href') ).fadeOut('slow');
            }
        );
    });
    
    
    // prompt confirmation on delete actions
    
    $('.delete').click( function()
    {
        var answer = confirm( "Are you sure? This action cannot be undone!" )
        
        if (answer) // IF yes...
        {
            // run anchor action
        }
        else // ELSE no, stay on page
        {
            return false;
        }
    });
    
});

    
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * c-hanging-comment-ender-p: nil
 * End:
 */
