var rahmen="<div style=\"zIndex: 10; border: 1px solid #4e6187; margin: 5px 5px 5px 5px; background-color: Yellow; height: 500px; width: 300px; top: 200px; left: 400px; position:absolute;\">&nbsp;</div>";
var fto = new Array();
var ftoricht = new Array();
var ftoi = 0;
var itemp = 0;

var cFIOstepBG_off = -0.12;
var cFIOstepBG_on = 0.09;
var cFIOstepTXT_off = -0.14;
var cFIOstepTXT_on = 0.19;

function tssetup(){
	for(j=0;j<tse.length;j++){
	//alert(tse[j][3][7]);
		document.getElementById("divts0").appendChild(tse[j][3][7]);
		tse[j][3][7].style.border="1px solid #4e6187";
		tse[j][3][7].style.height=tse[j][3][4]+"px";
		tse[j][3][7].style.width=tse[j][3][5]+"px";
		tse[j][3][7].style.top="-900px";
		tse[j][3][7].style.left="-900px";
		tse[j][3][7].style.backgroundColor="#FFFFFF";
		tse[j][3][7].style.marginBottom="2px";
		tse[j][3][7].style.marginTop="2px";
		tse[j][3][7].style.marginLeft="2px";
		tse[j][3][7].style.marginRight="2px";
		tse[j][3][7].style.paddingBottom="13px";
		tse[j][3][7].style.paddingTop="16px";
		tse[j][3][7].style.paddingLeft="13px";
		tse[j][3][7].style.paddingRight="16px";
		tse[j][3][7].style.zoom="100%";
		tse[j][3][7].style.position="absolute";
		tse[j][3][7].style.filter="alpha(opacity=100)";
		tse[j][3][7].style.opacity=1;
		tse[j][3][7].style.zindex=50;
		tse[j][3][7].innerHTML="&nbsp;";
		tse[j][3][7].setAttributeNode(document.createAttribute("id"));
		tse[j][3][7].id = tse[j][3][0];

		
		
		document.getElementById("divts0").appendChild(tse[j][3][8]);
		tse[j][3][8].style.border="1px solid #4e6187";
		tse[j][3][8].style.height=tse[j][3][4]+"px";
		tse[j][3][8].style.width=tse[j][3][5]+"px";
		tse[j][3][8].style.top="-900px";
		tse[j][3][8].style.left="-900px";
		tse[j][3][8].style.marginBottom="2px";
		tse[j][3][8].style.marginTop="2px";
		tse[j][3][8].style.marginLeft="2px";
		tse[j][3][8].style.marginRight="2px";
		tse[j][3][8].style.paddingBottom="13px";
		tse[j][3][8].style.paddingTop="16px";
		tse[j][3][8].style.paddingLeft="13px";
		tse[j][3][8].style.paddingRight="16px";
		tse[j][3][8].style.zoom="100%";
		tse[j][3][8].style.position="absolute";
		tse[j][3][8].style.zindex=55;
		tse[j][3][8].style.filter="alpha(opacity=100)";
		tse[j][3][8].style.opacity=1;
		tse[j][3][8].innerHTML=tse[j][3][6];
		tse[j][3][8].setAttributeNode(document.createAttribute("id"));
		tse[j][3][8].id = tse[j][3][0]+"a";
		
		
		tse[j][3][7].style.filter="alpha(opacity=0)";
		tse[j][3][7].style.opacity=0;
		tse[j][3][8].style.filter="alpha(opacity=0)";
		tse[j][3][8].style.opacity=0;
	}
}

function tsswap(dat1,dat2){
	document.images[dat1].src = dat2;
	return true;
};

var tsswapTmr=null;
var tslasti=0;
var DissapearDelay=6000; // Dauer des Effekts in ms

function tsswapon(i){
	tslasti = i;
	for(j=0;j<tse.length;j++){
		for(k=0;k<tse[j][1].length;k++){
			document.images[tse[j][1][k][0]].src = tse[j][1][k][2].src;
		}
		for(k=0;k<tse[j][2].length;k++){
			document.getElementById(tse[j][2][k]).style.fontWeight = 'normal';
		}
		if(j != i){
			fade_in_out(tse[j][3][0], cFIOstepBG_off, j, 0.89, j+"a");
			fade_in_out(tse[j][3][0]+"a", cFIOstepTXT_off, j, 1, j+"b");
		}
	}
	
	if(tsswapTmr)clearTimeout(tsswapTmr);
	
	for(k=0;k<tse[i][1].length;k++){
		document.images[tse[i][1][k][0]].src = tse[i][1][k][1].src;
	}
	for(k=0;k<tse[i][2].length;k++){
		document.getElementById(tse[i][2][k]).style.fontWeight = 'bold';
	}
	tse[i][3][7].style.left=(parseInt(tsgetPageCoordsX(tse[i][3][1]))+parseInt(tse[i][3][2]))+"px";
	tse[i][3][7].style.top=(parseInt(tsgetPageCoordsY(tse[i][3][1]))+parseInt(tse[i][3][3]))+"px";
	tse[i][3][8].style.left=(parseInt(tsgetPageCoordsX(tse[i][3][1]))+parseInt(tse[i][3][2]))+"px";
	tse[i][3][8].style.top=(parseInt(tsgetPageCoordsY(tse[i][3][1]))+parseInt(tse[i][3][3]))+"px";

	fade_in_out(tse[i][3][0], cFIOstepBG_on, i, 0.89, i+"a");
	fade_in_out(tse[i][3][0]+"a", cFIOstepTXT_on, i, 1, i+"b");
};

function tsswapoff(i){
	if(tsswapTmr)clearTimeout(tsswapTmr);
	tsswapTmr=setTimeout('tskillswap('+i+')',DissapearDelay);
};

function tskillswap(i){
	for(k=0;k<tse[i][1].length;k++){
		document.images[tse[i][1][k][0]].src = tse[i][1][k][2].src;
	}
	for(k=0;k<tse[i][2].length;k++){
		document.getElementById(tse[i][2][k]).style.fontWeight = 'normal';
	}
	fade_in_out(tse[i][3][0], cFIOstepBG_off, i, 0.89, i+"a");
	fade_in_out(tse[i][3][0]+"a", cFIOstepTXT_off, i, 1, i+"b");
};

function tshide(i){
	tse[i][3][7].style.top="-900px";
	tse[i][3][7].style.left="-900px";
	tse[i][3][8].style.top="-900px";
	tse[i][3][8].style.left="-900px";
};


function tsgetPageCoordsX(elementId) {
	var element;
	if (document.all)	element = document.all[elementId];
	else if (document.getElementById) element = document.getElementById(elementId);
	if (element) {
		var x = 0;
		do {
			x += element.offsetLeft;
			element = element.offsetParent;
		} while (element);
		return x;
	}
	else return 0;
}

function tsgetPageCoordsY(elementId) {
	var element;
	if (document.all)	element = document.all[elementId];
	else if (document.getElementById) element = document.getElementById(elementId);
	if (element) {
		var y = 0;
		do {
			y += element.offsetTop;
			element = element.offsetParent;
		} while (element);
		return y;
	}
	else return 0;
}

function fade_in_out (element_id, step, usebox, maxop, instanz) {

//document.getElementById("debug1").innerHTML = "Test";
  if((opacity<0.05)&&(step<0)){tshide(usebox);};
  if (ftoricht[instanz] && (ftoricht[instanz]!=step)){
  	window.clearInterval (fto[instanz]);
	  ftoricht[instanz] = null;
      fto[instanz] = null;
	}
  if (!fto[instanz]) {
    fto[instanz] = window.setInterval ('fade_in_out(\'' + element_id + '\', ' + step + ', ' + usebox + ', ' + maxop + ', \'' + instanz + '\')', 50);
	ftoricht[instanz]=step;
  }
  else {
    var e = document.getElementById(element_id);
    var opacity;
    if (!e.filters)
      opacity = !e.style.opacity ? step > 0 ? 0 : 1 : parseFloat (e.style.opacity);
    else
      opacity = !e.filters.alpha.opacity ? step > 0 ? 0 : 1 : parseFloat (e.filters.alpha.opacity) / 100;
    if ((step < 0 && opacity != 0) || (step > 0 && ((opacity) < maxop))) {
		if(step > 0 && ((opacity+step))>=maxop){opacity=maxop;}else{opacity += step;};
      if (!e.filters)
        e.style.opacity = step < 0 ? opacity < 0 ? 0 : opacity : opacity > maxop ? maxop : opacity;
      else
        e.filters.alpha.opacity = step < 0 ? opacity < 0 ? 0 : opacity * 100 : opacity > maxop ? maxop * 100 : opacity * 100;
    }
    else {
      window.clearInterval (fto[instanz]);
	  ftoricht[instanz] = null;
      fto[instanz] = null;
    }
  }
  if((opacity<0.05)&&(step<0)){tshide(usebox);};
  //if((element_id=='box0a' || element_id=='box0a')&&(step>0)){
  	//itemp++;
	//document.getElementById("debug1").innerHTML = itemp+": "+element_id+" | "+step+" | "+usebox+" | "+maxop+" | "+instanz+" | "+opacity +"<br>"+document.getElementById("debug1").innerHTML; 
	//}
}