$(document).ready(function() {

	$('.stream-box ul li a').click(function() {

		var rel = $(this).attr('href');

		$(rel).show().siblings('div').hide();
		
		$(this).parent('li').siblings('li').removeClass('ui-tabs-selected');
		$(this).parent('li').addClass('ui-tabs-selected');
		return false;
	}).each(function() {
		var rel = $(this).attr('href');
		if ($(rel).text().length==0) {
			var self = this;
			$(self).remove();
		}

	});

	$('.streamlinks a').live('click',function() {
		var href = $(this).attr('href');
		stream_pop(500,300,href);
		return false;
	})

	$('.stream-box').each(function() { $('ul li a:first',this).click(); });
});

function stream_pop(b, h, url)	{

	var tpop_bildschirmx = screen.availWidth;
	var tpop_bildschirmy = screen.availHeight;

	var tpop_breite = b;
	var tpop_hoehe = h;

	var tpop_startx = Math.round(tpop_bildschirmx / 2) - (tpop_breite / 2);
	var tpop_starty = Math.round(tpop_bildschirmy / 2) - (tpop_hoehe / 2);

	var popup = window.open('/'+url, 'stream', 'width='+ b + ', height=' + h
				+ ', status=no, toolbar=no, menubar=no, resizable=yes, scrollbars=no, screenX=' + tpop_startx
				+ ', left=' + tpop_startx + ', screenY=' + tpop_starty + ', top=' + tpop_starty + ' ');
			popup.focus();
	return false;
}

