var preloadFlag = false;
// Speedtest by #?!.KS.qed-audio
var testimgsize = 277666;
//var testimgsize = 120822;
var udef=typeof(top.t824xfr3);
var teststart=0;
var teststop=0;
var testtime=0;
top.testimg = void(0);
top.conspeed=0;
top.dsl_2k=false;


function gElem(win,id,idx){
	var el;
	if (typeof win.document.getElementById(id) != udef) el = win.document.getElementById(id); 
	else if (typeof win.document.getElementsByName(id) != udef) el = win.document.getElementsByName(id);
	else return void(0);
	return(el);
}

function wElem(win,id,idx,ihtml) {
	if (gElem(win,id,idx)) gElem(win,id,idx).innerHTML=ihtml;
}

function speedtest(){
	wElem(top,"playerwmp",0,"Teste Übertragungsgeschwindigkeit... (max. 5 sec)");
	top.testimg=new Image();
	top.conspeed=0;
	top.dsl_2k=false;
	teststop = 0;
	var t=new Date();
	teststart=t.getTime();
	top.testimg.src = "http://85.214.55.57/cgi-bin/speedtest.cgi?id="+String(teststart)+String(Math.random());
	//top.testimg.src = "http://85.214.55.57/cgi-bin/speedtest.cgi?id="+String(teststart)+String(Math.random());
	window.setTimeout("stoptest()",100);
}

function stoptest() {
	var t=new Date();
	teststop = t.getTime();
	testtime=teststop-teststart;
	if (top.testimg.complete==false) { 
		if (testtime < 4800) {
			window.setTimeout("stoptest()",100); return; 
		} else {
			top.testimg = void(0);
			wElem(top,"playerwmp",0,"Übertragungsrate < 1000 kBit/s bzw. Connect-Fehler.<br><a href=\"javascript:speedtest();\">Erneut prüfen</a>");
			return;
		}
	} else {
		if (top.testimg.height <= 0) {
			top.testimg = void(0);
			return;
		}
	}
	top.conspeed = Math.round((testimgsize*8000)/(testtime*1024));
	if (top.conspeed>=1700) { top.dsl_2k = true; } else { top.dsl_2k = false; }
	top.testimg = void(0);
	writePlayer();
}
function writePlayer(){
  var lostream = "mms://85.214.55.57:1234";
  var histream = "mms://85.214.55.57:1234";
  var usestream = lostream;
  if(top.dsl_2k==true) { usestream = histream; } 
  if (navigator.appName == "Netscape") {
    document.all["playerwmp"].innerHTML = '<embed type="application/x-mplayer2"  pluginpage="http://www.microsoft.com/windows/windowsmedia/download/" width="296" height="237" src="' + usestream + '" volume="100" stretchtofit="true" showstatusbar="1" controller="1" autostart="1" uimode="none" playcount="999"></embed>';
  } else {
    document.all["playerwmp"].innerHTML = '<OBJECT ID="streetclip" width="296" height="237" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"><PARAM NAME="url" VALUE="' + usestream + '"/><PARAM NAME="AutoStart" VALUE="true"/><PARAM NAME="Volume" VALUE="100"/><PARAM NAME="uiMode" VALUE="none"/><param NAME="stretchToFit" VALUE="1"/><param NAME="Playcount" VALUE="999"/></OBJECT>';
  }
}
