<!--

function showInfoWindow(element)
{
    if (element)
    {
        var coords = Position.cumulativeOffset(element);
        $('infoWindow').setStyle({ 
            top: coords[1]+'px' 
        });
    }
    
    Element.show('infoWindow');
}

function closeInfoWindow()
{
    Element.hide('infoWindow');
    infoWindowDrag.destroy();
    $('infoContent').update();
}

var infoWindowDrag;
function createWindowDrag()
{
    infoWindowDrag = new Draggable('infoWindow', { handle: 'header', starteffect: null, endeffect: null } );
}

function enlargeGalleryImage(aObj, options)
{
    var thumbnails = aObj.parentNode.parentNode.getElementsByTagName('LI');
    
    for (var i=0; i<thumbnails.length; i++)
    {
        var aEl = thumbnails[i].getElementsByTagName('A')[0];
        //if (aEl.hasClassName('current'))
            Element.removeClassName(aEl, 'current');
    }
    
    Element.addClassName(aObj, 'current');

    imgObj = aObj.firstChild;
    
    Element.show('loading');
    
    new Effect.Opacity('galleryItemContainer', {
        from: 1,
        to: 0,
        queue: 'front',
        afterFinish: function()
        {
            //set caption/credit
            if (!empty(options.caption))
                $('caption').update(options.caption);
            if (!empty(options.credit))
                $('credit').update(options.credit);

            var imgTarget = $('galleryItem').getElementsByTagName('IMG')[0];
            imgTarget.width = options.width;
            imgTarget.height = options.height;
            imgTarget.src = imgObj.src.replace(new RegExp("thumb_"), "");
            
            new Effect.Opacity('galleryItemContainer', {
                from: 0,
                to: 1,
                queue: 'end',
                afterFinish: function()
                {
                    Element.hide('loading');
                }
            
            });
        }
    });
    
    
    
}

function showGalleryVideo(aObj, options)
{
    //highlight current
    Element.addClassName(aObj, 'current');
    
    Element.hide('galleryItemContainer');
    Element.show('loading');
    var flashVars = {
            autoPlay: false, 
            mediaType: 'video',
            videoFile: options.videoFile,
            videoSkin: '/swf/ClearExternalAll.swf'
    };
    var params = {loop: 'false', menu: 'false', quality: 'high', swliveconnect: 'true', bgcolor: '#a78e3f', allowScriptAccess: 'always'};
    var attributes = {id: 'avPlayerMovie', name: 'avPlayerMovie'}
    swfobject.embedSWF('/swf/avPlayer.swf', 'avPlayerMovie', '550', '492', '8.0.0', false, flashVars, params, attributes);
    Element.hide('loading');
    Element.show('galleryItemContainer');
    
}

function openGallery()
{
    setupScreenCover();
    Element.show('mediaGallery');
    Event.observe(window, 'resize', setupScreenCover);
}

function closeGallery()
{
    Element.hide('mediaGallery');
    Element.hide('screenCover');
    Event.stopObserving(window, 'resize', setupScreenCover);
    
}


function setupScreenCover()
{
    //resize the screenCover to full scrollheight
    var screenDims = $('body').getDimensions()
    $('screenCover').setStyle({height:screenDims.height+'px', width:screenDims.width+'px'})
    
    //goto #top
    window.location.href = (window.location.href.indexOf('#') == -1) ? window.location.href+'#top' : window.location.href.substr(0, window.location.href.indexOf('#'))+'#top';
}

    

//-->
