/// Main menu hover
$(function () {
  $('ul.menu > li').each(function(index, item) {
    var color = '';
    
    if (index % 4 == 0)
      color = '#e11a1a';
    else if (index % 4 == 1)
      color = '#68cd2d';
    else if (index % 4 == 2)
      color = '#2aa9d0';
    else if (index % 4 == 3)
      color = '#deda1b';
    
    $(this).hover(
      function () {
        $(this).css('background-color', '#2aa9d0');
        $(this).children('a').css('color', 'white');
      },
      function () {
        $(this).css('background-color', '');
        $(this).children('a').css('color', '');
      }
    );
  });
});

/// Top menu hover
$(function () {
  $('ul#header-menu > li').each(function(index, item) {
    var color = '';
    
    if (index == $('ul#header-menu > li').length - 1)
      return;
    
    if (index % 4 == 0)
      color = '#e11a1a';
    else if (index % 4 == 1)
      color = '#68cd2d';
    else if (index % 4 == 2)
      color = '#2aa9d0';
    else if (index % 4 == 3)
      color = '#deda1b';
    
    $(this).hover(
      function () {
        $(this).css('background-color', '#2AA9D0');
        $(this).children('a').css('color', 'white');
      },
      function () {
        $(this).css('background-color', '');
        $(this).children('a').css('color', '');
      }
    );
  });
});

/// Side menu hover
$(function () {
  $('ul.side-menu > li').has('a').each(function(index, item) {
    var color = '';
    
    if (index % 4 == 0)
      color = '#e11a1a';
    else if (index % 4 == 1)
      color = '#68cd2d';
    else if (index % 4 == 2)
      color = '#2aa9d0';
    else if (index % 4 == 3)
      color = '#deda1b';
    
    $(this).hover(
      function () {
        $(this).css('background-color', '#2aa9d0');
      },
      function () {
        $(this).css('background-color', '');
      }
    );
  });
});


/// collapse
$(function () {
  $('.collapse-msg')
  .each(function () {
    var a = $('<a href="">' + $(this).attr('title') + '</a>');
    
    a.click(function () {
      $('.collapse-msg').slideUp('400');
      
      a.parent().next().stop().slideDown('400');
      
      return false;
    });
    
    $(this).before($('<p></p>').append(a));
  })
  .hide();
  
  $($('.collapse-msg')[0]).show();
});


