jQuery(document).ready(function($) {

	setInterval('gallery_rotate()', 5000);


	$('#viewvids').click(function() {

		if ($(this).hasClass('right')) {
			$('#column_container').stop().animate({ left: '-400' }, 1000);
			$(this).html('&laquo; Back');
		} else {
			$('#column_container').stop().animate({ left: '0' }, 1000);
			$(this).html('View More Videos &raquo;');
		}
		$(this).toggleClass('right');

		return false;

	});

	$('#header-slider').cycle();

});

var gallery_row = 1;
var next_gallery_row = 2;
var speed = 500;

function gallery_rotate() {

	var $ = jQuery.noConflict();

	for(i=1;i<=5;i++) {

		//$('#gallery_row'+next_gallery_row+' li:nth-child('+i+')').delay(((i*1000))-500);
		$('#gallery_row'+gallery_row+' li:nth-child('+i+')').delay(((i-1)*speed)).animate({ opacity : 0 }, speed);
		$('#gallery_row'+next_gallery_row+' li:nth-child('+i+')').delay(((i-1)*speed)).delay(speed).animate({ opacity : 1 }, speed);

	}

	gallery_row++;
	next_gallery_row++;
	if (gallery_row > 2) { gallery_row = 1; }
	if (next_gallery_row > 2) { next_gallery_row = 1; }

}


function onYouTubePlayerReady(playerId) {
	player = document.getElementById("myytplayer");
}

function switch_video(id,obj) {
	player.loadVideoById(id, 0, 'medium');

	jQuery('#vidlist a').removeClass('playing');
	jQuery(obj).addClass('playing');

	return false;
}
