/***************************Start checking if a valid browser*******************************************/
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
/***************************End checking if a valid browser*******************************************/

var xmlHttp
function get_stations(val) {
xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
	var params="market_id="+val;

	var url="fileadmin/scripts/get_stations.php";

		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", params.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(params);
		xmlHttp.onreadystatechange=stateChanged;

}
function stateChanged() 
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
		  document.getElementById("stat").innerHTML=xmlHttp.responseText;
		 } 
	}

/********Play radio station***********/
function play_stations(val) {
xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
	var params="station_id="+val;

	var url="fileadmin/scripts/play_stations.php";

		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", params.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(params);
		xmlHttp.onreadystatechange=stationChanged;

}
function stationChanged() 
	{
	var radioembed;
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
		 radioembed = xmlHttp.responseText;
		 ifstream=radioembed.substring(radioembed.length-10);
			if(ifstream=="--nostream") {
			document.getElementById("straming_err").innerHTML="Not streaming";
			ifstream = radioembed.replace("--nostream",""); 
			document.getElementById("radio_link").innerHTML=ifstream;
			}
			else
			{
			document.getElementById("radio_link").innerHTML=radioembed;
			document.getElementById("straming_err").innerHTML="";
			}
		 } 
	}

/*********Play radio station*********/


function swapTab(tabnam) {

}
function swapTab_t(tabnam) {
document.getElementById("err_msg").className="err_msg_blk";
}


function T_PopUp(w,h,ziel) {
  h = h - 20; var x=0, y=0, parameter="";
  if (w < screen.availWidth || h < screen.availHeight) {
    x = (screen.availWidth - w - 12) / 2;
    y = (screen.availHeight - h - 104) / 2;
    if (window.opera) y = 0; // Opera positioned below the toolbars
    if (x<0 || y<0) { x=0; y=0; }
    else parameter = "width=" + w + ",height=" + h + ",";
  }
  parameter += "left=" + x + ",top=" + y;
  parameter += ",menubar=0,location=0,toolbar=0,status=0";
  parameter += ",resizable=0,scrollbars=1";
  var Fenster = window.open(ziel,"PopUp",parameter);
  if (Fenster) Fenster.focus();
  return !Fenster;
}

function PopWindow()
{
window.open('help.php','help','width=400,height=250,menubar=no,scrollbars=no,toolbar=no,location=yes,directories=no,resizable=no,top=200,left=300');
}

function openCenteredWindow(url) {
    var width = 800;
    var height = 710;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "subWind", windowFeatures);
}

