function XHConn(){var xmlhttp,bComplete=false;xmlhttp=XHRFactory.getInstance();if(!xmlhttp)return null;this.connect=function(sURL,sMethod,sVars,fnDone){if(!xmlhttp)return false;bComplete=false;sMethod=sMethod.toUpperCase();try{if(sMethod=="GET"){xmlhttp.open(sMethod,sURL+"?"+sVars,true);sVars="";}else{xmlhttp.open(sMethod,sURL,true);xmlhttp.setRequestHeader("Method","POST "+sURL+" HTTP/1.1");xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&!bComplete){bComplete=true;if(fnDone!=null)fnDone(xmlhttp);XHRFactory.release(xmlhttp);}};xmlhttp.send(sVars);}catch(z){return false;}return true;};return this;}var XHRFactory=(function(){var stack=new Array();var poolSize=10;var nullFunction=function(){};function createXHR(){if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){return new ActiveXObject('Microsoft.XMLHTTP')}}for(var i=0;i<poolSize;i++){stack.push(createXHR());}return({release:function(xhr){xhr.onreadystatechange=nullFunction;stack.push(xhr);},getInstance:function(){if(stack.length<1){return createXHR();}else{return stack.pop();}},toString:function(){return"stack size = "+stack.length;}});})();
function ux_alert(msg){document.getElementById('ux_text').innerHTML=msg;document.getElementById('ux').style.display='block';document.getElementById('ux').style.visibility='visible';document.getElementById('ux_btn').focus();}
function ux(msg){ux_alert(msg);}
function uxCloseBtn(btn){btn.parentNode.style.visibility='hidden';return true;}
function ec(d,i,n){document.getElementById('msg'+d).style.display=i;document.getElementById('msgx'+d).style.display=n;document.getElementById('col'+d).style.display=i;document.getElementById('exp'+d).style.display=n;}
function setinputvalue(sinput,svalue){document.getElementById(sinput).value=svalue;}
function jsduration(input){var out='';input=(input-(input%1));if(input<1)out=' 0s';var secs=(input%60);input=(input-(input%60))/60;if(secs>0)out=' '+secs+'s';var mins=(input%60);input=(input-(input%60))/60;if(mins>0)out=' '+mins+'min'+out;var hs=(input%24);input=(input-(input%24))/24;if(hs>0)out=' '+hs+'h'+out;if(input==1)out=input+' Tag'+out;else if(input>1)out=input+' Tage'+out;return out;}
function unif(pos,act){var f=document.getElementById('form'+pos);f.action='?session='+sid+'&mode='+act;f.method='post';f.submit();}
function sethp(id,gfx){if(gfx==0)document.getElementById('img-'+id).src=tf.src;document.getElementById('hp-'+id).src=hp[gfx].src;}
function setsp(id,gfx){document.getElementById('sp-'+id).src=sp[gfx].src;}
function gotoscript(sid){for(i=0;i<document.getElementById('goto').length;i++){if(document.getElementById('goto').options[i].selected==true){location='?session='+sid+'&mode=galaxy&'+document.getElementById('goto').options[i].value;}}return false;}
function tab(tab,tabName){if(preTab)preTab.style.textDecoration='none';tab.style.textDecoration='underline';preTab=tab;document.getElementById('base').style.display=(tabName=="base")?'block':'none';document.getElementById('addr').style.display=(tabName=="addr")?'block':'none';document.getElementById('jump').style.display=(tabName=="jump")?'block':'none';document.getElementById('expo').style.display=(tabName=="expo")?'block':'none';}
function rechne(){var target=parseInt(document.getElementById("convert").value)/3;target=Math.floor(target);if(isNaN(target)){target = 0;}document.getElementById("convert2").value=target;}
function convertall(all){document.getElementById("convert").value=all;}
function ajax(){
var xhConn2=new XHConn();xhConn2.connect("ajax.php?ajax=user&session="+sid, "POST", "",
function(xh){
if(xh.responseText=="")return false;
var data=xh.responseText.split('|');
if(parseInt(data[0]) > 0) data[0]='('+data[0]+' <img src="skin/icons/message.png" alt="" border="0"/>)'; else data[0]='';
document.getElementById('msg').innerHTML=data[0];document.getElementById('geld').innerHTML=data[1];
});}
function ajax_timer(){
ajax();var xhConn1=new XHConn();
xhConn1.connect("ajax.php?ajax=common", "POST", "",
function(xh){
var res=xh.responseText.split(":");
h=parseInt(res[0]);m=parseInt(res[1]);s=parseInt(res[2]);
document.getElementById('chat_ajax').innerHTML=res[3];
});}

/* Gute Funktionen */

function toggle(what){if(document.getElementById(what).style.display=='none'){document.getElementById(what).style.display='block';document.getElementById(what+'_toggle').setAttribute("class", "navi_minus");}else{document.getElementById(what).style.display='none';document.getElementById(what+'_toggle').setAttribute("class", "navi_plus");}}
function jsclock(e){if(++s>59){s=0;if(++m>59){m=0;if(++h>23){h=0;}}}document.getElementById(e).innerHTML=(h<10?'0':'')+h+':'+(m<10?'0':'')+m+':'+(s<10?'0':'')+s;}

/* Restmüll */
function cmain(){tsr='';if(h<10)tsr='0';tsr=tsr+h+':';if(m<10)tsr=tsr+'0';tsr=tsr+m+':';if(s<10)tsr=tsr + '0';tsr=tsr+s;if((++s)==60){s=0;if((++m)==60){m=0;if((++h)==24)h=0;}}document.getElementById('clock').innerHTML=tsr;}
/* Core Ajax */
var coreajax=new Object;coreajax.get=function(a,b){var c=false;if(window.XMLHttpRequest){c=new XMLHttpRequest}else if(window.ActiveXObject){c=new ActiveXObject("Microsoft.XMLHTTP")}if(c){c.open("GET",a);c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){b(c.responseText,c.responseXML);delete c;c=null}};c.send(null)}};coreajax.post=function(a,b,c){var d=false;if(window.XMLHttpRequest){d=new XMLHttpRequest}else if(window.ActiveXObject){d=new ActiveXObject("Microsoft.XMLHTTP")}if(d){d.open("POST",a);d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.onreadystatechange=function(){if(d.readyState==4&&d.status==200){c(d.responseText,d.responseXML);delete d;d=null}};d.send(b)}}

/* discard */
function doNothing(){}

function delMsg(id,url){
if(document.getElementById('am-'+id+'-1'))document.getElementById('am-'+id+'-1').style.display='none';
if(document.getElementById('am-'+id+'-2'))document.getElementById('am-'+id+'-2').style.display='none';
if(document.getElementById('am-'+id+'-3'))document.getElementById('am-'+id+'-3').style.display='none';
var x=parseInt(document.getElementById('clX').innerHTML)-1;
document.getElementById('clX').innerHTML=''+x;
coreajax.get(url,doNothing);
return false;
}

