$(function() {

	$(document).pngFix(); 

	Cufon.replace(".cufon", { fontFamily: 'Vag' });
	Cufon.replace(".cufonBold", { fontWeight: 'bold' });

	// buttonOver
	if($.browser.mozilla || $.browser.safari) {
  	$('.buttonOver').each(function() {
      $(this).hover(function() {
        $(this).stop().animate({ opacity: 0.5 }, 200);
      },
	        
      function() {
        $(this).stop().animate({ opacity: 1 }, 200);
      });
    });
	}

  // Widget handling construct for any fanciness -->
  var widgetHandler = {
    speed: 1000,
    pause: 4000,

    init: function() {
      widgetHandler.initializeRotatingArticles();
    },

    initializeRotatingArticles: function() {
      setInterval(widgetHandler.removeFirst, widgetHandler.pause);
    },
    
    removeFirst: function() {
      var item = $('.articles ul li:first'),
          first = item.html();

      item.animate({ marginTop: '-' + item.height() + 'px' }, widgetHandler.speed, function() {
        $(this).remove();
      });

      widgetHandler.appendLast(first);
    },

    appendLast: function(markup) {
      $('.articles ul').append('<li class="item active">' + markup + '</li>');
    }

  };

  widgetHandler.init();

  // Navigation construct for fixes -->
  var dropDownNav = {
    init: function() {
      dropDownNav.subPageFix();
    },

    subPageFix: function() {
      $('.dropDown .section').hover(function() {
        var section   = $(this),
            drop_down = section.closest('.dropDown'),
            sub_nav   = section.find('.secondLevelSections'),
            height    = sub_nav.height();

        drop_down.height(height);
      });
    }
  };

  dropDownNav.init();

});
