var SERVERURL ='http://www.realstation.fm';
 function SelectAll() {
	for(var x=0;x<document.form.elements.length;x++) {
		var y=document.form.elements[x];
		if(y.name!='ALL') y.checked=document.form.ALL.checked;
	}
}

var request = false;

	// Request senden
	function setRequest(method, url, parameter, element) {
		// Request erzeugen
		if (window.XMLHttpRequest) {
			request = new XMLHttpRequest(); // Mozilla, Safari, Opera
		} else if (window.ActiveXObject) {
			try {
				request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
			} catch (e) {
				try {
					request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
				} catch (e) {}
			}
		}

		// überprüfen, ob Request erzeugt wurde
		if (!request) {
			alert("Kann keine XMLHTTP-Instanz erzeugen");
			return false;
		} else {
			// Name auslesen
			// Request öffnen
			request.open(method, url, true);
			// Requestheader senden
			request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			// Request senden
			request.send(parameter);
			// Request auswerten
			request.onreadystatechange = function(){interpretRequest(element)};
		}
	}

	// Request auswerten
	function interpretRequest(element) {
		switch (request.readyState) {
			// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
			case 4:
				if (request.status != 200) {
					document.getElementById(''+element+'').innerHTML = "Die angeforderte Datei wurde nicht gefunden!";
				} else {
					var content = request.responseText;
					// den Inhalt des Requests in das <div> schreiben
					evalScript(content);
					document.getElementById(''+element+'').innerHTML = content;
				}
				break;
			default:
				break;
		}
	}

function evalScript(scripts)
{	try
	{	if(scripts != '')
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	alert(e)
	}
}
function MM_goToURL() { //v3.0

  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");

}

function myPopUp(breite,hoehe,url,scrolling){var positionX=((screen.availWidth/2)-breite/2);var positionY=((screen.availHeight/2)-hoehe/2);pop=window.open('','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scrolling+',resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10000,left=10000');pop.resizeTo(breite,hoehe);pop.moveTo(positionX,positionY);pop.location=url;}

function postRequest(strURL,id,action) {
  var xmlHttp;
  if (window.XMLHttpRequest) { 
    var xmlHttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) { 
    var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlHttp.open('POST', strURL, true);
  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4) {
      updatepage(xmlHttp.responseText,id,action);
    }
  }
  xmlHttp.send(strURL);
}
//update target
function updatepage(str,id,action){
	if (action == "add"){
    document.getElementById(id).innerHTML+=str;
	}
	else if (action == "replace"){
		document.getElementById(id).innerHTML=str;
	}
	else if (action == "formfield"){
		document.getElementById(id).value =trimstring(str);
	}
	else if (action == "return"){
		return str;
	}
	else if (action == "execute"){
		eval(str);
	}
}
//fetch data for onclick/onchange events
function eventfetch(url,id,action){
  postRequest(url,id,action);
}
//fetch data for timebased events
function timefetch(url,id,action,milliseconds) {
	eventfetch(url,id,action);
  setTimeout(function () { timefetch(url,id,action,milliseconds); },milliseconds);
}
//generic fetch function, accepts 5 parameters (first 4 mandatory).
//url = script to access on the server
//id = html id (for example of a div, a form field etc.., works with all tags which accept an id)
//action = add, replace, return or formfield, add adds up content at the end of the original content in the id element, replace replaces the complete content in the id element, formfield replaces a form field value, return simply returns the fetched data
//base = time or event, time based means script will autoexecute itself every amount of milliseconds specified via the 5th parameter, event based means you are calling the funtion with something like onclick, onchange, onmouseover or directly in a script
//milliseconds = time in milliseconds till the script should autoexecute itself again (only needed when base==time)
function fetch(url,id,action,base,milliseconds){
	if(base == "event"){
		eventfetch(url,id,action);
	}
	else if(base == "time"){
		timefetch(url,id,action,milliseconds);
	}
}

function search(user,id,action,exact,searchtype){
	exact = typeof(exact) != 'undefined' ? exact : 0;
	searchtype = typeof(searchtype) != 'undefined' ? searchtype : 0;
  searchrequest=""+ SERVERURL +"/user/user_suche.php?eingabe="+user;
  eventfetch(searchrequest,id,action);
}
function getposOffset(overlay, offsettype){
  var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
  var parentEl=overlay.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}
function overlay(curobj, subobjstr, opt_position){
  if (document.getElementById){
    var subobj=document.getElementById(subobjstr)
    subobj.style.display="block"
    var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0)
    var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
    subobj.style.left=xpos+"px"
    subobj.style.top=(ypos+15)+"px"
    return false
  }
  else
    return true
}
function overlayclose(subobj){
	document.getElementById(subobj).style.display="none"
}

function trim(stringToTrim) {
  return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function formcheck_onsend(id){
	valuestring=document.getElementById(id).value;
	if(trim(valuestring)==''){
		return false;
	}
	else{
		return true;
	}
}

