/**
 * @author sasonikolov
 */ 
function basics_geladen(){return true;}
function apicall(url, onSuccess, onError, onErrorTimeout, urlid) {
	if (!system)
		system = {};
	if (!system['dscript'])
		system['dscript'] = {'id':1, 'cb':{}, 'urls':{}};		
    var id = system["dscript"]["id"];
    system["dscript"]["cb"][id] = {"url": url, "onSuccess": onSuccess, "onError": onError, "time": new Date().getTime()};
    var refurl = url;
    if (system['daten_server']) {
    	for (var a=0;a<system['daten_server'].length;a++) {
			if (system['daten_server'][a] == url.substr(0, system['daten_server'][a].length)) {
				refurl =url.substr(system['daten_server'][a].length); 
				break;
			}    		
		}
	}
    if (system['daten_serverSSL']) {
    	for (var a=0;a<system['daten_serverSSL'].length;a++) {
			if (system['daten_serverSSL'][a] == url.substr(0, system['daten_serverSSL'][a].length)) {
				refurl =url.substr(system['daten_serverSSL'][a].length); 
				break;
			}    		
		}
	}
    if (!urlid)
    	urlid = refurl
    system["dscript"]["urls"][urlid] = id; // für die statischen URLs
    var head    = document.getElementsByTagName("head")[0];
    var script  = document.createElement('script');
    script.id   = 'obj_dscript_'+id;
    if (id > 36000 && !system["dscript"]["cb"][1])
    	system["dscript"]["id"] = 1;	
    script.type = 'text/javascript';    
	var srcurl = url;
	if (srcurl.indexOf("?")<1)
		srcurl += "?"      
    script.src  = srcurl+"&cbf=RS_APIDispatcher&cbid="+id;
    var d = new Date();
    script.src += '&t='+d.getTime();
    head.appendChild(script);
    var timeout = 5000; // 5 sekunden
    if (onErrorTimeout)
    	timeout = onErrorTimeout; 
	var errorcheck = setTimeout("RS_APIErroLoadCheck('"+id+"')", timeout);
	system["dscript"]["cb"][id]['errorcheck'] = errorcheck;    
    system["dscript"]["id"]++;
}   
function RS_APIDispatcher(id, result) {
    if (intval(id) == 0 && system["dscript"]["urls"][id])
      id = system["dscript"]["urls"][id];
    if (!document.getElementById('obj_dscript_'+id))
      return false;
    if (system["dscript"]["cb"][id])
    	system["dscript"]["cb"][id]['dontkill'] = true;
    if (system["dscript"]["cb"][id] && system["dscript"]["cb"][id].errorcheck)  
    	clearTimeout(system["dscript"]["cb"][id].errorcheck);
    var old = document.getElementById('obj_dscript_'+id);
    if (old != null) {
        old.parentNode.removeChild(old);
        delete old;
    }
    var oobj = null;
    if(typeof result == 'function')
      result = result();
    else if(typeof result == 'object') 
      oobj = result; 
    var obj = {"responseText": result, "object": oobj};
    if (system["dscript"]["cb"][id])
    	system["dscript"]["cb"][id].onSuccess(obj); // errorload could have killed it already
    delete(system["dscript"]["cb"][id]);   
}
function RS_APIErroLoadCheck(apicallid){                            
	if (!system["dscript"]["cb"][apicallid])
		return false;
	var objekt = system["dscript"]["cb"][apicallid];
	if (system["dscript"]["cb"][apicallid]['dontkill'])
		return false;
	// immernoch da, also wahrscheinlich fehler aufgetreten	
	if (objekt.onError)
		objekt.onError(apicallid);	
	delete(system["dscript"]["cb"][apicallid]);
}
    function ajaxen(obj) {
        var text = obj.url;            
        if (obj.str)
            text += "&" + obj.str;
        loggen('<a href="'+text+'" target="_blank">'+text+'</a>');
        RSAjax(obj);
    }             
	function time(onlyseconds) {
		var datum = new Date();
		var milliseconds = datum.getTime();
		if (onlyseconds)
			return intval(milliseconds/1000);
		return milliseconds;
	}
	function Date2Text(millisek, format) {
		if (!millisek)
			millisek = time();
		var d = new Date(millisek);
		if (!format)
			format = "%d.%m.%Y %H:%i";
		var tage = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
		var monate = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dez'];
		var formate = {'d':((d.getDate()<10)?'0'+d.getDate():d.getDate()),
				'j':d.getDate(),'D':tage[d.getDay()],'w':d.getDate(),'m':((d.getMonth()+1<10)?'0'+(d.getMonth()+1):d.getMonth()+1),'M':monate[d.getMonth()],
				'n':d.getMonth()+1,'Y':d.getFullYear(),'y':((d.getYear()>100)?(d.getYear().toString().substr(d.getYear().toString().length-2)):d.getYear()),
				'H':((d.getHours()<10)?'0'+d.getHours():d.getHours()),'h':((d.getHours()>12)?(d.getHours()-12):d.getHours()),
				'i':((d.getMinutes()<10)?'0'+d.getMinutes():d.getMinutes()),'s':((d.getSeconds()<10)?'0'+d.getSeconds():d.getSeconds())
				}
        for (var akey in formate) {
            var rg = new RegExp('%'+akey, "g");
            format = format.replace(rg, formate[akey]);
        }
		return format;
	}
	function isset(variable){
//	   if (!variable)
//	       return false; // ist definiert mit false
	   if (typeof(variable) == "undefined")
	       return false;
	    if (variable == null)
	       return false;	    
	    return true;
    }
    function trim(text) {
        if (!text)
            return "";
        text += "";
        return text.replace(/^\s+|\s+$/g, '');
    }
    function floatval(text, maxwert, minwert) {
        var zahl = parseFloat(text);
        if (isNaN(zahl))
            zahl = 0.0;
        if (typeof(maxwert) != "undefined" && maxwert < zahl)
            zahl = maxwert;
        if (typeof(minwert) != "undefined" && minwert > zahl)
            zahl = minwert;
        return zahl;
    }
    function intval(text, maxwert, minwert) {
        var zahl = parseInt(text, 10);
        if (isNaN(zahl))
            zahl = 0;
        if (typeof(maxwert) != "undefined" && maxwert < zahl)
            zahl = maxwert;
        if (typeof(minwert) != "undefined" && minwert > zahl)
            zahl = minwert;
        return zahl;
    }
    function number_format(zahl, anzahl, trenner) {
    	if (!anzahl)
    		anzahl = 2;
        var wert = floatval(zahl).toFixed(anzahl); 
    	if (!trenner)
        	return wert;
        var gzahl = intval(zahl);
        var vorne = trenneZahl(gzahl, trenner);
    	var nwert = "" + vorne;
        if (trenner == ".")
        	nwert += ",";
        else
        	nwert += ".";       
        wert = ""+wert;
        nwert += wert.substr(wert.indexOf(".")+1);
        return nwert;
    }
function basics_filesize2Text(filesizes) {
    var filesizeeinheit = "Bytes";
	var filesizesumme = filesizes;
	if (filesizes > 1000) {
		filesizesumme = filesizes/1000;
		filesizeeinheit = "KB";
	}				
	if (filesizes > 1000000) {
		filesizesumme = filesizes/1000/1000;
		filesizeeinheit = "MB";
	}				
	if (filesizes > 1000000000) {
		filesizesumme = filesizes/1000/1000/1000;
		filesizeeinheit = "GB";
	}				
	return {'size':filesizesumme,'unit':filesizeeinheit};
}
	function trenneZahl(zahl, trenner, anzahl) 
	{
		//zahl = intval(zahl);
		zahl = ""+zahl;
		if (!anzahl) anzahl = 3;
	    if (typeof trenner == 'undefined') trenner = " ";
	    //  Vorzeichenbereinigen - ggf. floats zu Integer konvertieren (sn=StringNumber):
	    var sn = String(Math.abs(zahl));
	    var sf = "";
	    //  Zahl nur verarbeiten falls >3stellig
	    if (sn.length > anzahl)
	    {
	        var bg = sn;
	        var new_n = "";
	        for(var j=3; j < bg.length ; j+=3)
	        {
	            var ex = bg.slice(bg.length - j, bg.length - j + 3);
	            new_n = trenner + ex +  new_n;
	        }
	        //  Falls noch ein Restring da ist mit vorhängen:
	        sf = bg.substr(0, (bg.length % 3 == 0)?3:(bg.length % 3));
	        //  StringNumber überschreiben mit Ergebnis
	        sn = sf + new_n;
	    }
	    //  Rückgabe der formatierten Zahl (ggf. Vorzeichen wieder vorhängen)
	    if(zahl<0)  return "-"+sn;
	    else                return sn;
	}
    
	function function_exists(funktionsname) {
		if(typeof window[funktionsname] == 'function')
			return true; 
		return false;
	}
    function getXMLWertText(wert)
    {
        var text = "";       
        if (wert == null)
            return text;
        if (wert.childNodes[0])    
            text = wert.childNodes[0].nodeValue;
        return text;
    }
    function getXMLWertInt(wert)
    {
        var text = 0;
        if (wert == null)
            return text;
        if (wert.childNodes[0])
            text = intval(wert.childNodes[0].nodeValue);
        return text;
    }
    function getXMLWertToTimestamp(wert) {
        var varwert = trim(getXMLWertText(wert));
        if (varwert == "")
            return 0;
        var teile = varwert.split(".");
        if (teile.length < 3)
            return 0;
        var datum = new Date(intval(teile[2]), intval(teile[1])-1, intval(teile[0])); // de format 23.10.2009
        return datum.getTime();
    }
    function loggen(text, notreverse) {
        if (!system['debug'])
            return false;
        if (!document.getElementById("statusmeldung")) {
            var elem = document.createElement("div");
            elem.id = "statusmeldung";
            document.getElementsByTagName("body")[0].appendChild(elem);
        } else {
//        document.getElementById("statusmeldung").style.display = "block";
        }
        var datum = new Date();
        if (notreverse) {
            document.getElementById("statusmeldung").innerHTML += "<div>"+ datum.toTimeString()+": " + text + "</div>";
        } else {
            document.getElementById("statusmeldung").innerHTML = "<div>"+ datum.toTimeString()+": " + text + document.getElementById("statusmeldung").innerHTML+"</div>"; 
        }                                                                         
    }
    function Text2XML(text) {
        return (new DOMParser()).parseFromString(text, "text/xml");
    }
    function XML2Text(xmlobjekt) {
        return (new XMLSerializer()).serializeToString(xmlobjekt);
    }
    function getXML2Obj(xmlnode) {
        var knoten = new Object();
        if (!xmlnode)
            return null;
        knoten.Value = '';
        if (xmlnode.attributes && xmlnode.attributes.length > 0) { 
            knoten.Attribute = new Object();
            for (var i=0;i<xmlnode.attributes.length;i++) {
                knoten.Attribute[xmlnode.attributes[i].name] = xmlnode.attributes[i].value;
            } 
        }
        if (xmlnode.hasChildNodes()) {
            knoten.Kinder = new Object();
            for (var a=0;a<xmlnode.childNodes.length;a++) {
                var eintrag = xmlnode.childNodes[a]; 
                if (eintrag.nodeName.toLowerCase() == "#text" || eintrag.nodeName.toLowerCase() == "#cdata-section") {
                    knoten.Value += eintrag.nodeValue;
                } else {
                    if (!knoten.Kinder[eintrag.nodeName])
                        knoten.Kinder[eintrag.nodeName] = new Array();
                    knoten.Kinder[eintrag.nodeName].push(getXML2Obj(eintrag));
                }                
            }        
        }
        return knoten;
    }
    function checkResponse(text, leise) {
    	if (typeof(text) != "string")
    		return true; // ist ein object. also schon mal keine fehlermeldung
        if (text.substr(0, 6).toUpperCase() == "ERROR:") {
            if (leise) {} else {
                alert(text);
            }            
            return false;
        }
        return true;
    }
    function ermittelErrorCode(text) {
        text = trim(text);
        var errorCode = "";
        var erg = text.match(/#([0-9|a-z|A-Z]+)/);
        if (erg) {
            errorCode = trim(erg[1]);
        }
        return errorCode;
    }
	function removeHTMLTags(text){
	   text = ""+text;
 	 	text = text.replace(/&(lt|gt);/g, "");
 	 	text = text.replace(/<\/?[^>]+(>|$)/g, "");
 	 	return text;
	}
	function ermittelTitelAusText(text) {
		var zeilen = text.split("\n");
		var titel = zeilen[0];
		zeilen[0] = "";
		var ntext = trim(zeilen.join(""));  
		return new Array(titel, ntext);
	}                                           
	function BildBoxZeigen(bildurl, breite) {
		return InhaltBoxZeigen("<img src='"+bildurl+"' width='90%'>", breite);
	}
	function InhaltBoxZeigen(inhalt, breite) {
		var elem = InfoBoxZeigen(inhalt);
		if (!breite)
			breite = "90%";
		elem.style.width = breite;
		var fbreite = basics_getWindowWidth();
		var ebreite = basics_getWindowWidth(elem);
		elem.style.left = ((fbreite-ebreite)/2)+"px";
		return elem;
	}
    function InfoBoxZeigen(inhalt, fktwert, noschliessen, titel) {
        var fkt = "InfoBoxSchliessen()";
        if (fktwert)
            fkt = fktwert;    
        var t = "";
        if (titel)
        	t = titel;
		var textschliessen = '<div style="float:left;overflow:hidden;font-weight:bold;margin-bottom:5px;">'+t+'</div><div style="float:right;text-align:right;"><a href="#" onclick="' + fkt + ';return false;" style="margin-bottom:5px;padding-right:5px;font-weight:bold;text-decoration:none;color:#00204e;">[X]</a></div><div style="clear:both;"></div>';
        var text = textschliessen;
        text += inhalt;
        var elem;
        if (!document.getElementById("infobox")) {            
            elem = document.createElement("div");
            elem.id = "infobox";
            document.getElementsByTagName("body")[0].appendChild(elem);
        } else {
            elem = document.getElementById("infobox");
        }
        elem.innerHTML = "";
		elem.style.width = "550px";           
        elem.style.height = "";
        elem.style.position = "absolute";
        elem.style.zIndex = 101;
		elem.style.border = "2px solid #00204e";
        elem.style.borderRadius = "6px 6px 6px 6px";
        elem.style.boxShadow = "10px 10px 10px 5px #ddd";
        elem.style.backgroundColor = "white";
        elem.style.backgroundImage = "";
        elem.style.top = "100px";
        elem.style.left = "50px";
        elem.style.overflow = "visible";
        elem.style.paddingTop = "5px";
        elem.style.paddingBottom = "5px";
        elem.style.paddingLeft = "5px";
        elem.style.paddingRight = "5px";
        elem.innerHTML = text;
        var clientBreite = document.body.clientWidth;        
        var links = (clientBreite - parseInt(elem.style.width)) / 2;
        if (links > 0) {
            elem.style.left = links + "px";
        } else {
            elem.style.left = "50px";
        }
        elem.style.position = 'absolute';
        var toppos = 0;
        if (typeof(document.documentElement.scrollTop) != "undefined") {
            if (typeof(window.pageYOffset) && window.pageYOffset > 0 && window.pageYOffset > document.documentElement.scrollTop) {
                toppos = window.pageYOffset;
            } else {
                if (typeof(document.body.scrollTop) != "undefined" && document.body.scrollTop > document.documentElement.scrollTop) {
                    toppos = document.body.scrollTop;
                } else {
                    toppos = document.documentElement.scrollTop;
                }                
            }       
        } else {
            toppos = window.pageYOffset;
        }
        toppos += 50;    
        elem.style.top = toppos+"px";     
        BlenderZeigen(fktwert, noschliessen);
        elem.style.display = "block";
        if (intval(elem.offsetHeight+50) > document.body.clientHeight) {        	
            //elem.style.overflow = "scroll";
            elem.style.height = (document.body.clientHeight - 100) +"px";
            elem.innerHTML = textschliessen+'<div style="overflow:auto;height:'+(document.body.clientHeight - 170)+'px;">'+inhalt+'</div>';
        }        
        basics_fadein("infobox",0,20);
        return elem;
    }
    function InfoBoxSchliessen(nofade)
    {
    	if (!nofade) {
	        basics_fadeout("infobox",0,20,function(){InfoBoxSchliessen(true);});
		} else {
	        BlenderSchliessen(); 
	        if (document.getElementById("infobox")) {
	        	document.getElementById('infobox').innerHTML = "";
	            document.getElementById('infobox').style.display='none';
	            document.getElementById('infobox').style.position='absolute';
	        }
    	}
    }
    function BlenderZeigen(fktwert,noschliessen) 
    {
        var elem;
        if (!document.getElementById("blender")) {
            var elem = document.createElement("div");
            elem.id = "blender";
            document.getElementsByTagName("body")[0].appendChild(elem);
        } else {
            elem = document.getElementById("blender");
        }                
        elem.style.backgroundImage = "url(bilder/blender.gif)";
        if (navigator.appName.toLowerCase().match(/microsoft/))
        	elem.style.position = "absolute"; // einfach scheisse und arrogant
        else
        	elem.style.position = "fixed";
        elem.style.top = "0px";
        elem.style.left = "0px";
        elem.style.height = "100%";
        elem.style.width = "100%";
        elem.style.display = "block";
        elem.style.zIndex = 100;  
        if (noschliessen) {
            elem.onclick = null;
        } else {
            elem.onclick = InfoBoxSchliessen;
        }                
    }
    function BlenderSchliessen()
    {
        if (document.getElementById("blender"))
            document.getElementById("blender").style.display = "none";
    }
    function WarteSymbolSchliessen() {
        if (document.getElementById("wartesymbolbox"))
            document.getElementById("wartesymbolbox").style.display = "none";
    }
    function WarteSymbolEinblenden(textbelegung) {
        var text = '';
        if (textbelegung) {
            text = '... '+textbelegung+' ...';
        } else {
            //text = '... bitte warten ...';
        }
        text = '<img src="bilder/progress_wheel.gif"><br>'+text;
        var elem;
        if (!document.getElementById("wartesymbolbox")) {            
            elem = document.createElement("div");
            elem.id = "wartesymbolbox";
            document.getElementsByTagName("body")[0].appendChild(elem);
        } else {
            elem = document.getElementById("wartesymbolbox");
        }           
        elem.style.width = "150px";
        elem.style.height = "60px";
        elem.style.position = "absolute";
        elem.style.zIndex = 110;
        //elem.style.border = "6px solid #00204e";
        //elem.style.backgroundColor = "#CCFFFF";
        elem.style.top = "100px";
        elem.style.left = "150px";
        elem.style.overflow = "visible";
        elem.style.padding = "4px";
        elem.style.fontWeight = "bold";
        elem.style.textAlign = "center";
        elem.innerHTML = text;
        var clientBreite = document.body.clientWidth;
        var links = (clientBreite - parseInt(elem.style.width)) / 2;
        if (links > 0) {
            elem.style.left = links + "px";
        } else {
            elem.style.left = "150px";
        }
        elem.style.position = 'absolute';
        var toppos = 0;
        if (typeof(document.documentElement.scrollTop) != "undefined") {
            if (typeof(window.pageYOffset) && window.pageYOffset > 0 && window.pageYOffset > document.documentElement.scrollTop) {
                toppos = window.pageYOffset;
            } else {
                toppos = document.documentElement.scrollTop;
            }       
        } else {
            toppos = window.pageYOffset;
        }
        toppos += 100;    
        elem.style.top = toppos+"px";     
        elem.style.display = "block";
    }
	function JSLaden(dateiname) {
	   if (function_exists(dateiname+"_geladen"))
	       return true;
        var d = new Date();
        var pfad = "";
        if (system && system['jspfad'])
            pfad = system['jspfad'];
        var url = pfad+dateiname+".js?t="+d.getTime();
        ajaxen({
			asynchron: false,
            url: url,
            method: "POST",
            onError: function () {alert('Not Found: '+url);},
            onSuccess: function(h) {
                var code = "";
                code += h.responseText;
                if (window.execScript) {                	
                    try{
						window.execScript(code);
					} catch(e) {
                    	alert("ERROR: Fehler in dynamischer JS Datei: "+url+"\n"+e.message);
                    	return;
					}
                } else {
                    var textnode = document.createTextNode(code);
              		var snode = document.createElement('script');
              		snode.setAttribute('type','text/javascript');
              		snode.appendChild(textnode);
              		document.getElementsByTagName('head')[0].appendChild(snode);
                }
            }
        });
    }
    function GlobalerText(textname) {
    	if (!system['GLOBALTEXTE'])
    		system['GLOBALTEXTE'] = {};
		if (!system['GLOBALTEXTE'][system['sprache']])
			system['GLOBALTEXTE'][system['sprache']] = {};    	
    	if (!system['GLOBALTEXTE'][system['sprache']][textname]) {
    		if (!system['GLOBALTEXTE'][system['sprache']]["_DIVSLAYER_"])
    			system['GLOBALTEXTE'][system['sprache']]["_DIVSLAYER_"] = TemplateLaden("globaletexte");
			var e = document.createElement("div");
            e.id = "tmp_GLOBALTEXTE";
			e.innerHTML = system['GLOBALTEXTE'][system['sprache']]["_DIVSLAYER_"];
            document.getElementsByTagName("body")[0].appendChild(e);
			system['GLOBALTEXTE'][system['sprache']][textname] = "_GLOBAL_TEXT_NOT_FOUND_";
			var e1 = document.getElementById("_global_"+textname);
			if (e1)
				system['GLOBALTEXTE'][system['sprache']][textname] = e1.innerHTML;
			delete(e);
		}
		return system['GLOBALTEXTE'][system['sprache']][textname]; 
	}
	function TemplateLaden(templatename) {
		if (!system['templatepfad'])
			system['templatepfad'] = "";
		if (!system['sprachdateien'])
			system['sprachdateien'] = new Array("en", "de");
		var msprache = system['sprache'];
		if (!inArray(system['sprachdateien'], msprache))
			msprache = "en";
		if (!system['TEMPLATES'])
			system['TEMPLATES'] = {};
		if (!system['TEMPLATES'][templatename])
			system['TEMPLATES'][templatename] = {};
		if (!system['debug'] && system['TEMPLATES'][templatename] && system['TEMPLATES'][templatename][msprache])
			return system['TEMPLATES'][templatename][msprache]['text'];
        var url = system['templatepfad'] + encodeURIComponent(templatename) + ".html?t="+time();
        loggen(url);
		var ttext = "";
		var textobjekt = {};
        ajaxen({
			asynchron: false,
            url: url,
            onError: function () {alert('Not Found: '+url);},
            onSuccess: function(h) {
				var template = h.responseText;
				var url = system['templatepfad'] + 'lang/' + encodeURIComponent(msprache) + '/' + encodeURIComponent(templatename) + ".html?t="+time();
				loggen(url);
				ajaxen({
					asynchron: false,
					url: url,
					onError: function() {ttext = template;},
					onSuccess: function(h) {
						var text = template;
						var zeilen = h.responseText.split("\n");
						for (var i=0;i<zeilen.length;i++) {
							var sp = trim(zeilen[i].substr(0, zeilen[i].indexOf(':')));
							if (sp == "")
								continue;
							var spw = trim(zeilen[i].substr(zeilen[i].indexOf(':')+1));
			                var rg = new RegExp('#'+sp+'#', "g");
			                textobjekt[sp] = spw;
                			text = text.replace(rg, spw);
						}
						ttext = text;
					}
				});
            }
        });
		system['TEMPLATES'][templatename][msprache] = {'text':ttext, 'loaded':time(),'sprachteile':textobjekt}; 
		return ttext;
	}
function inArray(array, wert) {
	if (!array || !array.length)
		return false;
    for (var a=0;a<array.length;a++) {
        if (array[a] == wert)
            return true;
    }
    return false;
}
function DateinameHolenOhneSuffix(filename) {
    var pos = filename.lastIndexOf(".");
    if (pos > 0) {
        filename = filename.substr(0, pos);
    }
    return filename;
}
function rsdownload_downloadRequest(fileurl, cookiecode) {
	window.location.href = fileurl;
	return; 
	// nur für tsh3
	var teile = fileurl.split("/");
	var md5 = teile[5].split("-");
	seclinktimeout = md5[0].substr(1);
	seclinkmd5 = md5[1];
	rsdownload_downloadSenden(teile[4], teile[6], cookiecode, seclinkmd5, seclinktimeout);
}
function rsdownload_downloadSenden(rsfileid, rsfilename, cookiecode, seclinkmd5, seclinktimeout) {
	// nur für TSH3
	if (!rsfileid || !rsfilename || !seclinktimeout || !seclinkmd5)
		return false;
    var url = "http://api.rapidshare.com/";
	var parameter = "cgi-bin/rsapi.cgi?sub=download_v1&cookie="+cookiecode+"&login=&password=&seclinkmd5="+seclinkmd5+"&seclinktimeout="+seclinktimeout+"&fileid="+encodeURIComponent(rsfileid)+"&filename="+encodeURIComponent(rsfilename);
	var apiurl = url+parameter+"&try=1";	
    apicall(apiurl, function(h) {
        if (!checkResponse(h.responseText))
            return false;
		var teile = h.responseText.substr(3).split(",");
		window.location.href = "http://"+teile[0]+"/"+parameter;
	});
}
function basics_getWindowWidth(win) { 
	if (!win) win = window; 
	if (win.innerWidth) 
		return win.innerWidth; 
	if (win.document && win.document.documentElement && win.document.documentElement.clientWidth) 
		return win.document.documentElement.clientWidth;
	if (win.offsetWidth)
		return win.offsetWidth; 
	return win.document.body.offsetWidth; 
}
function basics_getWindowHeight(win) { 
	if (!win) win = window; 
	if (win.innerHeight) 
		return win.innerHeight; 
	if (win.document && win.document.documentElement && win.document.documentElement.clientHeight) 
		return win.document.documentElement.clientHeight;
	if (win.offsetHeight)
		return win.offsetHeight; 
	return win.document.body.offsetHeight; 
}
function basics_getScreenWidth(){
    if (window.innerWidth)
        return window.innerWidth;
    if (document.documentElement.clientWidth)
        return document.documentElement.clientWidth;
    if (document.body.clientWidth)
        return document.body.clientWidth;
    return 0;
}
function basics_getScreenHeight(){
    if (window.innerHeight)
        return window.innerHeight;
    if (document.documentElement.clientHeight)
        return document.documentElement.clientHeight;
    if (document.body.clientHeight)
        return document.body.clientHeight;
    return 0;
}
function basics_ermittelBrowserSprache(defaultwert) {
	if (!defaultwert)
		defaultwert = "en";
	var sprache = trim(defaultwert);
	var language = "";
	if (navigator.appName == 'Netscape') { 
		language = navigator.language}
	else {
		language = navigator.browserLanguage
	}
	if (language != "") {
		var pos = language.indexOf('-');
		if (pos < 0) 
			pos = language.length;
		sprache = language.substr(0, pos);
	}
	if (sprache == "")
		sprache = defaultwert;
	return sprache.toLowerCase();
}
function basics_ermittelURLParameter() {
	var parawerte = {};
    var teile;
    if (window.location.search != "") {
        teile = window.location.search.substring(1).split("&");
        for (var a=0;a<teile.length;a++)
        {
            var t = teile[a].split("=");
            if (t.length == 2) {
                if (t[0] != "")            
                    parawerte[t[0]] = t[1];
            } else {
                parawerte[teile[a]] = true;
            }                
        }
    }
    return parawerte;
}
function basics_url() {
	var host = window.location.host.split(".").reverse().slice(0,2).reverse().join("."); // nur die domain, ohne subdomain
	return host+window.location.pathname.replace(/index\.html/,"");
}                 
function basics_detectNavigator() {
	if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i))
		return "iphone";
	if(navigator.userAgent.match(/iPad/i))
		return "ipad";
	if(navigator.userAgent.match(/android/i))
		return "android";
	if(navigator.userAgent.match(/opera mini/i))
		return "opera_mini";
	if(navigator.userAgent.match(/blackberry/i))
		return "blackberry";
	if(navigator.userAgent.match(/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i))
		return "palm";
	if(navigator.userAgent.match(/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i))
		return "windows_mobile";
	if(navigator.userAgent.match(/(Opera Mobile|mini 9\.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up\.browser|up\.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i))
		return "mobile";
	if(navigator.userAgent.match(/microsoft/i))
		return "ie";
	if(navigator.userAgent.match(/netscape/i))
		return "netscape";
	if(navigator.userAgent.match(/mozilla/i))
		return "mozilla";
	return navigator.userAgent; 
}         
function basics_holeViewerArt(navi) {
	if (!navi)
		navi = basics_detectNavigator();
	var ret = "normal";
	switch(navi) {
		case "iphone":
		case "ipad":
		case "android":
		case "opera_mini":
		case "blackberry":
		case "palm":
		case "windows_mobile":
		case "mobile":
			ret = "mobile";
	}
	return ret; 
}
function basics_holeAlleStyleSheets() {
	var allRules = {'EMPTY':true};
	if (document.styleSheets) {
		for (var b=0;b<document.styleSheets.length;b++) {
			var rules = new Array();
			if (document.styleSheets[b].cssRules)
				rules = document.styleSheets[b].cssRules
			else if (document.styleSheets[b].rules)
				rules = document.styleSheets[b].rules
			if (rules.length > 0) {
				allRules['EMPTY'] = false; 
				for (var a=0;a<rules.length;a++)
					allRules[rules[a].selectorText.toLowerCase()] = rules[a];
			}
		}
	}	
	return allRules;
}
function cookie_set(name, wert, miltime, pfad) {
	if (navigator.cookieEnabled == false)
		return false;
	wert = ''+wert;
	var str = name+"="+wert.replace(/;/g,"")+";";
    if (miltime) {
        var ablauf = new Date();
        ablauf.setTime(miltime);
        str += " expires="+ablauf.toGMTString();
	}
	if (pfad)
		str += ' path='+pfad;
    document.cookie = str;
    return true;
}
function cookie_get(name) {
	if (!document.cookie)
		return "";
	var str = trim(document.cookie);
	if (str == "")
		return "";
	var teile = str.split(";");
	for (var a=0;a<teile.length;a++) {
		var pos = teile[a].indexOf("=");
		if (name == trim(teile[a].substr(0,pos)))
			return trim(teile[a].substr(pos+1));
	}
	return "";
}
function basics_fadein(elemname, prozent, mill, cbf) {
	if (cbf) {
		if (!system['FKT'] || !system['FKT']['basics_fadein'])
			system['FKT'] = {'basics_fadein':{elemname:{"cbf":cbf}}};		
	}
	if (!prozent)
		prozent = 0;
	if (!mill)
		mill = 300;
	var elem = document.getElementById(elemname);
	if (!elem)
		return;
	if (!elem.style.filter && /MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		// forget shit IE alpha transparent
		elem.style.visibility = 'visible';
		if (system['FKT'] && system['FKT']['basics_fadein'] && system['FKT']['basics_fadein'].elemname)
			system['FKT']['basics_fadein'].elemname['cbf'](elemname);
		return;
	}		
	if (navigator.appName == 'Netscape') { 
		language = navigator.language}
	prozent += 20;
	if (prozent > 100)	
		prozent = 100;
	elem.style.zoom = "1";
	elem.style.opacity = (prozent/100);
	elem.style.filter = 'alpha(opacity='+prozent+')'; // also paints chil elements, :-(, whats wrong with them MS guys?
	elem.style.visibility = 'visible';
	if (prozent < 100)
		window.setTimeout("basics_fadein('"+elemname+"',"+prozent+","+mill+")", mill);
	else {
		elem.style.filter = ''; // IE hack, but looks like shit		
		if (system['FKT'] && system['FKT']['basics_fadein'] && system['FKT']['basics_fadein'].elemname)
			system['FKT']['basics_fadein'].elemname['cbf'](elemname);
	}
}
function basics_fadeout(elemname, prozent, mill, cbf) {
	if (cbf) {
		if (!system['FKT'] || !system['FKT']['basics_fadeout'])
			system['FKT'] = {'basics_fadeout':{elemname:{"cbf":cbf}}};		
	}
	if (!prozent)
		prozent = 100;
	if (!mill)
		mill = 100;
	var elem = document.getElementById(elemname);
	if (!elem)
		return;
	if (!elem.style.filter && /MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		// forget shit IE alpha transparent
		elem.style.visibility = 'hidden';
		if (system['FKT'] && system['FKT']['basics_fadeout'] && system['FKT']['basics_fadeout'].elemname)
			system['FKT']['basics_fadeout'].elemname['cbf'](elemname);
		return;
	}		
	prozent -= 10;
	if (prozent <= 0)	
		prozent = 0;
	elem.style.zoom = "1"; // IE hack
	elem.style.opacity = (prozent/100);
	elem.style.filter = 'alpha(opacity='+prozent+')';
	if (prozent > 0)
		window.setTimeout("basics_fadeout('"+elemname+"',"+prozent+","+mill+")", mill);
	else {
		elem.style.visibility = 'hidden';
		if (system['FKT'] && system['FKT']['basics_fadeout'] && system['FKT']['basics_fadeout'].elemname)
			system['FKT']['basics_fadeout'].elemname['cbf'](elemname);
	}
}
function getInhalt(elemname, defaultv) {
    if (!defaultv)
        defaultv = "";
//        defaultv = "no elemment: "+elemname;
    if (!document.getElementById(elemname))
        return defaultv;
    return document.getElementById(elemname).innerHTML;
}
function setInhalt(elemname,inhalt) {
    if (!document.getElementById(elemname))
        alert("no element: "+elemname);
    document.getElementById(elemname).innerHTML = inhalt;
}
function basics_removeTagById(elemname){
    if (!document.getElementById(elemname))
        return false;
    var elem = document.getElementById(elemname);
    elem.parentNode.removeChild(elem);
}
//See http://www.JSON.org/js.html
var JSON;
if (!JSON) {
    JSON = {};
} 
(function () {
    "use strict";
 
    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }
 
    if (typeof Date.prototype.toJSON !== 'function') {
 
        Date.prototype.toJSON = function (key) {
 
            return isFinite(this.valueOf()) ?
                this.getUTCFullYear() + '-' +
                f(this.getUTCMonth() + 1) + '-' +
                f(this.getUTCDate()) + 'T' +
                f(this.getUTCHours()) + ':' +
                f(this.getUTCMinutes()) + ':' +
                f(this.getUTCSeconds()) + 'Z' : null;
        };
 
        String.prototype.toJSON =
            Number.prototype.toJSON =
            Boolean.prototype.toJSON = function (key) {
                return this.valueOf();
            };
    }
 
    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = { // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;
 
 
    function quote(string) {
 
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
 
        escapable.lastIndex = 0;
        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
            var c = meta[a];
            return typeof c === 'string' ? c :
                '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
        }) + '"' : '"' + string + '"';
    }
 
 
    function str(key, holder) {
 
// Produce a string from holder[key].
 
        var i, // The loop counter.
            k, // The member key.
            v, // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];
 
// If the value has a toJSON method, call it to obtain a replacement value.
 
        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }
 
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
 
        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }
 
// What happens next depends on the value's type.
 
        switch (typeof value) {
        case 'string':
            return quote(value);
 
        case 'number':
 
// JSON numbers must be finite. Encode non-finite numbers as null.
 
            return isFinite(value) ? String(value) : 'null';
 
        case 'boolean':
        case 'null':
 
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
 
            return String(value);
 
// If the type is 'object', we might be dealing with an object or an array or
// null.
 
        case 'object':
 
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
 
            if (!value) {
                return 'null';
            }
 
// Make an array to hold the partial results of stringifying this object value.
 
            gap += indent;
            partial = [];
 
// Is the value an array?
 
            if (Object.prototype.toString.apply(value) === '[object Array]') {
 
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
 
                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }
 
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
 
                v = partial.length === 0 ? '[]' : gap ?
                    '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
                    '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }
 
// If the replacer is an array, use it to select the members to be stringified.
 
            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    if (typeof rep[i] === 'string') {
                        k = rep[i];
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {
 
// Otherwise, iterate through all of the keys in the object.
 
                for (k in value) {
                    if (Object.prototype.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }
 
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
 
            v = partial.length === 0 ? '{}' : gap ?
                '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
                '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }
 
// If the JSON object does not yet have a stringify method, give it one.
 
    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {
 
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
 
            var i;
            gap = '';
            indent = '';
 
// If the space parameter is a number, make an indent string containing that
// many spaces.
 
            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }
 
// If the space parameter is a string, it will be used as the indent string.
 
            } else if (typeof space === 'string') {
                indent = space;
            }
 
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
 
            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                    typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }
 
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
 
            return str('', {'': value});
        };
    }
 
 
// If the JSON object does not yet have a parse method, give it one.
 
    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {
 
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
 
            var j;
 
            function walk(holder, key) {
 
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
 
                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.prototype.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }
 
 
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
 
            text = String(text);
            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }
 
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
 
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
 
            if (/^[\],:{}\s]*$/
                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
 
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
 
                j = eval('(' + text + ')');
 
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
 
                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }
 
// If the text is not JSON parseable, then a SyntaxError is thrown.
 
            throw new SyntaxError('JSON.parse');
        };
    }
}());

