/*TELEMETER ANFANG*/

var TE_slideSpeed = 20;	// Higher value = faster
var TE_timer = 8;	// Lower value = faster

var objectIdToSlideDown = false;
var TE_activeId = false;
var TE_slideInProgress = false;

var TE_cntIE = false;
var IE = true;
if (self.innerHeight) {
    IE = false;
}


function showHideContent(e,inputId)
{
	if(TE_slideInProgress)return;
	TE_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('TE_a' + numericId);
	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){	
		if(TE_activeId &&  TE_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			TE_cntIE = true;
			TE_slideContent(TE_activeId,(TE_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			TE_cntIE = false;
			TE_slideContent(numericId,TE_slideSpeed);
		}
	}else{
	    TE_cntIE = true;
		TE_slideContent(numericId,(TE_slideSpeed*-1));
		TE_activeId = false;
	}
}



function TE_slideContent(inputId,direction)
{
	var obj =document.getElementById('TE_a' + inputId);
	var contentObj = document.getElementById('TE_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1 || (TE_cntIE && IE)){
		height = 1;
		rerunFunction = false;
	}
	
	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('TE_slideContent(' + inputId + ',' + direction + ')',TE_timer);
	}else{
		if(height<=1){
		
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('TE_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('TE_a' + objectIdToSlideDown).style.visibility='visible';
				TE_cntIE = false;
				TE_slideContent(objectIdToSlideDown,TE_slideSpeed,TE_cntIE);				
			}else{
				TE_slideInProgress = false;
			}
		}else{
		
			TE_activeId = inputId;
			TE_slideInProgress = false;
		}
	}
}


function pruefeerror(){
	
	
		var divs = document.getElementsByTagName('DIV');
		var i = 1;
		var contentdivs = 0;
		var answerdiv;
		var te_a_divs;
		
		for(var no=0;no<divs.length;no++)
		{
			te_a_divs = document.getElementById('TE_ac'+i);
			if(te_a_divs != null) {
			
				contentdivs = te_a_divs.getElementsByTagName('DIV');
				
				for(var nox=0;nox<contentdivs.length;nox++)
				{
					if(contentdivs[nox].className == 'pruefformularerror')
					{
					    for(var noxx=0;noxx < contentdivs.length; noxx++)
						{
							if(contentdivs[noxx].className == 'formularname')
							{
								if(contentdivs[noxx].title == formularname)
								{
									
									numericId = i;
									
									if(TE_slideInProgress)return;
									TE_slideInProgress = true;
									
									var answerDiv = document.getElementById('TE_a' + numericId);
									
									objectIdToSlideDown = false;
									
									if(!answerDiv.style.display || answerDiv.style.display=='none'){
										if(TE_activeId &&  TE_activeId!=numericId){
											objectIdToSlideDown = numericId;
											TE_slideContent(TE_activeId,(10000*-1));
										}else{
											
											answerDiv.style.display='block';
											answerDiv.style.visibility = 'visible';
											
											TE_slideContent(numericId,10000);
										}
									}else{
										TE_slideContent(numericId,(10000*-1));
										TE_activeId = false;
									}
								}
							}
						}
					}
					
				}
				
				i++;
			}
		}
	
}


function TE_initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	var div_nr = new Array();
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='TE_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'TE_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'TE_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='TE_answer_content';
			contentDiv.id = 'TE_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			div_nr[divCounter] = no;
			divCounter++;
		}		
	}
	
	pruefeerror();
	
	if(TE_navdiv) {
		var o = divs[div_nr[TE_navdiv_nr]]; 
	    if (document.createEvent) { 
	        var evt = document.createEvent("Events"); 
	        evt.initEvent('click', true, true); 
	        o.dispatchEvent(evt); 
	    } 
	    else if (document.createEventObject) 
	    {
	        var evt = document.createEventObject(); 
	        o.fireEvent('onclick', evt); 
	    } 
	    o = null;
	}
}
window.onload = TE_initShowHideDivs;





function toggleMe(a){
  var e=document.getElementById(a);
  if(!e){
	return true
  }
  if(e.style.display=="none"){
    e.style.display="block"
	document.Link_Beschriftung.Name.value="Zurück ...";
  } else {
    e.style.display="none"
	document.Link_Beschriftung.Name.value="Weiterlesen ...";
  }
  return true;
}



/*TELEMETER ENDE*/

