(function ($) {

  Drupal.behaviors.pmba_theme = {
    attach: function (context, settings) {
      $(document).ready(function() { 
        
        //rollover swap images with rel 
        var img_src = "";
        var new_src = "";

        $(".rollover", context).hover(function(){
          //mouseover
          img_src = $(this).attr('src'); //grab original image
          new_src = $(this).attr('rel'); //grab rollover image
          $(this).attr('src', new_src); //swap images
          $(this).attr('rel', img_src); //swap images
        },
        function(){
          //mouse out
          $(this).attr('src', img_src); //swap images
          $(this).attr('rel', new_src); //swap images
        });

        //preload images
        var cache = new Array();
        //cycle through all rollover elements and add rollover img src to cache array
        $(".rollover", context).each(function(){
          var cacheImage = document.createElement('img');
          cacheImage.src = $(this).attr('rel');
          cache.push(cacheImage);
        });
        
          jQuery('a.top').click(function(){
            jQuery('html, body').animate({scrollTop:0}, 'slow');
            return false;
          });
                    
          $("#block-user-login h2 span").click(function () {
            $("#user-login-form").slideToggle('fast');    
            $(this).text($(this).text() == 'Member Login' ? 'Close' : 'Member Login');
          });
          
          
          // Balloon Hover Fun      
          $('#join-pmba-balloon a').hover(function() {
            $('#join-pmba-balloon img').animate({ marginTop: '4px', marginLeft: '-4px' }, 100);
          }, function() {
            $('#join-pmba-balloon img').animate({ marginTop: '0', marginLeft: '0' }, 100);         
          });
           
          $('#member-benefits-balloon a').hover(function() {
            $('#member-benefits-balloon img').animate({ marginTop: '3px' }, 100);
          }, function() {
            $('#member-benefits-balloon img').animate({ marginTop: '0' }, 100);         
          });
          
          /*
          $('#join-pmba-balloon a').hover( function(){
            $('#join-pmba-balloon img').animate({
              margin: '3px -2px 0 0'
            })
          }, 
          function(){
            $('#join-pmba-balloon img').animate({
              margin: '0'
            })
          });
          
          
          $('#member-benefits-balloon a').hover( function(){
            $('#member-benefits-balloon img').css('margin-top', '3px');
          },
          function(){
            $('#member-benefits-balloon img').css('margin-top', '0px');
          });
          */
          
        // End $(document).ready().
        
        
      });
    }
  };

}(jQuery));
;

