
var heightOpen = 100;

function checkActiveElement(id){
   element = false; 

   (function($) {
      if (document.getElementById(id)){
         var kids = $("#" + id).children();

         $.each(kids, function() { 
            classElement = $('#' + this.id).attr("class");
            if (classElement == 'submenuActiv'){
               element = true;
            }
         });	

         if (element == false){
            document.getElementById(id).style.display = 'none'; 
         }
      }
   })(jQuery);
}

function animateBox(box, slideDown){
   (function($) {

      height = ($('#newSubMenu' + box).height());
      if ($("#newSubMenu" + box).is(":hidden") && slideDown) {
         $("#newMenu"  + box).addClass("newMenuActiv"  + box);
         $('#newSubMenu' + box).slideDown('normal');
      }
      else if ($("#newSubMenu" + box).not(":hidden")){
         $("#newMenu"  + box).removeClass("newMenuActiv" + box);
         $('#newSubMenu' + box).slideUp('normal');
      }		
   })(jQuery);
}

function jQueryAnimate(){

   checkActiveElement('newSubMenu1');
   checkActiveElement('newSubMenu2');
   checkActiveElement('newSubMenu3');
   checkActiveElement('newSubMenu4');
   checkActiveElement('newSubMenu5');

   inner = document.getElementById("naviSub").innerHTML;

   if (inner == ''){
      document.getElementById("boxNews2").style.display = 'none';
   }
   else{
      document.getElementById("boxNews2").style.display = 'block';
      document.getElementById("naviSub").style.display = 'block';
   }

   (function($) {
      $('#newMenu1').click(function () {
         animateBox(1, true);
         animateBox(2, false);
         animateBox(3, false);
         animateBox(4, false);
         animateBox(5, false);
      });

      $('#newMenu2').click(function () {
         animateBox(2, true);
         animateBox(1, false);
         animateBox(3, false);
         animateBox(4, false);
         animateBox(5, false);
      });	

      $('#newMenu3').click(function () {
         animateBox(3, true);
         animateBox(1, false);
         animateBox(2, false);
         animateBox(4, false);
         animateBox(5, false);
      });	

      $('#newMenu4').click(function () {
         animateBox(4, true);
         animateBox(1, false);
         animateBox(3, false);
         animateBox(2, false);
         animateBox(5, false);
      });   

      $('#newMenu5').click(function () {
         animateBox(5, true);
         animateBox(1, false);
         animateBox(2, false);
         animateBox(4, false);
         animateBox(3, false);
      });   


   })(jQuery);
}

