$(document).ready(function(){
   $('#langues ul>li>ul').css('display', 'none');

   var langSegments = new Array(
     'inter',
     'europe',
     'northamerica',
     'southamerica',
     'asia',
     'oceania',
     'middleeast'
   );

   for(place in langSegments) {

       $('#langues ul>li#' + langSegments[place]).bind('click',
            function(){
                var statusHolderInter = $(this);
                if(statusHolderInter.attr('animating')!='true') {
                  statusHolderInter.attr('animating', 'true');
                  $(this).children('ul').slideDown('fast', function() { statusHolderInter.attr('animating', '');});
                }
            }).bind('click',
            function(){
                var statusHolderInter = $(this);
                if(statusHolderInter.attr('animating')!='true') {
                  statusHolderInter.attr('animating', 'true');
                  $(this).children('ul').slideUp('fast', function() { statusHolderInter.attr('animating', '');});
                }
            }
       );

   }

   $('#langues ul>li>ul>li').hover(
        function(){
            $(this).css('background-color', '#e4ba72');
        },
        function(){
            $(this).css('background-color', '#000');
        }
   )

   $("#prehome1").css({opacity:1.0,display:"block"}).show();
   $("#prehome2").css({opacity:0,  display:"block"}).show();

  function cycle1(jq, opacity){
     opacity = opacity==1.0 ? 0 : 1.0;
     jq.delay(5000).animate({opacity:opacity}, 1000, function(){
         cycle1(jq,opacity);
     });
  };

  function cycle2(jq, opacity){
     opacity = opacity==1.0 ? 0 : 1.0;
     jq.delay(5000).animate({opacity:opacity}, 1000, function(){
         cycle2(jq,opacity);
     });
  };
  // async fade mode
  cycle1($("#prehome1"),0);
  cycle2($("#prehome2"),1);



});
