j$ = jQuery.noConflict();

j$(document).ready(function(){
	
   //various display fixes, because I'm a CSS idiot
  function setLengths() {
    if (j$("#rightcol").length) {
      j$("#rightcol").height( j$("#content").height());  	
    }
    j$("#container").height("auto").height( j$("#container").height() - 20);  	
  }
  
  j$("li .info").each(function(i) {
    j$(this).width( j$(this).prev("a").width()-2);
  });
  
  stripe_padding = parseInt ((j$("#ces-stripe").width() - j$("#ces-stripe ul").innerWidth())/2);
  j$("#ces-stripe ul").css("left",stripe_padding);
  
  //actual behaviors
  j$("#ces-stripe li a").hover(function(){
    j$(this).next("div").fadeIn("fast");
  },function(){
    j$(this).next("div").fadeOut("fast");      
  });
  
  j$("#tools #grow, #tools #shrink").hover(function(){
    j$(this).addClass("hover");
  },function(){
    j$(this).removeClass("hover");      
  });
  
  j$("#searchbutton").click(function() {
    j$(this).parent("form").submit();
  });
  
  j$("#search input, #signup input").resettable();
  
  j$("#shrink").click(function() {
    fontShrink(".contents, .side p");
  });

  j$("#grow").click(function() {
    fontGrow(".contents, .side p");
  });
  
  j$("#slideshow").innerfade({
    speed:'slow',
    timeout:8000,
    containerheight:410
  });
  
  function fontShrink( elements ) {
    j$(elements).each(function(i){
      j$(this).css("font-size",function(i,curr) {
        return parseInt(curr)-2;
      });
    });
    setLengths();
  }

  function fontGrow( elements ) {
    j$(elements).each(function(i){
      j$(this).css("font-size",function(i,curr) {
        return parseInt(curr)+2;
      });
    });
    setLengths();
  }
    
  setLengths();
  
  today = new Date();
  j$("span#year").html(today.getFullYear()); 
	
	j$('ul#navigation').superfish({
		animation:{height:'show'},
		speed:'fast',
		delay:300,
		dropShadows:false,
		autoArrows:false
	});
  
});

