(function ($) {
  Drupal.behaviors.team537 = {
    attach: function(context, settings) {

      /* Search placeholder */
      $('#search-block-form .form-text').val('Search');
      $('#search-block-form .form-text').css('color', 'gray');
      $('#search-block-form .form-text').focus(function() {
        if($('#search-block-form .form-text').val() == 'Search') {
          $('#search-block-form .form-text').css('color', 'black');
          $('#search-block-form .form-text').val('');
        }
      });
      $('#search-block-form .form-text').focusout(function() {
        if($('#search-block-form .form-text').val() == ''){
          $('#search-block-form .form-text').css('color', 'gray');
          $('#search-block-form .form-text').val('Search');
        }
      });

      /* AnythingSlider
      $('#carousel .view-content ul').anythingSlider({
        width          : 900,
        height         : 250,
        resizeContents : true,
        startStopped   : true,
        toggleControls : false,
        theme          : 'metallic',
        autoPlay       : true,
        delay          : 15000,
        hashTags       : false
      });
      */
      
      /* Logo fade */
      if ($.browser.webkit || $.browser.mozilla || $.browser.safari || $.browser.opera) {
        $('#logo').append('<div></div>');
        $('#logo a').removeClass("no-fade");
        $('#logo a').hover(function() {
          $('#logo div').stop(true, true).fadeIn(500);
        }, function() {
          $('#logo div').stop(true, true).fadeOut(500);
        });
      }

      /* Page styles */
      $("#content *").filter( function() {
        if ( /^(left)$/.test($(this).css("float")) == true) {
          $(this).css('margin-top', '0');
          $(this).css('margin-left', '0');
        }
        else if ( /^(right)$/.test($(this).css("float")) == true) {
          $(this).css('margin', '0 0 25px 25px');
        }
      });
      
      $("#content tr:even").addClass("even");
    
      $(window).load(function() {
        var maxHeight = 0;
        $('.feature').each(function() {
          if ($(this).height() > maxHeight) {
            maxHeight = $(this).height();
          }
        });
        $('.feature').each(function() {
          $(this).height(maxHeight);
        });
        
        $('#carousel .view-content').peKenburnsSlider();
        
        $('header #frc-intro').hover(
        	function() {
						if (!$(this).hasClass('animated')) {
							$(this).dequeue().stop().animate({bottom: '10px'}, 'slow');
						}
					}, 					
					function() {
				    $(this).addClass('animated').animate({bottom: '-35px'}, 'slow', 'linear', 
				    	function() {
								$(this).removeClass('animated').dequeue();
							});
					}
				);
			});
      /* Taxonomy more link */
      /*var maxwidth = 200;
      var currentwidth = 0;
      var out = true;

      $('.views-tags-list li').each(function(index) {
        currentwidth += $(this).width();
        if(currentwidth > maxwidth) {
          $(this).appendTo('#shrink');
        }
      });
      currentwidth = 0;
      $('.views-tags-list li').each(function(index) {
        currentwidth += $(this).width();
        if(currentwidth>maxwidth) {
          $(this).hide();
        }
      });
      $('#moreClick').text("More...");
      currentwidth = 0;
      out = false;

      $('#moreClick').click(function() {
        if (out==true) {
          $('.views-tags-list li').each(function(index) {
            currentwidth += $(this).width();
            if(currentwidth>maxwidth) {
              $(this).hide();
            }
          });
          $('#moreClick').text("More...");
          currentwidth = 0;
          out = false;
        }
        else {
          $('li').each(function(index) {
            currentwidth = 0;
            $(this).show();
          });
          $('#moreClick').text("Less...");
          out = true;
        }
      }); */
    }
  };
})(jQuery);

