// BEGIN: image rollovers
// see http://www.freaksauce.com/blog/2007/03/simple-jquery-rollovers.html

var J = jQuery.noConflict();

J(document).ready(function(){
	
	var myGallery = new gallery($('myGallery'), {timed: true,showCarousel: false, showArrows: false});

	// rollover code
	J('.rollover').hover(
		function() {
			curr = J(this).find('img').attr('src');
			over = curr.replace(/_off\./, '_on.');
			J(this).find('img').attr({ src: over});
		},
		function() {
			J(this).find('img').attr({ src: curr});
		}
	)

	// preload images
	J('.rollover').find('img').each(function(i) {
		temp = this.src;
		pre = temp.replace(/_off\./, '_on.');
		preload_image_object = new Image();
		preload_image_object.src = pre;
	});
});

// END: rollovers


// BEGIN: jquery news scroller
// see http://www.learningjquery.com/2006/10/scroll-up-headline-reader

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

J(document).ready(function(){
	headline_count = J('#headlines li').size();
	J('#headlines li:eq('+current_headline+')').css('top', '0px');

	headline_interval = setInterval(headline_rotate,5000);
});

function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count;
	J('#headlines li:eq(' + old_headline + ')')
	.animate({top: -29}, 'slow', function() {
		J(this).css('top', '30px');
	});
	J('#headlines li:eq(' + current_headline + ')')
	.animate({top: 0}, 'slow'); 
	old_headline = current_headline;
}

// END: scroller


// BEGIN: jQuery tabs
// see http://jqueryfordesigners.com/jquery-tabs/

J(document).ready(function() {
    var tabbed = J('div.categories > div');
    
    J('div.categories ul.category_list a').click(function () {
        tabbed.hide().filter(this.hash).show();
        
        J('div.categories ul.category_list a').removeClass('selected');
        J(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});

// END: tabs


// BEGIN: toggle Credits listings 

J(document).ready(function() {
	J('ul.credits li .desc').hide();
	J('ul.credits li .desc').parent().find('span').addClass("hover");

	J('ul.credits li span').click(function() {
		// this item
		J(this).parent().find('.desc').parent().toggleClass('active');
		J(this).parent().find('.desc').slideToggle('fast');

		// other items
		J(this).parent().siblings().removeClass('active');
		J(this).parent().siblings().find('.desc').slideUp('fast');
		J(this).parent().parent().siblings().find("li").removeClass('active');
		J(this).parent().parent().siblings().find('.desc').slideUp('fast');
	});
});

// END: toggle credits


// BEGIN: jquery flash plugin code
// see http://jquery.lukelutman.com/plugins/flash/

// inline mp3s
J(document).ready(function(){
    J('a[@href$="mp3"]').flash(
        { src: '/flash/musicplayer.swf', height: 21, width: 72 },
        { version: 7 },
        function(htmlOptions) {
            Jthis = J(this);
            htmlOptions.flashvars.song_url = Jthis.attr('href');
			htmlOptions.flashvars.width = '72';
			htmlOptions.flashvars.height = '21';
			htmlOptions.flashvars.buttons = '/images/play_button.jpg,/images/play_button.jpg,/images/playing_button.jpg,/images/play_button.jpg';
            Jthis.before(J.fn.flash.transform(htmlOptions));
			J(this).parent().addClass('flash-replaced');
			J(this).addClass('alt');
        }
    );
});

// flash movie playlists
J(document).ready(function(){
	J('#movie_player').flash(
		{ 
			src: '/flash/mediaplayer.swf',
			width: 595,
			height: 230,
			allowscriptaccess: 'always',
			allowfullscreen: 'true',
			flashvars: {
				file: '/movies/playlist.php',
				backcolor: '0xFFFFFF',
				frontcolor: '0x002d5b',
				lightcolor: '0x3b71b7',
				screencolor: '0x000000',
				displaywidth: '297',
				autoscroll: 'false',
				shuffle: 'false'
			}
		},
		{ version: 8 }
	);
});

// flash banner
// J(document).ready(function(){
// 	J('#banner').flash(
// 		{ 
// 			src: '/flash/banner.swf',
// 			width: 800,
// 			height: 128,
// 		},
// 		{ version: 8 }
// 	);
// });

// END: flash plugin