//<!-- 

/*
 * swapInlineImage
 * swaps a thumbnail image to the fullsize image
 * 
 * @param aObj:             the href (containing the image thumbnail) that was clicked on
 * @param options:          object with the following keys:
 *      caption:            String
 *      credit:             String        
 *      description:        String
 *      idPrepend:          String - for multiple instances of the partial, the id's need to be unique, this is the id of the image object.
 *
 */
function swapInlineImage(aObj, options)
{
    var aObj            = $(aObj);
    var imgObj          = aObj.down('img', 0);
    
    //remove current classname
    aObj.up('ul').select('a').invoke('removeClassName', 'current');
    aObj.addClassName(options.hrefHighlightedCssClass);
    
    var loadingDiv      = $(options.loadingDiv);
    var largeImageDiv   = $('inlineImageLargeImageContainer'+options.idPrepend);
    var coords          = Position.cumulativeOffset(largeImageDiv);
    
    loadingDiv.setStyle
    ({
        position:   'absolute',
        top:        coords.top,
        left:       coords.left
    });
    
    loadingDiv.show();
    
    new Effect.Opacity
    (
        largeImageDiv, 
        {
            from: 1.0,
            to: 0.0,
            duration: 0.8,
            queue: 'front',
            afterFinish: function()
            {
                var imgTarget       = $('inlineImageLargeImage'+options.idPrepend).down('img', 0);
                imgTarget.src       = imgObj.src.replace(new RegExp("thumb_"), "");
                imgTarget.width     = options.width;
                imgTarget.height    = options.height;
                
                //hide caption/credit/desc
                hideInlineImageText(options);
        
                //set caption/credit/desc
                setInlineImageText(options);
            
                //show caption/credit/desc if they have content
                showInlineImageText(options);
            
                new Effect.Opacity
                (
                    'inlineImageLargeImageContainer'+options.idPrepend, 
                    {
                        from: 0.0,
                        to: 1.0,
                        duration: 0.8,
                        queue: 'end',
                        afterFinish: function()
                        {
                            loadingDiv.hide();
                        }
            
                    }
                );
            }
        }
    );
}


/*
 * hideInlineImageText
 * hides the caption/credit/desc for the large inline image
 *
 *
 * @param options:          object with the following keys:
 *      caption:            String
 *      credit:             String        
 *      description:        String
 *      idPrepend:          String
 */
function hideInlineImageText(options)
{
    $('inlineImageCaption'+options.idPrepend).hide()
    $('inlineImageCredit'+options.idPrepend).hide()
    $('inlineImageDescription'+options.idPrepend).hide()
}


/*
 * showInlineImageText
 * show the caption/credit/desc for the large inline image, if they are set
 *
 * @param options:          object with the following keys:
 *      caption:            String
 *      credit:             String        
 *      description:        String
 *      idPrepend:          String
 *
 */
function showInlineImageText(options)
{
    if (!empty(options.caption))
        $('inlineImageCaption'+options.idPrepend).show();
    if (!empty(options.credit))
        $('inlineImageCredit'+options.idPrepend).show();
    if (!empty(options.description))
        $('inlineImageDescription'+options.idPrepend).show();
}



/*
 * setInlineImageText
 * sets the caption/credit/desc innerHTML for the large inline image
 * 
 * @param options:          object with the following keys:
 *      caption:            String
 *      credit:             String        
 *      description:        String
 *
 */
function setInlineImageText(options)
{
    $('inlineImageCaption'+options.idPrepend).update((!empty(options.caption)) ? options.caption : '');
    $('inlineImageCredit'+options.idPrepend).update((!empty(options.credit)) ? options.credit : '');
    $('inlineImageDescription'+options.idPrepend).update((!empty(options.description)) ? options.description : '');
}

function empty () { if (arguments[0] == null || typeof arguments[0] == "undefined" || arguments[0] == "undefined" || arguments[0] == "") return true; else return false;};
//-->
