$(document).ready(function() {
    var pause = 0;

    $('.up').css({top: '0px' });
    $('.down').css({top: '130px'});
    
   $('#nav li a').hover(
       function () {
        var content = $(this).html();
        var width = $(this).width();
        var height = $(this).height();
        var offset = $(this).offset();
        var left = offset.left;
        var top = offset.top;
        $(this).before('<img src="/images/hover.png" width="'+width+'" height="'+height+'" style="position: absolute; left: '+left+'; top: '+top+';>');
      },
      function() {
        $(this).children('img').remove();
      }
   )
   // set opacity to nill on page load
    $("#nav li a span.hvr").css("opacity","0");
    // on mouse over
    $("#nav li a span.txt").hover(function () {
        // animate opacity to full
        $(this).prev().stop().animate({
            opacity: 1
        }, "slow");
    },
    // on mouse out
    function () {
        // animate opacity to nill
        $(this).prev().stop().animate({
            opacity: 0
        }, "slow");
    });
        
   $("#nav li").hover(
        function() {
            $(this).children("img").fadeTo(200, 0.85).end().children(".hover").show();
        },
        function() {
            $(this).children("img").fadeTo(200, 1).end().children(".hover").hide();
        }
   );
   
   // set opacity to nill on page load
    $("#footer li a span.hvr").css("opacity","0");
    // on mouse over
    $("#footer li a span.txt").hover(function () {
        // animate opacity to full
        $(this).prev().stop().animate({
            opacity: 1
        }, "slow");
    },
    // on mouse out
    function () {
        // animate opacity to nill
        $(this).prev().stop().animate({
            opacity: 0
        }, "slow");
    });
        
   $("#footer li").hover(
        function() {
            $(this).children("img").fadeTo(200, 0.85).end().children(".hover").show();
        },
        function() {
            $(this).children("img").fadeTo(200, 1).end().children(".hover").hide();
        }
   );

   function banner_rotator() {  
      $('.up').delay('5000').animate({
        top: '130px', opacity: 0.25
      }, 300, function() {
        $(this).removeClass('up').addClass('down');
        if($(this).next().length == 0) {
            $('#banner div:first-child').addClass('up').animate({top: '0px', opacity: 1}, 300, function() {
               $(this).addClass('up');
               banner_rotator();   
            });
        } else {
            $(this).next().animate({top: '0px', opacity: 1}, 300, function() {
               $(this).addClass('up'); 
               banner_rotator();   
            });
        }
      });
   }
   
   function banner_rotator_ie() {  
      $('.up').delay('5000').animate({
        top: '130px'
      }, 300, function() {
        $(this).removeClass('up').addClass('down');
        if($(this).next().length == 0) {
            $('#banner div:first-child').addClass('up').animate({top: '0px'}, 300, function() {
               $(this).addClass('up');
               banner_rotator_ie(); 
            });
        } else {
            $(this).next().animate({top: '0px'}, 300, function() {
               $(this).addClass('up'); 
               banner_rotator_ie(); 
            });
        }
      });
   }
   
   if ($.browser.msie) {
      $('.up').css({top: '0px'});
      $('.down').css({top: '130px'});
      banner_rotator_ie();
   } else {
      $('.up').css({top: '0px', opacity: 1  });
      $('.down').css({top: '130px', opacity: 0 });
      banner_rotator();   
   }

});
