function $(id){
	return document.getElementById(id);
}

function swap(mID){
	td = $(mID);

	if(td.style.display == 'none'){
		td.style.display = 'block';
		$(mID+'_link').innerHTML = '[weniger]';
	} else {
		td.style.display = 'none';
		$(mID+'_link').innerHTML = '[mehr]';
	}
}

function nonl(id){
	string = $(id).value;

	$(id).value = string.replace(/\n/g, " ");
}


function gallery(image){
	imsource = image.src.replace('preview/', '');
	

	$('lightbox').innerHTML = "<a onclick=\"Return();\"><img src=\"" + imsource + "\" /></a>";
	$('lightbox').style.display = "block"; 
}

function Return(){
	$('lightbox').style.display = "none";
	$('lightbox').innerHTML = ""; 
}


function wiesotrainer(){
	AJAX('trainerposten2.php', 'lightbox');
	$('lightbox').onClick = 'Return();';
//	$('lightbox').innerHTML = "<a onclick=\"Return();\">" + src + "</a>";
	$('lightbox').style.display = "block"; 
}



// Init Ajax
var req = null;
var dst = null;

try{
    req = new XMLHttpRequest();
}
catch (ms){
    try{
        req = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (nonms){
        try{
            req = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (failed){
            req = null;
        }
    }  
}

function disp(id, text)
{
  $(id).innerHTML = text;
  $(id).style.display=  "block";
}

// AJAX
function AJAX(url,dst)
{
  req.onreadystatechange = null;
    req.abort();

  req.open("GET",url,true); 
  
  req.onreadystatechange = function(){
        if(req.readyState == 4)  // ready
        {
           if(req.status == 200)
           {
              tex = req.responseText
              if(tex != ""){
                disp(dst, req.responseText);                                    
              } else {
                $(dst).style.display="none";
              }
           }
        } else {
          disp(dst, 'loading...');
        }
  };
  
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}


function galerie(id){
	AJAX('galerie/index.php?id='+id, 'galerie');

}


