/*
    @author   : Igor "SkAZi" Potapov <igor@potapoff.org>
    @copyright: Plan-B Ltd.
    @requires : Mootools 1.2
*/

function closePromo(){
    $('flash-promo').set('html', '').setStyles({
            'display': 'none',
            'overflow': 'auto'
    });
    $$('body').setStyle('overflow', '');
    $$('html').setStyle('overflow', '');
    $('flash-promo').onmousewheel = $lambda;
}

window.addEvent('domready', function(){
    
    $$('a[rel^=promo]').addEvent('click', function(){
        $('flash-promo').setStyles({
            'display': 'block',
            'overflow': 'auto'
        });
        $$('body').setStyle('overflow', 'hidden');
        $$('html').setStyle('overflow', 'hidden');
        
        $('flash-promo').onmousewheel = function(e){
            if(e.preventDefault)
                e.preventDefault();
        };
        
        var href;
        if(!this.getAttribute('href').test(/^#\d+$/)){
            href = this.getAttribute('href');
        } else {
            href = "/" + LANGUAGE_CODE + "/academy/masterclass/" + this.getAttribute('href').replace(/^.*#(\d+)/, "$1") +"/masterclass.xml";
        }
        
        new Swiff('/media/img/masterclass/master-class.swf', {
            container: 'flash-promo',
            width: "100%",
            height: "100%",
            id: 'flash-portfolio',
            vars: {
                'xmlPath': href,
                'locale': LANGUAGE_CODE
            },
            params:{
                wMode: 'none'
            }
        });
        
        return false;
    });
    
    var opend = document.location.href.match(/#(\d+)$/);
    if(opend && opend[1]){
        $$('a[rel=promo '+opend[1]+']')[0].fireEvent('click');
    }

});
