var surl = window.location.host.split(".");
surl = surl[surl.length-1];

targeturl='http://www.klf-communications.'+surl+'/';
picsrc='http://pics.klf-communications.'+surl+'';
picext='';

if (typeof document.addEventListener != 'function' && window.XMLHttpRequest)
{
	font='klf,Impact,Arial';
}
else
{
	font='Arial';
}

document.write('<style>'+
'@font-face {'+
    'font-family: klf;'+
    'font-style:  normal;'+
    'font-weight: normal;'+
    'src: url(\''+targeturl+'DATA/s/klf.eot\');'+
'}'+
'td'+
'{'+
'	PADDING: 2px;'+
'	CURSOR: url(\''+targeturl+'DATA/s/klf.ani\');'+
'	white-space:nowrap;'+
'	TEXT-DECORATION: none;'+
'	FONT-FAMILY: '+font+';'+
'}'+
'*.n'+
'{'+
'	display: none'+
'}'+
'*.k'+
'{'+
'	FONT-SIZE: 32px;'+
'}'+
'*.l'+
'{'+
'	FONT-SIZE: 10px;'+
'}'+
'*.f'+
'{'+
'	FONT-SIZE: 18px;'+
'}'+
'*.wb'+
'{'+
'	COLOR: #fff;'+
'	BACKGROUND-COLOR: #000;'+
'}'+
'*.bw'+
'{'+
'	COLOR: #000;'+
'	BACKGROUND-COLOR: #fff;'+
'}'+
'*.gray'+
'{'+
'	COLOR: #aaa;'+
'	BACKGROUND-COLOR: #000;'+
'}'+
'A:link'+
'{'+
'	COLOR: #fff;'+
'	BACKGROUND-COLOR: #000;'+
'}'+
'A:visited'+
'{'+
'	COLOR: #fff;'+
'	BACKGROUND-COLOR: #000;'+
'}'+
'A:hover'+
'{'+
'	COLOR: #000;'+
'	BACKGROUND-COLOR: #fff;'+
'}'+
'A:active'+
'{'+
'	COLOR: #000;'+
'	BACKGROUND-COLOR: #fff;'+
'}'+
'A'+
'{'+
'	PADDING: 2px;'+
'}'+
'IMG'+
'{'+
'	Border: 0px;'+
'	CURSOR: url(\''+targeturl+'DATA/s/klf.ani\');'+
'}'+
'BODY'+
'{'+
'	SCROLLBAR-ARROW-COLOR: #000;'+
'	SCROLLBAR-TRACK-COLOR: #000;'+
'	SCROLLBAR-BASE-COLOR: #000;'+
'	BACKGROUND-COLOR: #000;'+
'	scrollbar-3d-light-color: #000;'+
'	scrollbar-dark-shadow-color: #000;'+
'	CURSOR: url(\''+targeturl+'DATA/s/klf.cur\');'+
'}'+
'td.play'+
'{'+
'	PADDING-TOP:6px;'+
'}'+
'</style>'+
'<body id=body onload="m();"></body>');

bodybuffer='';

function dummy()
{
}


document.onmousedown = MD;
document.onmousemove = MM;
document.onmouseup = MU;

var templeft=0;
var temptop=0;
var zindex=100;
var lastover=null;
var down=false;
var posx = 0;
var posy = 0;
var xpos=0;
var ypos=0;
var picArray=Array();
var picIDnr=1;
var records=null;

function changepic(ID)
{
	thislink = document.getElementById('link'+ID);

	if(picArray[ID][0]=='s')
	{
		picArray[ID][0]='b';
		thislink.innerHTML='<img id=pic'+ID+' onmouseover=changezindex("'+ID+'") src='+picsrc+'/'+picArray[ID][2]+picext+' title="'+picArray[ID][1]+'" >';
 	}
 	else
	{
		picArray[ID][0]='s';
		thislink.innerHTML='<img id=pic'+ID+' onmouseover=changezindex("'+ID+'") src='+picsrc+'/t/'+picArray[ID][2]+picext+' title="'+picArray[ID][1]+'" >';
 	}

	thispic = document.getElementById('pic'+ID);

 	leftx=posx-(thispic.width/2);
	topy=posy-(thispic.height/2);

	if(leftx<0)leftx=0;
	if(topy<0)topy=0;

	thislink.style.left=leftx;
	thislink.style.top=topy;
}

function changepos(ID)
{
	thislink = document.getElementById('link'+ID);

	leftx=posx-templeft;
	topy=posy-temptop;

	if(leftx<0)leftx=0;
	if(topy<0)topy=0;

	thislink.style.left=leftx;
	thislink.style.top=topy;
}

function savepos(ID)
{
	lastover=ID;

	thisdiv=document.getElementById('link'+ID);

	if(thisdiv.style.left=='')
	{
		thisdiv.style.left=document.body.clientWidth-parseInt(thisdiv.style.right.split('px')[0])-54;
		thisdiv.style.right='';
 	}

	templeft=posx-parseInt(thisdiv.style.left.split('px')[0]);
	temptop=posy-parseInt(thisdiv.style.top.split('px')[0]);
}

function changezindex(ID)
{
	thislink = document.getElementById('link'+ID);
	thislink.style.zIndex=zindex++;
}

function MM(e)
{
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}

	if((down)&&(lastover))
	{
		changepos(lastover);
	}
	
	return false;
}

function MD()
{
	down=true;
	return false;
}

function MU()
{
	down=false;
	lastover=null;
}

function m()
{
	tempload=replaceIt(replaceIt(document.getElementsByTagName("pre")[0].innerHTML,'\n\t\t',''),'\r','').split("\n^\n");

	temp=tempload[0];

	temp=replaceIt(temp,"\n\t","<br>");

	temp=temp.split("\n");

	document.title=replaceIt(replaceIt(temp[0]+' '+temp[1],"&amp;","&"),"<br>"," ");

	thisnum=0;

	bodybuffer=bodybuffer+'<table CELLSPACING=0 CELLPADDING=0 Style="width:100%;border-collapse:collapse;">';

	if((tempload[2])&&(top.location != self.location))
	{
		colspan=7;
		tracksarray=tempload[2].split("\n");
		tracksstring_a='';
		tracksstring_v='';
		found_a=0;
		found_v=0;

		for(xi=0;xi<tracksarray.length;xi++)
		{
			if((tracksarray[xi])&&(tracksarray[xi].substring(0,1)!='v'))
			{
				if(tracksstring_a)tracksstring_a=tracksstring_a+' ';
				tracksstring_a=tracksstring_a+tracksarray[xi];
				found_a++;
			}else if((tracksarray[xi])&&(tracksarray[xi].substring(0,1)=='v'))
			{
				if(tracksstring_v)tracksstring_v=tracksstring_v+' ';
				tracksstring_v=tracksstring_v+tracksarray[xi].substring(1,tracksarray[xi].length);
				found_v++;
			}
		}
	}
	else
	{
		colspan=6;
	}

	point=0;

	for(xi=0;xi<temp.length;xi++)
	{
  		if(xi==0)
		{
			bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'"><td colspan='+colspan+' class=k>'+temp[xi]+'</td></tr>';
		}
		else if(temp[xi].substr(0,1)=='•')
		{
			if((colspan==7)&&(!records)&&(found_a>1))
			{
				bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'"><td valign=top><img onclick="play(\''+tracksstring_a+'\')" src='+targeturl+'DATA/s/play.gif ></td><td colspan=6 class=l>'+temp[xi].substr(2,temp[xi].length)+'</td></tr>';
			}			
			else if((colspan==7)&&(!records)&&(found_v>1))
			{
				bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'"><td valign=top><img onclick="loadvid(\''+tracksstring_v+'\')" src='+targeturl+'DATA/s/play.gif ></td><td colspan=6 class=l>'+temp[xi].substr(2,temp[xi].length)+'</td></tr>';
			}
			else
			{
				bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'"><td colspan='+colspan+' class=l>'+temp[xi].substr(2,temp[xi].length)+'</td></tr>';
			}

			if(!records)records=temp[xi];
  		}
		else if(temp[xi].substr(0,1)=='#')
		{
			tempcols=temp[xi].substr(2,temp[xi].length).split("\t");
			if(tempcols.length==4)
			{
				tempcols[1]=tempcols[1].split(":");

				if(tempcols[1][1])
				{
					tempcols[1][2]=":";
				}
				else
				{
					tempcols[1][1]="";
					tempcols[1][2]="";
				}

				bodybuffer=bodybuffer+'<tr class="gray">';
				
				if(colspan==7)
				{
					bodybuffer=bodybuffer+'<td></td>';
				}

				bodybuffer=bodybuffer+'<td class=f align=center valign=top>'+tempcols[0]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-RIGHT:0px;">'+tempcols[1][0]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-RIGHT:0px;PADDING-LEFT:0px;">'+tempcols[1][2]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-LEFT:0px;">'+tempcols[1][1]+'</td>'+
				'<td class=f align=center valign=top>'+tempcols[2]+'</td>'+
				'<td class=f Style="width:2000" valign=top>'+tempcols[3]+'</td></tr>';
			}
			else
			{
				bodybuffer=bodybuffer+'<tr class="gray">'+
				'<td class=f colspan='+colspan+'>'+temp[xi].substr(2,temp[xi].length)+'</td></tr>';
			}
		}
  		else
  		{
			thisnum++;
			tempcols=temp[xi].split("\t");
			if(tempcols.length==4)
			{
				tempcols[1]=tempcols[1].split(":");

				if(tempcols[1][1])
				{
					tempcols[1][2]=":";
				}
				else
				{
					tempcols[1][1]="";
					tempcols[1][2]="";
				}

				bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'">';

				if(colspan==7)
				{
					if(tracksarray[point])
					{
						if(tracksarray[point].substring(0,1)=='v')
						{
							bodybuffer=bodybuffer+'<td valign=top class=play><img onclick="loadvid(\''+tracksarray[point].substring(1,tracksarray[point].length)+'\')" src='+targeturl+'DATA/s/play.gif ></td>';
						}
						else
						{
							bodybuffer=bodybuffer+'<td valign=top class=play><img onclick="play(\''+tracksarray[point]+'\')" src='+targeturl+'DATA/s/play.gif ></td>';
						}
					}
					else
					{
						bodybuffer=bodybuffer+'<td></td>';
					}
				}
				
				point++;

				bodybuffer=bodybuffer+'<td class=f align=center valign=top>'+tempcols[0]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-RIGHT:0px;">'+tempcols[1][0]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-RIGHT:0px;PADDING-LEFT:0px;">'+tempcols[1][2]+'</td>'+
				'<td class=f align=center valign=top style="PADDING-LEFT:0px;">'+tempcols[1][1]+'</td>'+
				'<td class=f align=center valign=top>'+tempcols[2]+'</td>'+
				'<td class=f Style="width:2000" valign=top>'+tempcols[3]+'</td></tr>';
			}
			else
			{
				bodybuffer=bodybuffer+'<tr class="wb" onmouseout="this.className=\'wb\'" onmouseover="this.className=\'bw\'">'+
				'<td class=f colspan='+colspan+'>'+temp[xi]+'</td></tr>';
			}
		}
	}

	bodybuffer=bodybuffer+'</table>';


	temp3=tempload[1];

	if(temp3!=null)
	{
		temp3=temp3.split("\n");

		direction=temp3[0];

		records=records.split("<br>");
		alt='';


		if(direction=='v')
		{
			ypos=35;
			xpos=10;
		}
		else
		{
			ypos=65;
			xpos=-20;
		}


		for(xi=1;xi<temp3.length;xi++)
		{
			if(temp3[xi])
			{
				temp4=temp3[xi].split("\t");


				if(temp4[1])
				{
					alt=replaceIt(records[temp4[0]],'"',"''").substr(2,1024);

					if(temp4[1]=='n')
					{
						if(direction=='v')
						{
							ypos=ypos+30;
						}
						else
						{
							xpos=xpos+30;
						}
					}
					else
					{
						if(direction=='v')
						{
							xpos=xpos+60;
							ypos=35+30;
						}
						else
						{
							ypos=ypos+60;
							xpos=10;
						}
					}
				}
				else
				{
					jpg=temp4[0].split(" ");

					for(jpgx=0;jpgx<jpg.length;jpgx++)
					{
						thisjpg=jpg[jpgx];

						if(jpgx==0)
						{
							thisjpg=jpg[0];
						}
						else
						{
							thisjpg=jpg[0].substring(0,jpg[0].length-1)+jpg[jpgx];
						}

						bodybuffer=bodybuffer+
						'<a onFocus=this.blur() id=link'+picIDnr+' onMouseDown="savepos('+picIDnr+');" href=javascript:dummy() ondblclick=changepic("'+picIDnr+'") '+
						'Style="z-index:'+zindex+';POSITION:absolute;right:'+xpos+'px;TOP:'+ypos+'px;">'+
						'<img id=pic'+picIDnr+' onmouseover=changezindex("'+picIDnr+'") src='+picsrc+'/t/'+thisjpg+picext+' title="'+alt+'" ></a>';
						picArray[picIDnr]=Array('s',alt,thisjpg);
						picIDnr++;
						zindex++;

						if(direction=='v')
						{
							ypos=ypos+30;
						}
						else
						{
							xpos=xpos+30;
						}
					}
				}
			}
		}
	}

	document.getElementById('body').innerHTML=bodybuffer+'<iframe ID=newinfoframe name=newinfoframe style="display:none;" scrolling=no></iframe>';

	if (top.location != self.location)
	{
		//	window.open(targeturl+'info.php'+'?'+'target='+this.name+'&url='+escape(self.location)+'&text='+escape(temp[0]),'infoframe');
			window.open(targeturl+'info2.php'+'?'+'target='+this.name+'&url='+escape(self.location)+'&text='+escape(temp[0]),'newinfoframe');

	}
}

function play(id)
{
	window.open(targeturl+'info2.php'+'?'+'pid='+id,'newinfoframe');
}

function loadvid(id)
{
	window.open(targeturl+'info2.php'+'?'+'vid='+id,'newinfoframe');
}

function replaceIt(string,suchen,ersetzen)
{
	ausgabe = "" + string;
	while (ausgabe.indexOf(suchen)>-1)
	{
    	pos= ausgabe.indexOf(suchen);
    	ausgabe = "" + (ausgabe.substring(0, pos) + ersetzen +
		ausgabe.substring((pos + suchen.length), ausgabe.length));
  	}
  	return ausgabe;
}
