var kids = [];

$(document).ready(function() {
	$('#listen_now').bind('click', function() {
//		$('#header_top_right_top').slideUp('slow', function() {
//			$('#header_top_right_top').delay(10000).slideDown('slow');
//		});
//		$('#header_top_right_bottom').slideDown('slow', function() {
//			$('#header_top_right_bottom').delay(10000).slideUp('slow');
//		});

		window.open("/listen/player/", "lsrplayer", "status=1, height=600, width=600, resizable=0");
		window.location = "/listen/";
		
		return false;
	});
	
	$('#content_slider').each(function() {
		$('head').append('<style type="text/css">#barrys_content_slider { position: relative; } #barrys_content_slider * { position: absolute; }</style>');
		
		$(this).children('li').hide();
		$(this).children('li').each(function() {
			kids.push(new Array($(this).html(), 300, 300));
		});
		$(this).replaceWith('<div id="barrys_content_slider" style="width: ' + kids[0][1] + 'px; height: ' + kids[0][2] + 'px;" class="0"></div>');
		$('#barrys_content_slider').html(kids[0][0]).hide().fadeIn(5000, function() {
			setInterval(barrys_content_slider, 5000);
		});
	});
	
	$(".zebra tbody tr:nth-child(odd)").addClass("odd");
});

function barrys_content_slider() {
	thisone = parseInt($('#barrys_content_slider').attr('class'));
	thisone++;
	
	if (thisone >= kids.length) {
		thisone = 0;
	}

	$('#barrys_content_slider').attr('class', thisone);
	$('#barrys_content_slider').append(kids[thisone][0]);

//	$('#barrys_content_slider').find('img:first').slideUp(3000, function() {
//		$(this).remove();
//	});
//	$('#barrys_content_slider').find('img:first').next().hide().slideDown(3000);

	$('#barrys_content_slider').find('img:first').next().show("slide", { direction: "right"}, 3000, function() {
		$('#barrys_content_slider').find('img:first').remove();
	});
	
	
//	$('#barrys_content_slider').find(':first').effect("size", { to: { width: 0, height: 0 }, origin: ['middle','right'] }, 3000, function() {
//		$(this).remove();
//	});
//	$('#barrys_content_slider').find(':first').next().effect("size", { from: { width: 0, height: 0 }, to: { width: 300, height: 300 }, origin: ['middle','left'] }, 3000);
}

// new webcam
var webcam_load;
var int_lock = false;

function setup_webcam(target_element, target_image) {
	$('#' + target_element).append('<img src="/elements/site/webcam/webcam-loading.jpg" style="width: ' + $('#' + target_element).width() + 'px;" />');
	setTimeout('run_webcam("' + target_element + '", "' + target_image + '")', 3000);
}
function run_webcam(target_element, target_image) {
	webcam_load = new Image();
	webcam_load.str = target_image + '?' + Math.random();
	webcam_load.onLoad = load_webcam(target_element, webcam_load.str);
	
	if (!int_lock) {
		int_lock = true;
		setInterval("run_webcam('" + target_element + "', '" + target_image + "');", 30000);
	}
}
function load_webcam(target_element, url) {
	if (!webcam_load.complete) {
		setTimeout("load_webcam('" + target_element + "', '" + url + "')", 500);
		return;
	}

	next_webcam = '<img src="' + url + '" style="width: ' + $('#' + target_element).width() + 'px;" />';
	$('#' + target_element).append(next_webcam);

	if ($('#' + target_element).find('img').size() >= 3) {
		$('#' + target_element).find('img').next().fadeOut(1000);
		$('#' + target_element).find('img').next().next().hide(function() {
			$(this).fadeIn(500);
		});
	} else {
		$('#' + target_element).find('img').next().hide(function() {
			$(this).fadeIn(500);
		});
	}
}

