//****************************************************//
//                  ON DOMREADY                       //
//****************************************************//
window.addEvent('domready', function(){
       
    window.store('domready', true); 
          
    
});
//****************************************************//
//                     ON LOAD                        //
//****************************************************//
window.addEvent('load', function(){ 

    if(! window.retrieve('domready')){ 
        window.fireEvent('domready');  
    };

}, true);


//****************************************************//
//                    DISPLAY POPUP                   //
//****************************************************// 
function getPopup(action, sTitle, sFile) {
    
    var bg          = $('popup_layer');
    var out_cont    = $('popup_outer_container');
    var inn_cont    = $('popup_inner_container');
    var popup_title = $('popup_header_mid');    
    var popup_file  = $('popup_mid_fileholder');  
    
    if (action == 'open')
    {
        popup_title.innerHTML   = sTitle;    
        popup_file.innerHTML    = sFile;

        bg.setStyles({
            'opacity' : 0.0,
            'display' : 'block',
            'height'  : window.getScrollHeight(),
            'width'   : window.getScrollWidth()    
        });
        bg.set('morph', {
            duration: 400, 
            link: 'cancel',
            onComplete: function() {
                out_cont.setStyles({
                    'display' : 'block'
                });
            }
        });
        bg.morph({
            'opacity' : 0.7
        });
    }
    else //close popup
    {
        $f("popup_mid_fileholder").close();

        out_cont.setStyles({
            'display' : 'none'
        });
        bg.set('morph', {
            duration: 400, 
            link: 'cancel'                   
        });
        bg.morph({
            'opacity' : 0.0
        });                              
 
    }
 
}
function getImagePopup(sTitle, sFile)
{
    getPopup('open', sTitle, sFile)
}
function getMoviePopup(sTitle, sFile)
{
        
    getPopup('open', sTitle, '');
    $('popup_mid_fileholder').setStyles({
        'width' : '640px',
        'height' : '480px'
    });
    flowplayer('popup_mid_fileholder', '/layouts/js/flowplayer-3.1.0.swf', {     
        clip: {
            url: sFile,
            autoPlay: true
        }, 
        plugins: {
           controls: {
              progressColor: '#454545',
              sliderGradient: 'none',
              tooltipColor: '#000000',
              tooltipTextColor: '#ffffff',
              bufferColor: '#333333',
              buttonColor: '#474747',
              backgroundGradient: [0.6,0.3,0,0,0],
              progressGradient: 'medium',
              timeColor: '#e3e3e3',
              volumeSliderGradient: 'none',
              timeBgColor: '#555555',
              bufferGradient: 'none',
              borderRadius: '0px',
              sliderColor: '#a1a1a1',
              buttonOverColor: '#6b6b6b',
              backgroundColor: '#a1a1a1',
              volumeSliderColor: '#000000',
              durationColor: '#dedede',
              height: 24,
              opacity: 1.0
           }
        }        
    });
}

