$(document).ready(function(){ 
		
		$('#words').focus(function(){ var tmp = $(this).val(); if (tmp == 'Enter your search term') { $(this).val(''); } });
		$('#words').blur(function(){ var tmp = $(this).val(); if (tmp == '') { $(this).val('Enter your search term'); } }); 
		
		$('#searchform').submit(function(){

			var tmp = $('#words').val(); if (tmp == 'Enter your search term') { $('#words').val(''); }	
			return true;
		});
		
		
		$('#nav ul li:not("ul ul li")').hover(
        function(){
          var el_o = $(this).position();
          var el_w = $(this).width();
          if($(this).children('ul').size() > 0){
            $(this).append('<div class="nav-tri" />')
            $('.nav-tri',this).css({
              left: el_o.left+el_w/2-7
            });
          }
          $(this).addClass('active');
          var ul_h = $(this).children('ul').innerHeight();
          $(this).children('ul').show();
          if ($(this).children('ul').width()) {
            $('#sub-nav').height(ul_h).show();
          }
        },
        function(){
          $('.nav-tri',this).remove();
          $(this).removeClass('active');
          $(this).children('ul').hide();
          $('#sub-nav').height(0).hide();
        }
      );
      
      //home-nav set width
      var rotator_li_w = 0;
      $('#home-nav ul li').each(function(){
        rotator_li_w += $(this).innerWidth();
      });
      $('#home-nav-wrap ul').width(rotator_li_w);
      
      //setup collapsable footer
      $('#footer-collapse').click(function(){
        if($(this).hasClass('collapsed')) {
          $(this).removeClass('collapsed').html('Collapse Footer');
          $('#footer-top').slideToggle();
          $('html, body').animate({scrollTop: $(document).height()}, 'slow');
        } else {
          $(this).addClass('collapsed').html('Open Footer');;
          $('#footer-top').slideToggle();
        }
      });   
      
      //add coner div to adlets
      $('.adlet').each(function(){
        $(this).append('<div class="adlet-corner"/>');
      });
      
      //setup news tabs 
      $("#news-tabs").tabs();
      
      //setup main rotator
      $('#slides').cycle({
        pager: '#slide-nav'
      });
      
      //setup gallery rotator
      $('#gallery-images').cycle({
        prev: '#gallery-prev',
        next: '#gallery-next',
        fx: 'scrollHorz',
        timeout: 0
      });
	  
	  //setup image caption width after full page has loaded
	  $(window).bind("load", function() {
      $('.image-caption').each(function(){
        img_width = $(this).find('img').width();
        $(this).width(img_width + 6);
      });
    });
	  
	  //setup news tabs 
	  $("#major-minor-tabs").tabs();
	  
	   //setup top right nav
      $('#right-nav > ul li:not("ul ul li")').hover(
        function(){
          var el_o = $(this).position();
          var el_w = $(this).width();
          $(this).append('<div class="nav-tri" />')
          $('.nav-tri',this).css({
            left: el_o.left+el_w/2
          });
          $(this).children('ul').show();
        },
        function() {
          $('.nav-tri',this).remove();
          $(this).children('ul').hide();
        }
      );
	  
	  });
