jQuery.noConflict();

jQuery(document).ready(function(){
	
	// check if main image is actually a swf, and load it
	mainImg = jQuery('#feature img').attr('src');
	if (mainImg.slice(mainImg.length - 3).toLowerCase() == 'swf') {
		showSWF(mainImg);
	};
	
	// preload images
	thumbnailLinks = jQuery('#thumbnails a');
	for (var i=1; i < thumbnailLinks.length; i++) {
		jQuery.preloadImages(thumbnailLinks[i].href);
	};

	jQuery('#thumbnails a').click(function(){
		newImage = this.href;
		if (newImage.slice(newImage.length - 3).toLowerCase() == 'swf') {
				jQuery('#feature #flash').remove();
				showSWF(newImage);
		} else {
			jQuery('#feature #flash').remove();
			jQuery('#feature img').fadeOut('fast', function(){
				jQuery('#feature img').attr({src: newImage});
			}).fadeIn('fast');
		};
		return false;
	});
});

jQuery.preloadImages = function() {
  for(var i = 0; i < arguments.length; i++) {
	tempImage = new Image;
	tempImage.src = arguments[i];
  }
}

function showSWF(swfURL) {
	jQuery('#feature img').hide();
	jQuery('#feature').append('<div id="flash"></div>');
	var so = new SWFObject(swfURL, "mymovie", "397", "297", "6", "#000000");
	so.write("flash");
}
