IE='\v'=='v';
function setAutoRemove(id, val) {
    if (!$(id)) return false;
    $(id).addEvent('focus', function() {
        if (this.get('value') == val) {
            this.set('value', '');
            this.removeClass('light_grey');
        }
    });
    $(id).addEvent('blur', function() {
        if (this.get('value') == '') {
            this.set('value', val);
            this.addClass('light_grey');
        }
    });
    if ($(id).get('value') == '') {
        $(id).set('value',val);
        this.removeClass('light_grey');
    }

    return $(id);
}
function addLightGreyClass() {
    if(document.getElementById('feedback-text')) {
        $('feedback-text').addClass('light_grey');
    }
    if(document.getElementById('feedback-name')) {
        $('feedback-name').addClass('light_grey');
    }
    if(document.getElementById('feedback-email')) {
        $('feedback-email').addClass('light_grey');
    }
    return true;
}
var timer = 0;


window.addEvent('domready', function() {

    var not_modify = $$('.not_modify');
    if(not_modify.length < 1) {
        addLightGreyClass();
    }
    not_modify = null;

    if(document.getElementById('about-product')) {
        $('about-product').set('opacity', 0);
        $('about-product').removeClass('none');
    }


    $$('div.interv_item').addEvents({
        'mouseover': function() {
            this.setStyle('background', "url('images/interv_item_active_bg.png') no-repeat top");
        },
        'mouseout': function() {
            this.setStyle('background', "url('images/interv_item_bg.png') no-repeat top");
        }
    });

    $$('div.gallery_item').addEvents({
        'mouseover': function() {
            this.setStyle('text-decoration', 'none');
            this.getElement('span.item_name').setStyle('color','#e81a2d'),
                /* this.setStyle('background', "url('images/gallery_bg_prod_2_active.png') no-repeat center"); */
                    this.addClass('gallery_item_active');
        },
        'mouseout': function() {
            this.getElement('span.item_name').setStyle('color','#666666'),
                /* this.setStyle('background', "url('images/gallery_bg_prod_2.png') no-repeat center"); */
                    this.removeClass('gallery_item_active');
        }
    });

    $$('div.interv_list_item').addEvents({
        'mouseover': function() {
            this.getElement('div.post').setStyle('color','#ffffff'),
                    this.setStyle('background', "url('images/interv_list_item_active_bg.png') no-repeat top");
        },
        'mouseout': function() {
            this.getElement('div.post').setStyle('color','#464646'),
                    this.setStyle('background', "url('images/interv_list_item_bg.png') no-repeat top");
        }
    });

    $$('div.lessons_list_item').addEvents({
        'mouseover': function() {
            this.getElement('a.link').setStyle('color','#e81a2d');
        },
        'mouseout': function() {
            this.getElement('a.link').setStyle('color','#666666');
        }
    });

    $$('div.other_video_list_item').addEvents({
        'mouseover': function() {
            this.getElement('a.link').setStyle('color','#e81a2d');
        },
        'mouseout': function() {
            this.getElement('a.link').setStyle('color','#666666');
        }
    });

    setAutoRemove('input-search',$('input-search').get('value'));


    if ($('video-container')) {
        swfobject.embedSWF(
                '/flash/player.swf',
                'video-container',
                '319',
                '206',
                '9.0.0',
                '/flash/expressInstall.swf',
        {
            'file':			$('video-container').get('title'),
            'type':			'video',
            'icons':		true,
            'backcolor':    '444444',
            'frontcolor':   'cccccc',
            'lightcolor':   'f8fb01',
            'volume':		'60',
            'skin':			'/flash/default.swf',
            'bufferlength':	'5',
            'autostart': false
        },
        {
            'allowScriptAccess':	'always',
            'allowFullScreen':		'true',
            'scale':				'noscale',
            'salign':				'tl',
            'bgcolor':				'#030303',
            'wmode':                'opaque'
        },
        {
            'id':					'video-container',
            'name':					'video-container',
            'align':				'middle'
        }
                );
    }

    if (document.getElementById('interview-embed')) {
        if($('interview-embed').getElementsByTagName('a')[0]) {
            $('interview-embed').getLast().dispose();
        }
    }

    $$('.menu_popup_item_box').set('opacity', 0);
    $$('.menu_popup_item_box').removeClass('none');
    var prodEffect = new Fx.Morph('products-menu', {duration: 'short', transition: Fx.Transitions.linear.easeOut});
    var famEffect = new Fx.Morph('family-menu', {duration: 'short', transition: Fx.Transitions.linear.easeOut});

    if(document.getElementById('products-category')) {
        $('products-menu').set('opacity', 0);
        $('products-category').addEvent('mouseenter', function(evt) {
            clearTimeout(timer);
            if($('family-menu').get('opacity') > 0 ){
                //$('family-menu').set('tween', {duration: 'long'});
                //$('family-menu').tween('opacity', 1, 0);
                //$('family-menu').fade('out');
                famEffect.start({
                    'left': [$('main-menu-left').getLeft()+$('main-menu-left').getWidth(), $('main-menu-left').getLeft()+$('main-menu-left').getWidth()-40], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
                });
            }
            $('products-menu').setStyle('top', $('products-category').getTop()-20);
            //$('products-menu').setStyle('left', $('main-menu-left').getLeft()+$('main-menu-left').getWidth()-10);
            //$('products-menu').removeClass('none');
            //$('products-menu').tween({'left' : [$('main-menu-left').getLeft()+$('main-menu-left').getWidth()-10 ,$('main-menu-left').getLeft()+$('main-menu-left').getWidth()], 'opacity' : [0.5, 1]});
            if($('products-menu').get('opacity') == 0 ){
                //$('products-menu').set('tween', {duration: 'long'});
                //$('products-menu').tween('opacity', 0, 1);
                //$('products-menu').fade('in');
                var prodEffect = new Fx.Morph('products-menu', {duration: 'short', transition: Fx.Transitions.linear.easeOut});
                prodEffect.start({
                    'left': [$('main-menu-left').getLeft()+$('main-menu-left').getWidth()-10, $('main-menu-left').getLeft()+$('main-menu-left').getWidth()], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [0, 1]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        });
        $('products-category').addEvent('mouseleave', function(evt) {
            timer = setTimeout("hideAllSubMenus()", 2000);
        });
    }

    if(document.getElementById('family-category')) {
        $('family-menu').set('opacity', 0);
        $('family-category').addEvent('mouseenter', function(evt) {
            clearTimeout(timer);
            $$('.menu_popup_item_box').each(function(item){
                if((item.get('opacity') > 0) && (item.get('id') != 'family-menu')) {
                    //item.tween('opacity',1, 0);
                    //item.fade('out');
                    var itmEffect = new Fx.Morph(item, {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                    itmEffect.start({
                        'left': [item.getLeft(), item.getLeft()-40], //Morphs the 'height' style from 10px to 100px.
                        'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
                    });
                }
            });
            $('family-menu').setStyle('top', $('family-category').getTop()-20);
            //$('family-menu').setStyle('left', $('main-menu-left').getLeft()+$('main-menu-left').getWidth());
            //$('family-menu').removeClass('none');
            //$('family-menu').tween('left', $('main-menu-left').getLeft(), $('main-menu-left').getLeft()+$('main-menu-left').getWidth());
            if($('family-menu').get('opacity') == 0 ){
                //$('family-menu').tween('opacity', 0, 1);
                //$('family-menu').fade('in');
                var famEffect = new Fx.Morph('family-menu', {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                famEffect.start({
                    'left': [$('main-menu-left').getLeft()+$('main-menu-left').getWidth()-40, $('main-menu-left').getLeft()+$('main-menu-left').getWidth()], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [0, 1]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        });
        $('family-category').addEvent('mouseleave', function(evt) {
            timer = setTimeout("hideAllSubMenus()", 2000);
        });
    }

    $$('.menu_popup_item_expandable').addEvent('mouseenter', function(evt) {
        clearTimeout(timer);
    });
    $$('.menu_popup_item_expandable').addEvent('mouseenter', function(evt) {
        var id = this.get('id').split('-').pop();
        clearTimeout(timer);
        hideSubMenus(this.getParent('div').getParent('div'), id);
        if(document.getElementById('products-menu-'+id)) {
            evt.stop();
            //$('products-menu-'+id).setStyle('left', this.getParent('table').getLeft()+this.getParent('table').getWidth()+5);
            $('products-menu-'+id).setStyle('top', this.getTop()-20);
            //$('products-menu-'+id).removeClass('none');
            if($('products-menu-'+id).get('opacity') == 0 ){
                //$('products-menu-'+id).tween('opacity', 0, 1);
                //$('products-menu-'+id).fade('in');
                var subEffect = new Fx.Morph('products-menu-'+id, {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                subEffect.start({
                    'left': [this.getParent('table').getLeft()+this.getParent('table').getWidth()-40, this.getParent('table').getLeft()+this.getParent('table').getWidth()+5], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [0, 1]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        }
    });

    $$('.menu_popup_item_noexpandable').addEvent('mouseenter', function(evt) {
        clearTimeout(timer);
    });

    $$('.mainmenu .no_sub').addEvent('mouseenter', function(evt) {
        if(timer) {
            clearTimeout(timer);
        }
        $$('.menu_popup_item_box').each(function(item){
            if(item.get('opacity') > 0) {
                //item.tween('opacity',1, 0);
                //item.fade('out');
                var itEffect = new Fx.Morph(item, {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                itEffect.start({
                    'left': [item.getLeft(), item.getLeft()-40], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        });
    });

    $$('.menu_popup_item_box').addEvent('mouseleave', function(evt){
        timer = setTimeout("hideAllSubMenus()", 2000);
    });

});

window.addEvent('click', function(evt) {
    if(!evt.target.hasClass('menu_popup_item')) {
        clearTimeout(timer);
        $$('.menu_popup_item_box').each(function(item){
            if(item.get('opacity') > 0) {
                //item.tween('opacity',1, 0);
                //item.fade('out');
                var itemEffect = new Fx.Morph(item, {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                itemEffect.start({
                    'left': [item.getLeft(), item.getLeft()-40], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        });
    }
});

function hideSubMenus(div, id) {
    var children = div.getChildren('div');
    for(var i=0; i<children.length; i++) {
        if(document.getElementById('products-menu-'+children[i].getFirst('a').get('id').split('-').pop())) {
            hideSubMenus($('products-menu-content-'+children[i].getFirst('a').get('id').split('-').pop()), 0);
            if(($('products-menu-'+children[i].getFirst('a').get('id').split('-').pop()).get('opacity') == 1) && (children[i].getFirst('a').get('id').split('-').pop() != id)) {
                //$('products-menu-'+children[i].getFirst('a').get('id').split('-').pop()).tween('opacity', 1, 0);
                //$('products-menu-'+children[i].getFirst('a').get('id').split('-').pop()).fade('out');
                var submEffect = new Fx.Morph('products-menu-'+children[i].getFirst('a').get('id').split('-').pop(), {duration: 'short', transition: Fx.Transitions.linear.easeOut});

                submEffect.start({
                    'left': [$('products-menu-'+children[i].getFirst('a').get('id').split('-').pop()).getLeft(), $('products-menu-'+children[i].getFirst('a').get('id').split('-').pop()).getLeft()-40], //Morphs the 'height' style from 10px to 100px.
                    'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
                });
            }
        }
    }
}

function hideAllSubMenus() {
    clearTimeout(timer);
    $$('.menu_popup_item_box').each(function(item){
        if(item.get('opacity') > 0) {
            //item.tween('opacity',1, 0);
            //item.fade('out');
            var itemsEffect = new Fx.Morph(item, {duration: 'short', transition: Fx.Transitions.linear.easeOut});

            itemsEffect.start({
                'left': [item.getLeft(), item.getLeft()-40], //Morphs the 'height' style from 10px to 100px.
                'opacity': [1, 0]  //Morphs the 'width' style from 900px to 300px.
            });
        }
    });
}

function showHTMLBlock() {
    var efect = new Fx.Morph('about-product', {duration: 1000, transition: Fx.Transitions.linear.easeOut});

                efect.start({
                    'opacity': [0, 1]  //Morphs the 'width' style from 900px to 300px.
                });
}

/*				
 lessons_list_item



 */
				
