function ieHover(){
        var nav = document.getElementById("nav");
        if (nav)
        {
                var nodes = nav.getElementsByTagName("li");
                for (var i=0; i<nodes.length; i++)
                {
                        nodes[i].onmouseover = function() 
                        {
                                this.className += " hover";
                        }
                        nodes[i].onmouseout = function()
                        {
                                this.className = this.className.replace(" hover", "");
                        }
                }
        }
}

sfHover = function() {
        if(document.getElementById("sounav")){
                //var sfEls = document.getElementById("sounav").getElementsByTagName("LI");
		var sfEls = $$(".sn li");
                for (var i=0; i<sfEls.length; i++) {
                        sfEls[i].onmouseover=function() {
                                this.className+=" sfhover";
                                setSelectVisibility('hidden');
                        }
                        sfEls[i].onmouseout=function() {
                                this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
                                setSelectVisibility('visible');
                        }
                }
        }
}

function setSelectVisibility(v){
        var elem=document.getElementsByTagName('select');
        for(i=0;i<elem.length;i++)
                elem[i].style.visibility=v;
}

if(window.attachEvent) window.attachEvent("onload", function(){if(!window.opera) ieHover(); sfHover();});

/*With Mootools*/
var Form = new Class({
    form: null,
    errorField: null,
    elements: new Array(),
    initialize: function(form, errorField){
        this.form = form;
        this.errorField = errorField;
        this.elements = this.form.getElements('input, select, textarea');
        this.form.getElements('input[type=submit], a[rel=submit]')[0].addEvent('click', function(e){
                e.stop();
            this.valid();
        }.bind(this));
    },
    valid: function(){
        var list = new Object();
        var hashList = null;
        this.elements.each(function(item, index){
            list[item.getProperty('name')] = item.getProperty('value');
        });
        hashList = new Hash(list);
        new Request({url: "/contact/valid_form.php", onSuccess: function(responseText){
            if(responseText == ''){
                this.form.submit();
                return true;
            }
            else{
                this.errorField.empty();
                                this.errorField.innerHTML = responseText;
            }
            return false;
        }.bind(this)}).post(hashList.combine({form_id:this.form.getProperty('id')}));
    }
});
if(window.addEvent){
        window.addEvent('load', function() {
        if ($$('form#contact')[0])
                new Form($$('form#contact')[0], $$('.errormsg')[0]);
        });
}

/*With Mootools*/
if(window.addEvent){
        window.addEvent('load', function() {
                var toggleFx = null;
                var hideFx = null;
                var fxOptions = {duration: 'long', link: 'ignore', transition: 'sine:in:out'};

                if($$('.toggle-content').length > 0){
                        toggleFx = new Fx.Morph($$('.toggle-content')[0], fxOptions);
                        if($$('.toggle-content')[0].getStyle('margin-top') == '0px')
                                toggleFx.start.delay(1000, toggleFx, '.up');
                        hideFx = new Fx.Morph($$('#sub-menu p')[0], fxOptions);
                        showFx = new Fx.Morph($$('#sub-menu ul')[0], fxOptions);
                }
        
                if($$('#sub-menu p').length > 0){
                        $$('#sub-menu p').each(function(item){
                                item.addEvent('click', function(){
                                        var isOut = false;
                                        toggleFx.start('.down');
                    toggleFx.onComplete = function(){
                                                //ToggleFlash.doIt({width: 930, height: 229, container:$$('.flash-holder')[0], src: '/files/flash/capabilities.swf', toggle: true});
                                                var close = function(){
                                                        if(isOut) toggleFx.start('.up');
                                                }
                                                close = close.create({delay: 5000});
                        $$('#inform6')[0].addEvent('mouseover', function(){isOut = true; close();});
                        $$('#inform6')[0].addEvent('mouseout', function(){isOut = false});
                    }
                                        hideFx.start({display: 'none'});
                                        showFx.start({display: 'block'});
                                });
                        }.bind());
                }
                DelValues.init();
                $$('.print').each(function(item){
                        item.addEvent('click', function(){
                                window.print();
                                return false;
                        });
                });
        });
}

var ToggleFlash = {
        content: null,
        doIt: function(){
                var param = arguments[0];
                if(param.toggle){
                        this.content = param.container.innerHTML;
                        new Swiff(param.src, param);
                }else if(this.content)
                        param.container.innerHTML = this.content; 
        }
}

var DelValues = {
        oneTime : true,
        init: function(){
                $$('.delValue').each(function(item){
                                item.addEvent('click', function(e){
                                if(this.oneTime) e.target.set('value', '');
                                this.oneTime = false;
                        }.bind(this));
                }.bind(this));
                $$('.delTargetValue').each(function(item){
                                item.addEvent('click', function(){
                                $$('.delValue').each(function(item){
                                        if(this.oneTime) item.set('value', '');
                                        this.oneTime = false;
                                }.bind(this));
                        }.bind(this));
                }.bind(this));
        }
}

var Lightbox = {
        fxOptions: {duration: 'long', link: 'ignore', transition: 'sine:in:out'},
        init: function(){
                var toggleFx = new Fx.Morph($('lightbox'), this.fxOptions);
                if($$('.close a')[0]){
                        $$('.close a')[0].addEvent('click', function(e){
                                e.stop();
                                toggleFx.start('.lightbox-down');
                        });
                }
                $$('a.lightbox').each(function(item){
                        item.addEvent('click', function(e){
                                e.stop();
                                toggleFx.start('.lightbox-up');
                        });
                });
        }
}

if(window.addEvent){
        window.addEvent('load', function(){
                var lang = $$('html')[0].get('lang');
                /*flashs*/
                if($$('.capabilities')[0]) 
                        new Swiff('/files/flash/capabilities_'+lang+'.swf', {width: 930, height: 229, wmode: 'transparent', container: $$('.flash-holder')[0]});
                if($$('.flash-world')[0])
                        new Swiff('/files/flash/carteImplantation_'+lang+'.swf', {width: 928, height: 453, wmode: 'transparent', container: $$('.flash-world')[0]});
                if($$('.flash-client')[0])
                        new Swiff('/files/flash/carteMonde_client_'+lang+'.swf', {width: 928, height: 453, wmode: 'transparent', container: $$('.flash-client')[0]});
                if($$('.flash-image')[0]){
                        var ItemId = $$('.flash-image')[0].get('id');
                        var flashContainer = new Element('div', {'class': 'flash-image'});
                        new Swiff('/file/flash/DCNS_player_dynamic.swf', {width: 290, height: 207, wmode: 'transparent', vars: {products: ItemId, type: 3}, container: flashContaineri});
                        $$('.flash-image')[0].dispose();
                }
                Lightbox.init();
                if($('contact'))
                        showSelected($$('#contact #lieu')[0], $$('#contact #addresses')[0]);
                Menu.init($$('.select-holder ul'));
                /*products - features*/
                if($('product') && !$('features')) $('product').setStyle('height', 314);
        });
}

var Menu = {
        fxOptions: {property: "opacity", duration: 500},
        fx2Options: {property: "display", duration: 500},
        fxValues: {
                opacity: {0:0, 1:1}, 
                display: {0:'none', 1:'block'}
        },
        parentItem: null,
        isOpen: true,
        init: function(item){
                this.parentItem = item;
                var link = this.getItem(this.parentItem.getElement('a'));
                while(link){
                        var thisObj = this;     
                        link.addEvent('click', function(e){
                                e.stop();
                                if(thisObj.isOpen) thisObj.open((this.getNext('ul').get('opacity') == 0), this.getNext('ul'));
                        });
                        link.getNext('ul').set('opacity', 0);
                        link.getNext('ul').setStyle('display', 'block');
                        if(link.getParent('li').getNext('li'))
                                link = this.getItem(link.getParent('li').getNext('li').getElement('a'));
                        else link = null;
                }
        },
        open: function(isOpen, item){
                var displayType = isOpen ? 1 : 0;
                var visible = true;
                if(isOpen) this.hideItems(item.getParent('ul').getFirst('li'), 'opacity');
                
                var fx = new Fx.Tween(item, this.fxOptions);
                
                fx.start(displayType);
                if(!item.getPrevious('a').hasClass('open'))
                        item.getPrevious('a').addClass('open');
                else visible = false;
                fx.onStart = function(){
                        this.isOpen = false;
                }
                fx.onComplete = function(){
                        this.isOpen = true;
                        if(!visible) item.getPrevious('a').removeClass('open');
                        this.initChildren(item);
                }.bind(this);
        },
        isArray: function(input){
                return typeof(input)=='object'&&(input instanceof Array);
        },
        getItem: function(item){
                if(this.isArray(item)) return item[0];
                else return item;
        },
        hideItems: function(listItem, type){
                var item = null;
                while(listItem){
                        item = listItem.getElement('ul');
                        if(item){
                                var fx = new Fx.Tween(item, type == 'opacity' ? this.fxOptions : this.fx2Options);
                                var itemType =  type == 'opacity' ? item.get(type) : item.getStyle(type);
                                var className = '';
                                if(itemType == this.fxValues[type][1]) fx.start(this.fxValues[type][0]);
                                if(item.getPrevious('a').hasClass('open'))
                                        item.getPrevious('a').removeClass('open');
                                if(item.getPrevious('a').hasClass('deploy'))
                                        item.getPrevious('a').removeClass('deploy');
                        }
                        listItem = listItem.getNext('li');
        }
        },
        initChildren: function(listItem){



                listItem.getElements('a').each(function(item){
                        
                        item.addEvent('click', function(e){
                                if(!e.target.hasClass('deploy')){
                                        var firstItem = null;
                                        var fx = new Fx.Tween(item.getNext('ul'), this.fx2Options);
                                        if(e.target.hasClass('children')){
                                                if(!firstItem) firstItem = e.target;
                                                this.hideItems(item.getParent('ul').getFirst('li'), 'display');
                                                e.target.addClass('deploy');
                                                fx.start('block');
                                        }
                                }
                                if(e.target.hasClass('children')) e.stop();
                        }.bind(this));
                }.bind(this));
        }
}

function showSelected(selectItem, parentList){
    if(selectItem){
        selectItem.addEvent('change', function(){
            var item = parentList.getChildren('div[id$='+this.get('value')+']')[0];
            parentList.getElement('.shown').className = 'hidden';
            item.className = 'shown';
        });
    }
}

function getItemId(id){
        var expression = new RegExp("^(item_)(.*)$");
        var idList = expression.exec(id);
        return idList[1]; 
}

// select box ie fix
if (window.addEvent && Browser.Engine.trident && (navigator.userAgent.toLowerCase().indexOf('msie 6') < 0)) {
      window.addEvent('domready', function() {
          var sbox = $$('select#lieu')[0];

          if (sbox) {
              sbox.addEvents({
                  'mouseover': function() {
                      this.setStyles({
                          'width': 'auto',
                          'position': 'relative',
                          'z-index': 101
                      });
                  },
                  'focus': function() {
                      this.setStyles({
                          'width': 'auto',
                          'position': 'relative',
                          'z-index': 101
                      });
                  },
                  'blur': function() {
                      this.setStyle('width', 200);
                  }
              });
          }
      });
  }

if ($defined($$('div.col3')[0]) && $defined($$('div.col3 h3'))) 
if (($$('div.col3 h3')[0].get('html') == "Nos success stories") || ($$('div.col3 h3')[0].get('html') == "Our success stories")) {
//if ($$('div.col3')[0] && $$('div.col3 h3') && $$('div.col3 h3')[0].get('html') == "Nos success stories") {
var el = $$('div.col3')[0];
var s = el.getStyles('z-index', 'right');
//$merge(s, {'position':'absolute'});
s.position = 'absolute';
el.addEvents({
'mouseover': function(){
        this.morph({
                position : 'absolute',
                right    : 0,
                'z-index': 1000,
                width    : 617
                }, {transition: Fx.Transitions.Sine.easeOut});
        },
'mouseout': function(){
        this.morph(s, {transition: Fx.Transitions.Sine.easeOut});
        }
})
}
function pdf_fadein(){
        $('link_pdf').fade('out');
        $('flag').fade('in');
        function pdffadeout(){
                $('link_pdf').fade('in');
                $('flag').fade('out');

         }
         pdffadeout.delay(5000);
        
        return(false);
}

