function goTo(sid){
  document.getElementById('idgoto').value=sid;
  document.getElementById('idnavig').submit();

}


function aO()
{
this.r = false;
this.t = "XMLHttpRequest";
this.waithtml = '<div style="width: 100%;"><p style="text-align:center;"><img class="cnt" src="/gfx/loading.gif" alt="bin am lade"/></p></div>';
this.errorhtml = this.waithtml+'<div style="width: 100%;"><p style="text-align:center;">F&Auml;HLER: probier nomal -- ERROR: try again</p></div>';
this.lastHash;
this.requestTimer = true;


//if (typeof XMLHttpRequest != 'undefined') {this.r = new XMLHttpRequest();}
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			this.r = new XMLHttpRequest();
        } catch(e) {}
}
if (!this.r) 
{
    this.requestTimer = false;
    try 
    {
        this.r = new ActiveXObject("Microsoft.XMLHTTP");
        this.t = "Microsoft.XMLHTTP"
    }
    catch(e) 
    {
        try 
        {
            this.r = new ActiveXObject("Msxml2.XMLHTTP");
            this.t = "Msxml2.XMLHTTP";
        }
        catch(e) 
        {
            this.r = false;
            this.t = false;
        }
    }
}
}

aO.prototype.aOsend = function(v){
    this.r.open('POST', '/');
    this.r.setRequestHeader('x-requested-with', 'XMLHttpRequest');
    this.r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    this.r.onreadystatechange = handleStateChange;
    this.r.send(v);
    if(this.requestTimer){
    this.requestTimer = setTimeout(function() {
       this.r.abort();
     }, 7000);
    }
}
aO.prototype.aOtreeAsString = function(node) {
    var root = null;
    try{
        root = this.r.responseXML.getElementsByTagName("response")[0];
        //if(root == undefined){root = this.r.responseXML.getElementsByTagName("response");}
    }
    catch(err){root=null;}
    if (root == null) {
        return this.r.responseText;
    } else if (window.ActiveXObject!=undefined) {
      //return root.getElementsByTagName(node)[0].xml;
      return root.getElementsByTagName(node)[0].childNodes[0].nodeValue;
    } else if (document.implementation!=undefined && document.implementation.createDocument!=undefined) {
    	var c = 0;
    	var xml = null;
    	try{
    		xml = root.getElementsByTagName(node)[0];
        }
    	catch(err){ xml = this.r.responseXML.getElementsByTagName(node)[0];}
    	if(xml.childNodes[0].nodeType == 4){
    	/*CDATA section*/
    		try{
    		ret = xml.childNodes[0].nodeValue;
        	}
    		catch(err){ret = xml.childNodes[0].value;}
    	} else {
    	c = xml.childNodes.length;
    	var ret = '';
        for(var i = 0; i<c; i++){
            var t = (new XMLSerializer()).serializeToString(xml.childNodes[i]);
            //alert(t);
            if(t.length > 3 && t.substr(t.length -2, 2) == "/>" && t.substr(0, 3) != "<br"){
                t = t.substr(0, t.length -2) + "></" + t.substring(1, t.indexOf(" ")) + ">";
                //alert(t);
            }
            ret += t;
        }
        /*
        var x = (new XMLSerializer()).serializeToString(xml);
        var s = 0;
        var i = x.indexOf("/>");
        while(i > -1){
          var t = x.substr(s, i);
          ret += t;
          var ii = i;
          var iii = i -1;
          var tt = t.substr(iii, ii);
          //alert(t);
          //alert(tt);
          while(tt != '<'){
            iii -= 1;
            ii -= 1;
            tt = t.substr(iii, ii);
            if(tt == '<'){
              ret += '/'+t.substr(iii +1, i);
            }
          }
          x = x.substr(i, x.length);
          //alert('x '+x);
          //alert('ret '+ret);
          i = x.indexOf("/>");
          s = i;
        }*/
        }
        return ret;
    } else {
        return this.errorhtml;
    }
}
aO.prototype.aOresultHTML = function() {
    var res = ao.errorhtml;
    if(this.r.responseXML != null){res=this.aOtreeAsString('result');}
    else if(res != ''){res=this.r.responseText;}
    return res;
}
aO.prototype.aOresultTitle = function() {
    var res = '';
    if(this.r.responseXML != null){res=this.aOtreeAsString('title');}
    else if(res != ''){res='not.set';}
    return res;
}
aO.prototype.aOresultUri = function() {
    var res = '';
    if(this.r.responseXML != null){res=this.aOtreeAsString('uri');}
    return res;
}
aO.prototype.aOresultOrder = function() {
    var res = '1';
    if(this.r.responseXML != null){res=this.aOtreeAsString('order');}
    return res;
}

 
var ao = new aO();

function locationChanged() {
        ao.lastHash = location.hash;
        ao.aOsend('xml=true&time='+new Date().getTime()+'&uri='+ao.lastHash);
        document.getElementById("cnt").innerHTML=ao.waithtml;
    }
    
hashChecker = function(){ ao.lastHash = location.hash; return setInterval(function() { if(ao.lastHash !== location.hash) { locationChanged(); } }, 50); } 
new hashChecker;
if(ao.lastHash == location.hash){
	ao.lastHash = '';
}
    function handleStateChange()
    {
	var readyState = ao.r.readyState;
    
    if (readyState != 4)  { return; }
	if(readyState == 4){
	if(ao.requestTimer){
	clearTimeout(ao.requestTimer);
	}
	if (ao.r.status != 200)  {
       $('inner').innerHTML=ao.errorhtml+'<h2>Status Code :'+ao.r.status+'</h2>';
     } else {
	
	
	 document.getElementById('cnt').innerHTML=ao.aOresultHTML();
	 
	          var title = ao.aOresultTitle();
	           if(title != ''){
	           document.title='rrastafareei - '+title;
	           }else{
	           document.title='rrastafareei';
	           }

	           elem = document.getElementById('ulmenu').getElementsByTagName('li');
	             var order = ao.aOresultOrder() -1;
              for(var i = 0; i<elem.length; i++){
                if(elem[i].id=='current'){elem[i].id='';}
                if(i == order){elem[i].id='current';}
              }
     }
	}
    }
    
    function a(i, s1, s2, s3) {
        ao.aOsend('xml=true&time='+new Date().getTime()+'&data='+i+'&s1='+s1+'&s2='+s2+'&s3='+s3);
        //ao.aOsend('time='+new Date().getTime()+'&data='+i+'&s1='+s1+'&s2='+s2+'&s3='+s3);
	document.getElementById("cnt").innerHTML=ao.waithtml;
    }

function showMore(sid, sub1, sub2, sub3){

  if(sub1 != null ? sub1=='' : true)
    sub1 = '-1';
  if(sub2 != null ? sub2=='' : true)
    sub2 = '-1';
  if(sub3 != null ? sub3=='' : true)
    sub3 = '-1';

  document.getElementById('idgoto').value=sid;
  document.getElementById('idsub1').value=sub1;
  document.getElementById('idsub2').value=sub2;
  document.getElementById('idsub3').value=sub3;
  document.getElementById('idnavig').submit();

}

var dont = null;
function dontClick(){

	location.hash = ao.lastHash;
  dont = document.createElement('div');
  dont.setAttribute('id', 'dont');
  //dont.setAttribute('onclick', 'hideDont()');
  //dont.style.display = 'visible';
  dont.innerHTML='<span onclick="hideDont()">X</span>';
  document.body.appendChild(dont);
  
  return false;

}

function hideDont(){

  //dont.style.display = 'hidden';
  document.body.removeChild(dont);
  dont = null;

}
