function createXMLHttp(){
	if(typeof XMLHttpRequest != "undefined"){
		return new XMLHttpRequest();
	}else if(window.ActiveXObject){
		var arrOfVersions = [
			"MSXML2.XMLHttp.5.0",
			"MSXML2.XMLHttp.4.0",
			"MSXML2.XMLHttp.3.0",
			"MSXML2.XMLHttp",
			"Microsoft.XMLHttp"
		];
		for(var i = 0; i < arrOfVersions.length; i++){
			try{
				var oXmlHttp = new ActiveXObject(arrOfVersions[i]);
				return oXmlHttp;
			}catch(oError){
				alert("XML Error " + oError.description + "\nBitte aktualisieren Sie Ihren Browser");
			}
		}
	}
}

intTimeoutCount = 0;
function loadFile(strCFFile, strContainer){
	//alert(strCFFile);
	intTimeOut = 3000; // MSec
	bTimeOut = false;
	try{
		intStartTime = new Date().getTime();
		var oXMLHttp = createXMLHttp();
		oXMLHttp.open("GET",strCFFile,true);
		try{
			intStartTime = new Date().getTime();
			oXMLHttp.onreadystatechange = function(){
				
				intElapsedTime = new Date().getTime() - intStartTime;
				if(intElapsedTime > intTimeOut){
					bTimeOut = true;
					intTimeoutCount++;
				}
				//alert("readyState : " + oXMLHttp.readyState);
				//alert("status : " + oXMLHttp.status);
				//alert("Timeout = " + bTimeOut + " intElapsedTime = " + intElapsedTime);
				if(oXMLHttp.readyState == 4 || bTimeOut){
					if(oXMLHttp.status == 200 || bTimeOut){
						if(strContainer.length > 0 && strContainer != null && document.getElementById(strContainer)){
							document.getElementById(strContainer).innerHTML=oXMLHttp.responseText;
						}
					}
				}
			}
			//alert("end request " + strCFFile);
			oXMLHttp.send(null);
		}catch(exSend){
			alert("alert -1: " + exSend.description);
		}
	}catch(exRequest){
		//alert("alert 0: " + exRequest.description);
	}
}




var itvStreaming;
function reloadStreaming(){
	try{
	  if(typeof itvStreaming != "undefined") {
		window.clearInterval(itvStreaming);
	  }
	  uuid = parseInt(new Date().getTime() / 10000);//Alle 10 sekunden cache löschen
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/getStreaming.php?option=now&nummer=1&uuid=" + uuid,"nowPlaying");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/getStreaming.php?option=prev&uuid=" + uuid,"ticker");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/moderator.php?uuid=" + uuid,"moderator");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/nameModerator.php?uuid=" + uuid,"nameModerator");
      itvStreaming = window.setInterval("reloadStreaming1()",10000);
	
	}catch(exc1){
		alert("alert1 : " + exc1.description);	
	}
}

function reloadStreaming1(){
	try{
	  if(typeof itvStreaming != "undefined") {
		window.clearInterval(itvStreaming);
	  }
	  uuid = parseInt(new Date().getTime() / 10000);//Alle 10 sekunden cache löschen
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/getStreaming.php?option=now&nummer=2&uuid=" + uuid ,"nowPlaying");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/getStreaming.php?option=prev&uuid=" + uuid,"ticker");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/moderator.php?uuid=" + uuid,"moderator");
	  loadFile("http://www.canal3.ch/DE/modules/mod_actsong/streaming/nameModerator.php?uuid=" + uuid,"nameModerator");
    itvStreaming = window.setInterval("reloadStreaming()",10000);
  	}catch(exc2){
		alert("alert2 : " + exc2.description);	
	}
}

