var J = jQuery.noConflict();
J(function () {
  // IE6 doesn't handle the fade effect very well - so we'll stick with
  // the default non JavaScript version if that is the user's browser.
  if (J.browser.msie && J.browser.version < 7) return;
  
  J('#navigation li')
  
    // remove the 'highlight' class from the li therefore stripping 
    // the :hover rule
    .removeClass('highlight')
    
    // within the context of the li element, find the a elements
    .find('a')
    
    // create our new span.hover and loop through anchor:
    .append('<span class="hover" />').each(function () {
      
      // cache a copy of the span, at the same time changing the opacity
      // to zero in preparation of the page being loaded
      var Jspan = J('> span.hover', this).css('opacity', 0);
      
      // when the user hovers in and out of the anchor
      J(this).hover(function () {
        // on hover
        
        // stop any animations currently running, and fade to opacity: 1
        Jspan.stop().fadeTo(500, 1);
      }, function () {
        // off hover
        
        // again, stop any animations currently running, and fade out
        Jspan.stop().fadeTo(1500, 0);
      });
    });



J(".fadeThis")
.append('<span class="hover"></span>').each(function() {
var a=J("> span.hover",this).css("opacity",0);
J(this).hover(function() {
a.stop().fadeTo(500,1);
}, function() {
a.stop().fadeTo(500,0);
});
});

// initialize scrollable
J("#chained").scrollable({mousewheel: true}).navigator().autoscroll({ autoplay: true, interval: 12000 });

J(".items img").click(function() {

	// see if same thumb is being clicked
	if (J(this).hasClass("active")) { return; }

	// calclulate large image's URL based on the thumbnail URL (flickr specific)
	var url = J(this).attr("src").replace("_t", "");

	// get handle to element that wraps the image and make it semi-transparent
	var wrap = J("#image_wrap").fadeTo("medium", 0.5);

	// the large image from www.flickr.com
	var img = new Image();


	// call this function after it's loaded
	img.onload = function() {

		// make wrapper fully visible
		wrap.fadeTo("fast", 1);

		// change the image
		wrap.find("img").attr("src", url);

	};

	// begin loading the image from www.flickr.com
	img.src = url;

	// activate item
	J(".items img").removeClass("active");
	J(this).addClass("active");

// when page loads simulate a "click" on the first image
}).filter(":first").click();

});
