// <![CDATA[

var NavMenuItem = Class.create(
{
    initialize: function(element, panel)
    {
        this.panel      = panel;
        this.element    = $(element);
        this.dimensions = {width: 0, height: 0};
        this.sub        = null;

        if (!this.element)
        {
            return false;
        }
    },

    onMouseOver: function()
    {
        this.activate();

        if(this.hasSubMenu())
        {
            this.showSubmenu();
        }
    },

    hasSubMenu: function()
    {

    },

    showSubMenu: function()
    {

    },

    getElement: function()
    {
        return this.element;
    },

    getWidth: function()
    {
        if(this.element != null)
        {
            return this.element.getWidth();
        }

        return 0;
    },

    setWidth: function(width)
    {
        if(this.element)
        {
            this.element.setStyle({width: width + 'px'});

            return true;
        }

        return false;
    },

    getHeight: function()
    {
        if(this.element != null)
        {
            return this.element.getHeight();
        }

        return 0;
    },

    setHeight: function(height)
    {
        if(this.element)
        {
            this.element.setHeight(height);

            return true;
        }

        return false;
    },

    activate: function()
    {
        if(this.element != null)
        {
            this.element.addClassname('activated');

            return true;
        }

        return false;
    },

    deactivate: function()
    {
        if(this.element != null)
        {
            this.element.removeClassname('activated');

            return true;
        }

        return false;
    },

    select: function()
    {
        if(this.element != null)
        {
            this.element.addClassname('selected');

            return true;
        }

        return false;
    },

    deselect: function()
    {
        if(this.element != null)
        {
            this.element.removeClassname('selected');

            return true;
        }

        return false;
    }
});

var NavMenuPanel = Class.create(
{
    initialize: function(element)
    {
        this.parent     = null;
        this.element    = $(element);
        this.items      = $A();
        this.dimensions = {width: 0, height: 0};
        this.position   = {top: 0, left: 0};

        this.loadItems();
        this.setWidth();
//        this.hide();
    },

    loadItems: function()
    {
        if(!this.element)
        {
            return false;
        }

        this.element.childElements().each(function(item){
            this.items.push(new NavMenuItem(item, this));
        }.bind(this));
    },

    setWidth: function(width)
    {
        if(!width)
        {
            var width = 0;
            this.items.each(function(item){

                var w = item.getWidth();

                if(w > width)
                {
                    width = w;
                }
            });
        }

        this.items.each(function(item){
           item.setWidth(width);
        });

        this.element.setStyle({width: width + 'px'});
    },

    show: function()
    {
        if(this.element != null)
        {
            this.element.show();

            return true;
        }

        return false;
    },

    hide: function()
    {
        if(this.element != null)
        {
            this.element.hide();

            return true;
        }

        return false;
    }
});

var NavMenu = Class.create(
{
    initialize: function(container, options)
    {
        this.element = $(container);

        if(!this.element)
        {
            return false;
        }

        if(options.remove)
        {
            options.remove.invoke('remove');
        }

        this.panels = $A();

        this.loadPanels(this.element);

        $$('#' + this.element.identify() + ' ul').each(function(panel, i){
            this.panels.push(new NavMenuPanel(panel));
        }.bind(this));

        this.panels[0].show();
    },


    loadPanels: function(element)
    {

    }
});

var NavigationMenu = Class.create(
{
    initialize: function()
    {
        var subs    = $$('#main-navigation-container ul ul');
        var toggles = $$('#main-navigation a');
        var timer   = null;

        subs.invoke('hide');
        [$('menu-section7'), $('menu-section37')].invoke('remove');

        toggles.each(function(t){
            var sub = t.next('ul');

            if(sub)
            {
               $(t.parentNode).observe('mouseover', function(){
                    timer = clearTimeout(timer);
                    t.next('ul').show();
               });
               $(t.parentNode).observe('mouseout', function(){
                    t.next('ul').hide();
//                    timer = setTimeout(function(){
//                        t.next('ul').hide();
//                    }, 500);
               });
            }
        });

    }
});


var ClientsLoginWidget = Class.create(
{
    initialize: function()
    {
        this.form = $('form-identification');

        if(!this.form || Prototype.Browser.IE)
        {
            return false;
        }

        this.username = {el: $('login'),    defaultValue: 'Identifiant'};
        this.username.el.value = this.username.defaultValue;
        this.username.el.observe('focus', this.toggleValue.bind(this.username));
        this.username.el.observe('blur', this.toggleValue.bind(this.username));

        this.password = {el: $('password'), defaultValue: 'Mot de passe'};
        this.password.el.value = this.password.defaultValue;
        $(this.password.el).writeAttribute('type', 'text');
        this.password.el.observe('focus', this.toggleValue.bind(this.password));
        this.password.el.observe('blur', this.toggleValue.bind(this.password));
    },

    toggleValue: function()
    {
        if(!this.el)
        {
            alert('Error: missing login form element!');
            return false;
        }

        var value = $F(this.el);

        if(value == this.defaultValue)
        {
            this.el.value = '';

            if(this.el.readAttribute('id').toLowerCase()=='password')
            {
                $(this.el).writeAttribute('type', 'password');
            }
        }
        else
        {
            if(value == '')
            {
                this.el.value = this.defaultValue;

                if(this.el.readAttribute('id').toLowerCase()=='password')
                {
                    $(this.el).writeAttribute('type', 'text');
                }
            }
            else
            {
                if(this.el.readAttribute('id').toLowerCase()=='password')
                {
                    $(this.el).writeAttribute('type', 'password');
                }
            }
        }
    }
});

var AcofiPlayerWidget = Class.create(
{
    initialize: function()
    {
        this.playlist = $('demarquage-playlist-videos');

        if(!this.playlist) { return; }

        this.playlist.absolutize();

        this.videos   = $$('#demarquage-playlist-videos li a.video');

        this.btn_prev = $('demarquage-playlist-btn-prev');
        this.btn_next = $('demarquage-playlist-btn-next');

        this.videosNb   = this.videos.length;
        this.videoWidth = 50 + 10;

        this.scrolling = false;

        this.btn_prev.observe('click', this.scrollLeft.bindAsEventListener(this));
        this.btn_next.observe('click', this.scrollRight.bindAsEventListener(this));
    },

    scrollLeft: function(event)
    {
        event.stop();

        if(!this.scrolling)
		{
			this.scrolling = true;

			if(parseInt(this.playlist.getStyle('left'))<0)
			{

				new Effect.MoveBy(this.playlist, 0, 180, {duration: .25, afterFinish: function(){

					$(this.playlist.parentNode).next().setStyle({opacity: 1, cursor: 'hand'});

					this.scrolling = false;
				}.bind(this)});
			}
			else
			{
				this.scrolling = false;
			}
		}

    },

    scrollRight: function(event)
    {
        event.stop();

        if(!this.scrolling)
		{
			this.scrolling = true;

			var stop = -this.videosNb*60+3*60;

			if(parseInt(this.playlist.getStyle('left'))>stop)
			{
				new Effect.MoveBy(this.playlist, 0, -180, {duration: .25, afterFinish: function(){

					$(this.playlist.parentNode).previous().setStyle({opacity: 1, cursor: 'hand'});

					this.scrolling = false;
				}.bind(this)});
			}
			else
			{
				this.scrolling = false;
			}
		}

    }
});

var NavigationWidget = Class.create(
{
	initialize: function()
	{
		this.sections = $$('div#navigation a.nav-section-item');
		this.pages    = $$('div#navigation div.nav-pages');
		this.updating = false;
		this.hover    = null;
		this.timer    = null;

		this.pages.invoke('hide');

		this.sections.each(function(item, i)
		{
			var parent = $(item.parentNode);
			var pages  = item.next();

			if(parent.hasClassName('selected'))
			{
				if(pages)
				{
					item.next().show();
				}
			}
			else
			{
				if(pages)
				{
					item.observe('mouseover',   this.showPages.bindAsEventListener(this, i));
					parent.observe('mousemove', this.clearTimer.bind(this));
					parent.observe('mouseout',  this.hidePages.bindAsEventListener(this, i));
				}
				else
				{
					parent.observe('mouseover', this.activateItem);
					parent.observe('mouseout',  this.deactivateItem);
				}
			}
		}.bind(this));
	},

	activateItem: function()
	{
		this.addClassName('hover');
	},

	deactivateItem: function()
	{
		this.removeClassName('hover');
	},

	showPages: function(event, i)
	{
		if(!this.updating && (i!=this.hover))
		{
			this.updating = true;

			this.hidePagesByNb(this.hover);

			this.hover    = i;
			var section   = $(this.sections[i].parentNode);
			var pages     = section.childElements()[1];

			new Effect.BlindDown(pages, {duration: .4, beforeStart: function(){ section.addClassName('selected'); }.bind(this), afterFinish: function(){ this.updating = false; }.bind(this)});
		}
	},

	hidePagesByNb: function(i)
	{
		if(i)
		{
			var section   = $(this.sections[i].parentNode);
			var pages     = section.childElements()[1];
			new Effect.BlindUp(pages, {duration: .4, beforeStart:function(){ section.removeClassName('selected'); }.bind(this)});
		}
	},

	hidePages: function(event, i)
	{
		if(!this.updating)
		{
			this.updating = true;
			var section   = $(this.sections[i].parentNode);
			var pages     = section.childElements()[1];

			this.timer = setTimeout(function(){ new Effect.BlindUp(pages, {duration: .4, beforeStart:function(){ }.bind(this), afterFinish: function(){ section.removeClassName('selected'); this.hover = null; this.updating = false; }.bind(this)}); }.bind(this), 500);
		}
	},

	clearTimer: function()
	{
		this.timer    = clearTimeout(this.timer);
		this.updating = false;
	}
});

var MoreWidget = Class.create(
{
	initialize: function()
	{
		$$('div#more li').each(function(item)
		{
			item.observe('mouseover', function(){ this.addClassName('hover'); });
			item.observe('mouseout', function(){ this.removeClassName('hover'); });
		});
	}
});

var FormsWidget = Class.create({
	initialize: function()
	{
		var btn_cancel = $$('.btn-cancel');
		var btn_save   = $$('.btn-submit');
		var result     = $('result');
		var timer      = null

		if(result)
		{
			result.hide();
			new Effect.BlindDown(result, {duration: .5, afterFinish: function(){
				timer = setTimeout(function(){ new Effect.BlindUp(result, {duration: .5}); clearTimeout(timer); }, 2000);
			}});
		}

		btn_cancel.each(function(btn){
			var form = $(btn.id.substr(4, btn.id.length));

			btn.observe('click', function(event){
				event.stop();
				form.reset();
			});
		});

		btn_save.each(function(btn){
			var form = $(btn.id.substr(4, btn.id.length));

			btn.observe('click', function(event){
				event.stop();
				form.submit();
			});
		});
	}
});

var CallYouBackWidget = Class.create(
{
	initialize: function()
	{
		var bg         = this.createBg();
		var toggle_btn = $('call-you-back');

		this.redraw();

		toggle_btn.observe('click', function(event){
			event.stop();

			if(this.bg.visible())
			{
				this.hideForm();
			}
			else
			{
				this.showForm();
			}
		}.bind(this));
	},

	toggleBackground: function()
	{
        if(this.bg)
        {
            if(this.bg.visible())
            {
                this.bg.fade({duration:.2});
            }
            else
            {
                this.bg.appear({duration: .2, from:0, to: .8});
            }
        }
	},

	createBg: function()
	{
		this.bg = new Element('div', {id: 'ACOFI-callback_bg'});

		$(document.body).insert({bottom: this.bg.hide()});

		this.bg.observe('window:resize', this.redraw.bind(this));
		this.bg.observe('click', this.hideForm.bind(this));

		return this.bg;
	},

	createPane: function()
	{
		this.pane = new Element('div', {id: 'acofi-callback_pane'});
		this.form = new Element('form', {id: 'acofi-callback-form', action:'/index/call-you-back', method: 'post'});

        var fields = '<fieldset>' +
            '<legend>Vous souhaitez être mis en relation avec notre équipe : <br />du lundi au vendredi, de 10h à 12h et de 14h à 17h, <br />nous vous contactons immédiatement par téléphone.</legend>' +
            '<h3>Merci de renseigner le formulaire ci-dessous.</h3>' +
            '<p class="field">' +
                '<label for="when">Vous souhaitez être rappelé : </label>' +
                '<select id="when" name="when">' +
                    '<option value="immédiatement">immédiatement</option>' +
                    '<option value="dans 5 minutes">dans 5 minutes</option>' +
                    '<option value="dans 10 minutes">dans 10 minutes</option>' +
                '</select>' +
            '</p>' +
            '<p class="field">' +
                '<label for="type">Vous êtes <span class="required">*</span> : </label>' +
                '<select name="type" id="type" style="width:109px">' +
                    '<option value="particulier">un particulier</option>' +
                    '<option value="société">une société</option>' +
                '</select>' +
            '</p>' +
            '<p class="field">' +
                '<label for="category">&nbsp;&nbsp;&nbsp;</label>' +
                '<select name="category" id="category">' +
                    '<option value="Institutionnel" label="Institutionnel">Institutionnel</option>' +
                    '<option value="Gestion privée" label="Gestion privée">Gestion privée</option>' +
                    '<option value="Société de gestion de portefeuilles" label="Société de gestion de portefeuilles">Société de gestion de portefeuilles</option>' +
                    '<option value="Plateforme" label="Plateforme">Plateforme</option>' +
                    '<option value="CGPI/CIF" label="CGPI/CIF">CGPI/CIF</option>' +
                '</select>' +
            '</p>' +
            '<p class="field">' +
                '<label for="title">Votre nom <span class="required">*</span> : </label>' +
                '<select id="title" name="title">' +
                    '<option value="Mme">Mme</option>' +
                    '<option value="Mlle">Mlle</option>' +
                    '<option value="M." selected="selected">M.</option>' +
                '</select>' +
                '<input type="text" name="lastname" id="lastname" value="" />' +
            '</p>' +
            '<p class="field">' +
                '<label for="telephone">Votre téléphone <span class="required">*</span> : </label>' +
                '<input type="text" name="telephone" id="telephone" value="" />' +
            '</p>' +
    	    '<p class="field">' +
        		'<label for="security">Code de sécurité <span class="required">*</span> : </label>' +
        		'<input type="text" name="security" id="security" value="" style="width:126px" />' +
        		'<img id="security-img" style="float:right;margin:0 51px 0 0;" src="/medias/security-imgs/' + Math.floor(Math.random()*5) + '.png" alt="" />' +
    	    '</p>' +
            '<p class="form-commands">' +
                '<input type="submit" value="Valider" />' +
            '</p>' +
            '<p class="required"><span>*</span> Champs obligatoires.</p>'
        '</fieldset>';

        this.form.update(fields);


		$(document.body).insert({bottom: this.pane.insert(this.form)});
		this.redraw();

        this.form.observe('submit', this.submitForm.bindAsEventListener(this, this.pane));

        $('category').disable();
		$('type').observe('change', function(){
			if('société' == $F('type'))
			{
				$('category').enable();
			}
			else
			{
				$('category').disable();
			}
		});

		return this.form;
	},

	removePane: function()
	{
        if(this.pane)
        {
            this.pane.remove();
        }
	},

	redraw: function()
	{
		var scr = document.viewport.getDimensions();

		this.bg.setStyle({position: 'fixed', zIndex: 10000, top: '0px', left: '0px', width: scr.width + 'px', height: scr.height + 'px', backgroundColor: '#000000', opacity: .8});
		if(this.pane)
		{
			this.pane.setStyle({position: 'fixed', zIndex: 10001, width: '480px', height: '300px', left: ((scr.width-480)/2) + 'px', top: ((scr.height-300)/2) + 'px'});
		}
	},

	showForm: function()
	{
		this.createPane();

		this.toggleBackground();

	},

	hideForm: function()
	{
		this.removePane();
		this.toggleBackground();
	},

    submitForm: function(event, pane)
    {
        event.stop();
    	valid = false;

        if($F('lastname') && $F('telephone') && $F('security'))
        {
    	    var code = parseInt($('security-img').src.substring($('security-img').src.lastIndexOf('.')-1, $('security-img').src.length));

    	    if((0 == code && $F('security') == 'LR84fq')  ||
    	       (1 == code && $F('security') == '6Mg84w')  ||
    	       (2 == code && $F('security') == 'pX239u')  ||
    	       (3 == code && $F('security') == 'i7nc42H') ||
    	       (4 == code && $F('security') == 'k33Sw2'))
    	    {
                new Ajax.Request('/index/call-you-back',
                {
                    method    : 'post',
                    parameters: $('acofi-callback-form').serialize(),
                    onSuccess : function(){
                        pane.update('<h3 id="callback-confirmation">Votre demande a bien été envoyée à un de nos conseillers.</h3>');
                        var timer = setTimeout(this.hideForm.bind(this), 1800);
                    }.bind(this)
                });
    	    }
    	    else
    	    {
        		alert('Le code de sécurité saisi est incorrect.');

        		$('security').setStyle({border: '1px solid #EA8B24'});
    	    }
        }
        else
        {
    	    if(!$F('security'))
    	    {
    		  $('security').setStyle({border: '1px solid #EA8B24'});
    	    }
    	    else
    	    {
    		  $('security').setStyle({border: 'inherit'});
    	    }

            if(!$F('lastname'))
            {
                $('lastname').setStyle({border: '1px solid #EA8B24'});
            }
            else
            {
                $('lastname').setStyle({border: 'inherit'});
            }

            if(!$F('telephone'))
            {
                $('telephone').setStyle({border: '1px solid #EA8B24'});
            }
            else
            {
                $('telephone').setStyle({border: 'inherit'});
            }
            alert('Merci de renseigner tous les champs du formulaire.');
        }
    }
});

var SubscriptionWidget = Class.create(
{
	initialize: function()
	{
		var bg         = this.createBg();
		var toggle_btn = $('subscription');

		this.redraw();

		toggle_btn.observe('click', function(event){
			event.stop();

			if(this.bg.visible())
			{
				this.hideForm();
			}
			else
			{
				this.showForm();
			}
		}.bind(this));
	},

	toggleBackground: function()
	{
        if(this.bg)
        {
            if(this.bg.visible())
            {
                this.bg.fade({duration:.2});
            }
            else
            {
                this.bg.appear({duration: .2, from:0, to: .8});
            }
        }
	},

	createBg: function()
	{
		this.bg = new Element('div', {id: 'ACOFI-subscription_bg'});

		$(document.body).insert({bottom: this.bg.hide()});

		this.bg.observe('window:resize', this.redraw.bind(this));
		this.bg.observe('click', this.hideForm.bind(this));

		return this.bg;
	},

	createPane: function()
	{
		this.pane = new Element('div',  {id: 'acofi-subscription_pane'});
		this.form = new Element('form', {id: 'acofi-subscription-form', action:'/index/subscription', method: 'post'});

        var fields = '<fieldset>' +
            '<legend>Vous souhaitez recevoir automatiquement nos publications.</legend>' +
            '<h3>Merci de renseigner le formulaire ci-dessous.</h3>' +
            '<p class="field">' +
                '<label for="type">Vous êtes <span class="required">*</span> : </label>' +
                '<select name="type" id="type">' +
                    '<option value="particulier">un particulier</option>' +
                    '<option value="société">une société</option>' +
                '</select>' +
            '</p>' +
            '<p class="field">' +
                '<label for="category">&nbsp;&nbsp;&nbsp;</label>' +
                '<select name="category" id="category">' +
                    '<option value="Institutionnel" label="Institutionnel">Institutionnel</option>' +
                    '<option value="Gestion privée" label="Gestion privée">Gestion privée</option>' +
                    '<option value="Société de gestion de portefeuilles" label="Société de gestion de portefeuilles">Société de gestion de portefeuilles</option>' +
                    '<option value="Plateforme" label="Plateforme">Plateforme</option>' +
                    '<option value="CGPI/CIF" label="CGPI/CIF">CGPI/CIF</option>' +
                '</select>' +
            '</p>' +
            '<p class="field">' +
                '<label for="title">Votre nom <span class="required">*</span> : </label>' +
                '<select id="title" name="title">' +
                    '<option value="Mme">Mme</option>' +
                    '<option value="Mlle">Mlle</option>' +
                    '<option value="M." selected="selected">M.</option>' +
                '</select>' +
                '<input type="text" name="lastname" id="lastname" value="" />' +
            '</p>' +
            '<p class="field">' +
                '<label for="firstname">Votre prénom <span class="required">*</span> : </label>' +
                '<input type="text" name="firstname" id="firstname" value="" />' +
            '</p>' +
            '<p class="field">' +
                '<label for="email">Votre email <span class="required">*</span> : </label>' +
                '<input type="text" name="email" id="email" value="" />' +
            '</p>' +
            '<p class="field">' +
                '<label for="company">Votre société : </label>' +
                '<input type="text" name="company" id="company" value="" />' +
            '</p>' +
            '<p class="field">' +
                '<label for="telephone">Votre téléphone : </label>' +
                '<input type="text" name="telephone" id="telephone" value="" />' +
            '</p>' +
            '<div class="field">' +
                '<ul>' +
                    '<li><label for="vl"><input type="checkbox" name="vl" id="vl" value="oui" />Valeurs liquidatives</label></li>' +
                    '<li><label for="rm"><input type="checkbox" name="rm" id="rm" value="oui" />Reporting mensuels</label></li>' +
                    '<li><label for="f"><input  type="checkbox" name="f"  id="f"  value="oui" />Flash</label></li>' +
                '</ul>' +
            '</div>' +
    	    '<p class="field">' +
        		'<label for="security">Code de sécurité <span class="required">*</span> : </label>' +
        		'<input type="text" name="security" id="security" value="" style="width:126px" />' +
        		'<img id="security-img" style="float:right;margin:0 63px 0 0;" src="/medias/security-imgs/' + Math.floor(Math.random()*5) + '.png" alt="" />' +
    	    '</p>' +
            '<p class="form-commands">' +
                '<input type="submit" value="Valider" />' +
            '</p>' +
            '<p class="required"><span>*</span> Champs obligatoires.</p>'
        '</fieldset>';

        this.form.update(fields);

		$(document.body).insert({bottom: this.pane.insert(this.form)});
		this.redraw();

        this.form.observe('submit', this.submitForm.bindAsEventListener(this, this.pane));

		$('category').disable();
		$('type').observe('change', function(){
			if('société' == $F('type'))
			{
				$('category').enable();
			}
			else
			{
				$('category').disable();
			}
		});

		return this.form;
	},

	removePane: function()
	{
        if(this.pane)
        {
            this.pane.remove();
        }
	},

	redraw: function()
	{
		var scr = document.viewport.getDimensions();

		this.bg.setStyle({position: 'fixed', zIndex: 10000, top: '0px', left: '0px', width: scr.width + 'px', height: scr.height + 'px', backgroundColor: '#000000', opacity: .8});
		if(this.pane)
		{
			this.pane.setStyle({position: 'fixed', zIndex: 10001, width: '378px', height: '374px', left: ((scr.width-378)/2) + 'px', top: ((scr.height-374)/2) + 'px'});
		}
	},

	showForm: function()
	{
		this.createPane();

		this.toggleBackground();

	},

	hideForm: function()
	{
		this.removePane();
		this.toggleBackground();
	},

    submitForm: function(event, pane)
    {
        event.stop();

        if($F('lastname') && $F('firstname') && $F('email') && $F('security'))
        {
            var code = parseInt($('security-img').src.substring($('security-img').src.lastIndexOf('.')-1, $('security-img').src.length));

    	    if((0 == code && $F('security') == 'LR84fq')  ||
    	       (1 == code && $F('security') == '6Mg84w')  ||
    	       (2 == code && $F('security') == 'pX239u')  ||
    	       (3 == code && $F('security') == 'i7nc42H') ||
    	       (4 == code && $F('security') == 'k33Sw2'))
    	    {
                new Ajax.Request('/index/subscription',
                {
                    method    : 'post',
                    parameters: $('acofi-subscription-form').serialize(),
                    onSuccess : function(){
                        pane.update('<h3 id="subscription-confirmation">Votre demande a bien été envoyée à un de nos conseillers.</h3>');
                        var timer = setTimeout(this.hideForm.bind(this), 1800);
                    }.bind(this)
                });
            }
            else
            {
        		alert('Le code de sécurité saisi est incorrect.');

        		$('security').setStyle({border: '1px solid #EA8B24'});
    	    }
        }
        else
        {
            if(!$F('security'))
    	    {
    		  $('security').setStyle({border: '1px solid #EA8B24'});
    	    }
    	    else
    	    {
    		  $('security').setStyle({border: 'inherit'});
    	    }

            if(!$F('lastname'))
            {
                $('lastname').setStyle({border: '1px solid #EA8B24'});
            }
            else
            {
                $('lastname').setStyle({border: 'inherit'});
            }

            if(!$F('firstname'))
            {
                $('firstname').setStyle({border: '1px solid #EA8B24'});
            }
            else
            {
                $('firstname').setStyle({border: 'inherit'});
            }

            if(!$F('email'))
            {
                $('email').setStyle({border: '1px solid #EA8B24'});
            }
            else
            {
                $('email').setStyle({border: 'inherit'});
            }
            alert('Merci de renseigner tous les champs du formulaire.');
        }
    }
});

var MainNavigationWidget = Class.create(
{
    initialize: function()
    {
        this.toggle   = $('toggle-navigation');
        this.nav      = $('main-navigation-container').hide();
        this.updating = false;

        this.toggle.observe('click', this.toggleNav.bindAsEventListener(this));
    },

    toggleNav: function(event)
    {
        event.stop();

        if(!this.upating)
        {
            if(this.nav.visible())
            {
                new Effect.BlindUp(this.nav, {
                    duration: .3,
                    beforeStart: function(){
                        this.updating = true;
                    }.bind(this),
                    afterFinish: function(){
                        this.updating = false;
                        this.toggle.update('menu +');
                    }.bind(this)
                });
            }
            else
            {
                 new Effect.BlindDown(this.nav, {
                    duration: .3,
                    beforeStart: function(){
                        this.updating = true;
                    }.bind(this),
                    afterFinish: function(){
                        this.updating = false;
                        this.toggle.update('menu -');
                    }.bind(this)
                });
            }
        }
    }
});

document.observe('dom:loaded', function()
{
    [$('menu-section7'), $('menu-section37')].invoke('remove');

    $$('#Vmenu-root li').each(function(li){
       li.observe('mouseover', function(){ li.addClassName('hover'); });
       li.observe('mouseout', function(){ li.removeClassName('hover'); });
    });

    $$('#Vmenu-root li ul li').each(function(li){
        var elements = li.childElements();

        if(elements.length>1)
        {
            elements[0].insert("&nbsp;&nbsp;&raquo; ")
        }
    });

//    new NavMenu('main-navigation-container', {remove: [$('menu-section7'), $('menu-section37')]});
//    new MainNavigationWidget();
//    new NavigationMenu();
	new NavigationWidget();
    new AcofiPlayerWidget();
	new MoreWidget();
	new FormsWidget();
    new CallYouBackWidget();
    new SubscriptionWidget();
    new ClientsLoginWidget();
});

// ]]>

