function Player( stream, mode ) {
	switch( stream ) {
		case 'lo':
			save1 = true;
			break;
		case 'hi':
			save1 = true;
			break;
		case 'ogg':
			save1 = true;
			break;
		default:
			save1 = false;
			stream = false;
			break;
	}
	switch( mode ) {
		case 'flash':
			save2 = true;
			break;
		case 'java':
			save2 = true;
			break;
		case 'mobile':
			save2 = true;
			break;
		default:
			save2 = false;
			mode = false;
			break;
	}
	if( save1 && save2 ) save = true;
	else save = false;

	NewPlayer = window.open( 'http://www.kanal-ratte.de/player/Player.php?stream='+stream+'&mode='+mode+'&save='+save, 'Webradio', 'width=300,height=250' );
	NewPlayer.focus();
}
function Chat( nickname ) {
	NewChat = window.open( 'http://www.kanal-ratte.de/irc/login.php?nickname='+nickname, 'Chat', 'width=770,height=570' );
	NewChat.focus();
}

function plugins() {
	var agt = navigator.userAgent.toLowerCase();
	var ie  = ( agt.indexOf( "msie" ) != -1 );
	var ns  = ( navigator.appName.indexOf( "Netscape" ) != -1 );
	var win = ( ( agt.indexOf("win")!=-1 ) || ( agt.indexOf( "32bit" ) != - 1) );
	var mac = ( agt.indexOf( "mac" )!= -1 );

	if( ie && win ) {
		pluginlist = detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash"); 
	}
	if( ns || !win ) {
		nse = "";
		for( var i = 0; i < navigator.mimeTypes.length; i++ ) {
			nse += navigator.mimeTypes[i].type.toLowerCase();
		}
		pluginlist = detectNS( "application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash");
	}
	function detectIE( ClassID, name ) { 
		result = false;
		document.write( '<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n' );
		if( result ) return name+',';
		else return '';
	}
	function detectNS( ClassID, name ) { 
		n = "";
		if( nse.indexOf( ClassID ) != -1 ) {
			if( navigator.mimeTypes[ClassID].enabledPlugin != null ) {
				n = name+","; return n;
			}
		}
	}
	pluginlist += navigator.javaEnabled() ? "Java," : "";
	if( pluginlist.length > 0 ) {
		pluginlist = pluginlist.substring( 0, pluginlist.length - 1 );
	}
	return pluginlist;
}

function readshow( secs, padd, drtn ) {
	factor = 30;
	interval = 60;

	if( secs == null ) secs = 0;
	else secs = ( ( secs * factor ) - 1 ) / factor; 
	if( padd == null ) padd = 0;
	if( drtn == null ) drtn = 0;

	// Nach Ablauf der Zeit neue Daten holen:
	if( secs <= 0 ) {
		secs = interval;
		t1 = $( '#ticker1' ).html();
		$.get( '/title?' + Math.random() * 1000, function( data ) {
			$( '#ticker2' ).html( data );
			$( '#ticker1' ).html( data );
		} );
		t2 = $( '#ticker1' ).html();
		if( t1 != t2 ) {
			padd = 0;
			drtn = 0;
		}
	}
	// Ansonsten Marquee-Effekt:
	max = $( '#hmenu' ).width() - $( '#ticker2' ).width() - 510;
	if( max > 0 ) {
		if( drtn == 0 && padd < max ) padd++;
		else drtn = 1;
		if( drtn == 1 && padd > 0 ) padd--;
		else drtn = 0;
	} else if( max < 0 ) {
		if( drtn == 0 && padd > max ) padd--;
		else drtn = 1;
		if( drtn == 1 && padd < 0 ) padd++;
		else drtn = 0;
	}
	$( '#ticker1' ).css( 'margin-left', padd );
	setTimeout( 'readshow( ' + secs + ', ' + padd + ', ' + drtn + ' )', 1000 / factor );
}

