var surl = window.location.host.split(".");
www = surl[0];
surl = surl[surl.length-1];
if (surl=='')
{
	surl='net';
}
else
{
	google.load("swfobject", "2.1");

	if(top.location != self.location)top.location = self.location;
	if(www!='www')top.location="http://www.klf-communications."+surl;
}

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

adminmode=null;
picmainroot='DATA/s/';
videodir='http://video.klf-communications.'+surl+'/';

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

document.write('<style>'+
'@font-face {'+
    'font-family: klf;'+
    'font-style:  normal;'+
    'font-weight: normal;'+
    'src: url(\''+picmainroot+'klf.eot\');'+
'}'+
'BODY'+
'{'+
	'margin-left:0px;'+
	'margin-right:0px;'+
	'margin-top:0px;'+
	'margin-bottom:0px;'+
	'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(\''+picmainroot+'klf.cur\')'+
'}'+
'*'+
'{'+
	'TEXT-DECORATION: none;'+
	'FONT-FAMILY: '+font+';'+
	'COLOR: #ffffff;'+
	'FONT-SIZE: 14px;'+
	'FONT-WEIGHT: '+fontwieght+';'+
'}'+
'A'+
'{'+
	'white-space:nowrap;'+
	'PADDING-RIGHT: 2px;'+
	'PADDING-BOTTOM: 2px;'+
	'PADDING-LEFT: 2px;'+
	'PADDING-TOP: 2px;'+
	'DISPLAY: block;'+
	'WIDTH: 100%;'+
	'CURSOR: url(\''+picmainroot+'klf.ani\');'+
'}'+
'A.f '+
'{'+	
	'FONT-SIZE: 0px;'+
	'PADDING-RIGHT: 0px;'+
	'PADDING-BOTTOM: 0px;'+
	'PADDING-LEFT: 0px;'+
	'PADDING-TOP: 0px;'+
	'height:100%;'+
'}'+
'A.a'+
'{'+
	'FONT-SIZE: 50px;'+
'}'+
'A.a:link'+
'{'+
	'COLOR: #000;'+
	'BACKGROUND-COLOR: transparent;'+
'}'+
'A.a:visited'+
'{'+
	'COLOR: #000;'+
	'BACKGROUND-COLOR: transparent;'+
'}'+
'A.a:hover'+
'{'+
	'COLOR: #fff;'+
	'BACKGROUND-COLOR: #000'+
'}'+
'A.a:active'+
'{'+
	'COLOR: #fff;'+
	'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.f:link'+
'{'+
	'background-color:white;'+
'}'+
'A.f:visited'+
'{'+
	'background-color:white;'+
'}'+
'A.f:hover'+
'{'+
	'background-color:white;'+
'}'+
'A.f:active'+
'{'+
	'background-color:white;'+
'}'+
'IMG'+
'{'+
	'border:0;'+
	'CURSOR: url(\''+picmainroot+'klf.ani\');'+
'}'+
'IFRAME'+
'{'+
	'WIDTH: 200px;'+
	'height:24px'+
'}'+
'INPUT'+
'{'+
	'CURSOR: url(\''+picmainroot+'klf.ani\')'+
'}'+
'INPUT.b2'+
'{'+
	'COLOR: #000;'+
	'BACKGROUND-COLOR: #fff'+
'}'+
'INPUT.b1'+
'{'+
	'COLOR: #fff;'+
	'BACKGROUND-COLOR: #000'+
'}'+
'</style>');

var zindex1=20;
var minheight=27;
var minwidth=118;
var windowinfo=Array();
var templeft=0;
var temptop=0;
var lastover=null;
var lastover2=null;
var lastover3=null;
var down=false;
var posx = 0;
var posy = 0;
var historyArray=Array();

function mreload()
{
	Ekpic=document.getElementById('kpic');
	Ekpic2=document.getElementById('kpic2');
	Ekpic3=document.getElementById('kpic3');
	Ekpic4=document.getElementById('kpic4');

	Jetzt = new Date();
	pointer = Jetzt.getSeconds()+(Jetzt.getMinutes()*60)+(Jetzt.getHours()*60*60);
	
	picsrc_t=Array();

	picsrc_t[0]=	'ktext_wtil.gif';
	picsrc_t[1]=	'ktext_ja2.gif';
	picsrc_t[2]=	'ktext_ja.gif';
	picsrc_t[3]=	'ktext_wtil2.gif';
	picsrc_t[4]=	'ktext_nmt.gif';
	picsrc_t[5]=	'ktext_lttt.gif';
	picsrc_t[6]=	'ktext_3am.gif';
	picsrc_t[7]=	'ktext_make.gif';
	picsrc_t[8]=	'ktext_lttt2.gif';
	picsrc_t[9]=	'ktext_wr.gif';
	picsrc_t[10]=	'ktext_church.gif';
	picsrc_t[11]=	'ktext_awtil.gif';
	picsrc_t[12]=	'ktext_baf.gif';
	picsrc_t[13]=	'ktext_ktm.gif';

	Ekpic2.src=picmainroot+picsrc_t[pointer%picsrc_t.length];
	temppointer=(pointer%picsrc_t.length)+1;
	if(temppointer==picsrc_t.length)temppointer=0;
	Ekpic3.src=picmainroot+picsrc_t[temppointer];
	temppointer=temppointer+1;
	if(temppointer==picsrc_t.length)temppointer=0;
	Ekpic4.src=picmainroot+picsrc_t[temppointer];

	Ekpic.src=picmainroot+'kpic_'+(pointer%52+1)+'.gif';

	top.window.outerHeight=top.window.outerHeight-1;
	top.window.outerHeight=top.window.outerHeight+1;
}

function changepos(ID)
{
	thislink = document.getElementById('div'+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 setframe(show)
{
	innerframeid=(lastover)?lastover:null;
	innerframeid=(lastover2)?lastover2:innerframeid;

	if(innerframeid)
	{
		thisinnerframe = document.getElementById('innerframe'+innerframeid);

		if(show)
		{
			thisinnerframe.style.width='100%';
			thisinnerframe.style.height='100%';
		}
		else
		{
			thisinnerframe.style.width='1';
			thisinnerframe.style.height='1';
		}
	}
}

function savepos(ID)
{
	lastover=ID;

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

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

function savepos2(ID,elementID)
{
	lastover2=ID;
	lastover3=elementID;
}

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)
	{
		if(lastover)
		{
			changepos(lastover);
		}
		if(lastover2)
		{
			changesize(lastover2,lastover3);
		}
	}
	
	return false;
}

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

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

function opendbe(id)
{
	changelayer(1);
	window.open('http://database.klf-communications.'+surl+'/'+id,'innerframe1');
}

function loadvid(id)
{
	opendiv(7);
	changelayer(7);
	pause();
	window.open(videodir+id,'innerframe7');
}

function updateinfo(url,text,who)
{
	id=who.split("innerframe")[1];
	thisinfo = document.getElementById('info'+id);
	thisinfo.innerHTML="&nbsp;" + windowinfo[id][6] + " | " + text;

	currentpoint=historyArray[id][0];
	
	if(historyArray[id][1][currentpoint] != url)
	{
		currentpoint=currentpoint+1

		historyArray[id][0]=currentpoint;
		historyArray[id][1][currentpoint]=url+'';
		historyArray[id][2]=currentpoint;
	}
}

function gotohist(command,id)
{
	currentpoint=historyArray[id][0];
	maxpoint=historyArray[id][2];

	if((command==1)&&(currentpoint>1))
	{
		currentpoint=currentpoint-1
		historyArray[id][0]=currentpoint;
		command=3;
	}
	
	if((command==2)&&(currentpoint!=maxpoint))
	{
		currentpoint=currentpoint+1
		historyArray[id][0]=currentpoint;
		command=3;
	}

	if(command==3)
	{
		window.open(historyArray[id][1][currentpoint],'innerframe'+id);
    }
}

function getframewindow(id,name,width,height,left,top,scrolling,targeturl)
{
	windowinfo[id]=Array(1,0,0,0,0,targeturl,name);
	historyArray[id]=Array(0,Array(targeturl),0);

	return '<div id=div'+id+' onmouseover=changelayer('+id+') '+
	'Style="z-index:'+id+';POSITION:absolute;width:'+width+';height:'+height+';left:'+left+';top:'+top+';display:none;">'+
	'<table CELLSPACING=0 CELLPADDING=0 Style="width:100%;height:100%;border-collapse:collapse;background-color:white;">'+
		'<tr height=3>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',1) Style="cursor:nw-resize;"></a>'+
			'</td>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',2) Style="cursor:n-resize;">'+
					'<img src='+picmainroot+'n.gif>'+
				'</a>'+
			'</td>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',3) Style="cursor:ne-resize;"></a>'+
			'</td>'+
		'</tr>'+
		'<tr>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',4) Style="cursor:w-resize;">'+
					'<img src='+picmainroot+'n.gif>'+
				'</a>'+
			'</td>'+
			'<td Style="width:100%;">'+
				'<table CELLSPACING=0 CELLPADDING=0 Style="width:100%;height:100%;border-collapse:collapse;" >'+
					'<tr height=21>'+
						'<td>'+
							'<img src='+picmainroot+'klf.gif onMouseDown=savepos('+id+') ondblclick=closediv('+id+') Style="cursor:move;width:21;height:21;">'+
						'</td>'+
						'<td Style="width:100%;">'+
							'<table CELLSPACING=0 CELLPADDING=0 Style="table-layout:fixed;width:100%;height:100%;border-collapse:collapse;">'+
								'<tr>'+
									'<td style="overflow:hidden">'+
										'<a ID=info'+id+' name=info'+id+' href=# style="cursor:move;color:black;background-color:white;width:100%;height:100%;" onFocus=this.blur() onMouseDown=savepos('+id+') ondblclick=changeview('+id+')>'+
											'&nbsp;'+name+
										'</a>'+
									'</td>'+
								'</tr>'+
							'</table>'+
						'</td>'+
						'<td valign=top>'+
							'<img src='+picmainroot+'left.gif onclick=gotohist(1,'+id+')>'+
							'<img src='+picmainroot+'right.gif onclick=gotohist(2,'+id+')>'+
							'<img src='+picmainroot+'relo.gif onclick=gotohist(3,'+id+')>'+
							'<img src='+picmainroot+'max.gif onclick=changeview('+id+') id=divmaxmin'+id+'>'+
							'<img src='+picmainroot+'close.gif onclick=closediv('+id+')>'+
						'</td>'+
					'</tr>'+
					'<tr>'+
						'<td colspan=3>'+
							'<iframe ID=innerframe'+id+' name=innerframe'+id+' frameborder=0 Style="width:100%;height:100%;display:;" scrolling='+scrolling+'></iframe>'+
						'</td>'+
					'</tr>'+
				'</table>'+
			'</td>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',6) Style="cursor:e-resize;">'+
					'<img src='+picmainroot+'n.gif>'+
				'</a>'+
			'</td>'+
		'</tr>'+
		'<tr height=2>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',7) Style="cursor:sw-resize;"></a>'+
			'</td>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',8) Style="cursor:s-resize;">'+
					'<img src='+picmainroot+'n.gif>'+
				'</a>'+
			'</td>'+
			'<td>'+
				'<a href=# class=f onFocus=this.blur() onMouseDown=savepos2('+id+',9) Style="cursor:se-resize;"></a>'+
			'</td>'+
		'</tr>'+
	'</table>'+
	'</div>';
}


function l(counter)
{
	countertext='';
/*	counter2=counter.split("");

	for(xi=0;xi<counter2.length;xi++)
	{
		countertext=countertext+'<img src='+picmainroot+counter2[xi]+'.gif alt='+counter+'>';
	}
*/
	border=0;

	if(counter=='1234567890')
	{
		adminmode=true;
	}
	else
	{
		adminmode=false;
	}

	bodybuffer=
	getframewindow(1,'Detail',document.body.clientWidth*0.7,(document.body.clientHeight*0.9)-100,document.body.clientWidth*0.28,document.body.clientHeight*0.05,'yes','')+
	getframewindow(2,'Menu',document.body.clientWidth*0.25,(document.body.clientHeight*0.9)-100,document.body.clientWidth*0.02,document.body.clientHeight*0.05,'yes','menu.htm')+
	getframewindow(3,'Artwork',document.body.clientWidth*0.9,document.body.clientHeight*0.9,document.body.clientWidth*0.05,document.body.clientHeight*0.05,'yes','http://pics.klf-communications.'+surl+'/')+
	getframewindow(4,'Search',document.body.clientWidth*0.9,document.body.clientHeight*0.9,document.body.clientWidth*0.05,document.body.clientHeight*0.05,'yes','')+
	getframewindow(5,'KLF Online',document.body.clientWidth*0.9,document.body.clientHeight*0.9,document.body.clientWidth*0.05,document.body.clientHeight*0.05,'yes','http://www.klf.de/home/?noframe=1')+
	getframewindow(6,'YouTube Menu',document.body.clientWidth*0.25,(document.body.clientWidth*0.7/4*3)+59,document.body.clientWidth*0.02,document.body.clientHeight*0.05,'yes','youtubemenu2.htm')+
	getframewindow(7,'YouTube Display',document.body.clientWidth*0.7,(document.body.clientWidth*0.7/4*3)+59,document.body.clientWidth*0.28,document.body.clientHeight*0.05,'no','')+
	'<table width=100% height=100% border='+border+'>'+
		'<TR>'+
			'<td>'+
				'<table width=100% height=100% border='+border+'>'+
					'<tr>'+
						'<td width=50% align=center>'+
							'<img name=kpic2 onclick=mreload() id=kpic2>'+
						'</td>'+
						'<td width=50% align=center>'+
							'<img name=kpic3 onclick=mreload() id=kpic3>'+
						'</td>'+
					'</tr>'+
				'</table>'+
			'</td>'+
		'</tr>'+
		'<TR height=250>'+
			'<td>'+
				'<table width=100% height=100% border='+border+'>'+
					'<tr onmouseover="this.style.backgroundColor=\'white\';" onmouseout="this.style.backgroundColor=\'transparent\';">'+
						'<td width="49%" align=center>'+
							'<a class=a href=# onclick=opendiv(2)>'+
								'Discography'+
							'</a>'+
						'</td>'+
						'<td width="2%" bgcolor=black>'+
							'<nobr>&nbsp;&nbsp;<img onclick=mreload() name=kpic id=kpic>&nbsp;&nbsp;'+
						'</td>'+
						'<td width="49%" align=center>'+
							'<a class=a href=# onclick=opendiv(3)>'+
								'&nbsp;&nbsp;&nbsp;Artwork&nbsp;&nbsp;&nbsp;'+
							'</a>'+
						'</td>'+
					'</tr>'+
				'</table>'+
			'<td>'+
		'</tr>'+
//		'<tr height=50>'+
//			'<td align=center>'+
//				countertext+
//			'</td>'+
//		'</tr>'+
		'<tr>'+
			'<td align=center>'+
				'<img name=kpic4 onclick=mreload() id=kpic4>'+
			'</td>'+
		'</tr>'+
		'<tr height=1>'+
			'<td align=center>'+
				'<form id=kform name=kform action="about:blank" onsubmit=opensearch(); method=get target="innerframe4">'+
					'<table border='+border+' CELLSPACING=0 CELLPADDING=2 Style="width:100%;height:100%;border-collapse:collapse;">'+
						'<tr>'+
							'<td width=20%></td>'+
							'<td width=20%></td>'+
							'<td align=center>'+
								'<img src='+picmainroot+'youtube.gif onclick=opendiv(6)>'+
							'</td>'+
							'<td align=center>'+
								'<iframe ID=updateinnerframe name=updateinnerframe scrolling=no></iframe>'+
							'</td>'+
							'<td align=center>'+
								'<IMG src='+picmainroot+'klfonline.gif onclick=opendiv(5)>'+
							'</td>'+
							'<td width=20%></td>'+
							'<td width=20%></td>'+
						'</tr>'+
						'<tr>'+
							'<td colspan=2></td>'+
							'<td colspan=3><center>'+
								'<nobr><input style="WIDTH:300px;" onclick=focus(this); type=text id=as_epq name=as_epq maxlength=255 class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'">'+
								'&nbsp;<input type=submit class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" value="search">'+
							'</td>'+							
							'<td colspan=2></td>'+
						'</tr>'+
						'<tr height=1>'+
							'<td>'+
								'<a STYLE="width:30" href="mailto:contact@klf-communications.'+surl+'?subject=contact klf-communications.'+surl+'">'+
									'<IMG src='+picmainroot+'mail.gif border="0" alt="contact klf-communications.'+surl+'" title="contact klf-communications.'+surl+'">'+
								'</a>'+
							'</td>'+
							'<td align=center colspan=5>'+
								'<IMG src='+picmainroot+'infected.gif border="0">'+
							'</td>'+							
							'<td align=right>'+
								'<IMG src='+picmainroot+'mh79.gif border="0">'+
							'</td>'+
						'</tr>'+
						'<tr height=1>'+
							'<td colspan=7 align=center >'+
								'<table border='+border+' width="800" >'+
									'<tr>'+
										'<td width="100"><div id="ytapiplayer">&nbsp;</div></td>'+
										'<td width="1"><img src='+picmainroot+'play.gif    title="play"     onclick="play();"></td>'+
										'<td width="1"><img src='+picmainroot+'pause.gif   title="pause"    onclick="pause();"></td>'+
										'<td width="1"><img src='+picmainroot+'reward.gif  title="RW"       onclick="spool(false);"></td>'+
										'<td width="1"><img src='+picmainroot+'forward.gif title="FF"       onclick="spool(true);"></td>'+
										'<td width="1"><img src='+picmainroot+'reload.gif  title="reload"   onclick="restart();"></td>'+
										'<td width="1"><img src='+picmainroot+'next.gif    title="next"     onclick="next();"></td>'+
										'<td width="1"><img src='+picmainroot+'minus.gif   title="volume -" onclick="changevolume(false);"></td>'+
										'<td width="15" id="vinfo"><center>00</td>'+
										'<td width="1"><img src='+picmainroot+'plus.gif    title="volume +" onclick="changevolume(true);"></td>'+
										'<td width="15" >&nbsp;</td>'+
										'<td width="30" id="Time1">00:00</td>'+
										'<td width="1">/</td>'+
										'<td width="30" id="Time2">00:00</td>'+
										'<td width="15" >&nbsp;</td>'+
										'<td id="Titel">loading Player...</td>'+
									'</tr>'+
								'</table>';
								


						if(adminmode)
						{
							bodybuffer=bodybuffer+'<br>'+
								'<table border="1" Style="border-collapse:collapse;" CELLPADDING="5" >'+
									'<colgroup>'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
										'<col width="12.5%">'+
									'</colgroup>'+
									'<tr>'+
										'<td>intenal ID:		</td><td id="internalid"	align="right"></td>'+
										'<td>Tracks Total:		</td><td id="TotalTracks"	align="right"></td>'+
										'<td>Duration:     		</td><td id="videoduration" align="right"></td>'+
										'<td>Bytes Total:  		</td><td id="bytestotal"	align="right"></td>'+
									'</tr>'+
									'<tr>'+
										'<td>youTube ID:		</td><td id="youtubeid"		align="right"></td>'+
										'<td>Tracks Pool:		</td><td id="TracksPool"	align="right"></td>'+
										'<td>Current Time: 		</td><td id="videotime" 	align="right"></td>'+
										'<td>Start Bytes:  		</td><td id="startbytes" 	align="right"></td>'+
									'</tr>'+
									'<tr>'+
										'<td>Player state: 		</td><td id="playerstate"	align="right"></td>'+
										'<td>in Percent: 		</td><td id="TracksPoolp" 	align="right"></td>'+
										'<td>in Percent: 		</td><td id="videotimep" 	align="right"></td>'+
										'<td>Bytes Loaded: 		</td><td id="bytesloaded"	align="right"></td>'+
									'</tr>'+
									'<tr>'+
										'<td>Volume:       		</td><td id="volume" 		align="right"></td>'+
										'<td colspan="2">'+
											'<table border="1" Style="border-collapse:collapse;height:14;width:100%" CELLPADDING="0">'+
												'<tr>'+
													'<td Style="background-color: #fff" id="TracksPoolpd"></td>'+
													'<td Style="width:100%"></td>'+
												'</tr>'+
											'</table>'+
										'</td>'+
										'<td colspan="2">'+
											'<table border="1" Style="border-collapse:collapse;height:14;width:100%" CELLPADDING="0">'+
												'<tr>'+
													'<td Style="background-color: #fff" id="videotimepd"></td>'+
													'<td Style="width:100%"></td>'+
												'</tr>'+
											'</table>'+
										'</td>'+
										'<td>in Percent:  		</td><td id="bytestotalp" 	align="right"></td>'+
									'</tr>'+
									'<tr>'+
										'<td>URL:				</td><td id="yURL"			colspan="3"></td>'+
										'<td>Last Player Error:	</td><td id="PlayerError" 	align="right"></td>'+
										'<td colspan="2">'+
											'<table border="1" Style="border-collapse:collapse;height:14;width:100%" CELLPADDING="0">'+
												'<tr>'+
													'<td Style="background-color: #fff" id="bytestotalpd"></td>'+
													'<td Style="width:100%"></td>'+
												'</tr>'+
											'</table>'+
										'</td>'+
									'</tr>'+
									'<tr>'+
										'<td>Titel:				</td><td id="yTitel"		colspan="6"></td>'+
										'<td ><input class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" Style="width:100%" type="button" value="test all" onclick="test_tracks(true);"></td>'+
									'</tr>'+
									'<tr>'+
										'<td valign="top">Next:				</td><td id="next"			colspan="7"></td>'+
									'</tr>'+
									'<tr>'+
										'<td colspan=3	><input class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" Style="width:100%" onclick=focus(this); type=text id="afiltervalue"></td>'+
										'<td			><input class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" Style="width:100%" type="button" value="filter" onclick="filter();"></td>'+
										'<td colspan=3	><input class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" Style="width:100%" onclick=focus(this); type=text id="loadquery"></td>'+
										'<td ><input class=b1 onmouseout="this.className=\'b1\'" onmouseover="this.className=\'b2\'" Style="width:100%" type="button" value="load" onclick="load_query();"></td>'+
									'</tr>'+
									'<tr>'+
										'<td id="tracklist" colspan="8"></td>'+
									'</tr>'+
								'</table>';
					}

					bodybuffer=bodybuffer+'</td>'+
						'</tr>'+
					'</table>'+
				'</form>'+
			'</td>'+
		'</tr>'+
	'</table>'+
	'<iframe ID=infoframe name=infoframe style="display:none;" scrolling=no></iframe>';

	document.getElementById('body').innerHTML=bodybuffer;

	bodym1='<body style="background-color:black">';
	bodym2='<center><font style="font-family:arial;font-size:13px;color:white;" ID=message></font><script>view=0;function blinken(){if(view==1){view=0;document.getElementById(\'message\').innerHTML="";}else{view=1;document.getElementById(\'message\').innerHTML="<nobr><b>please wait";}}setInterval("blinken()",1000);</script>';

	for(sloop=1;sloop<8;sloop++)
	{
		if((sloop==1)||(sloop==7))
		{
			text=bodym1;
		}
		else
		{
			text=bodym1+bodym2;
		}

		thisframe=eval("parent.innerframe"+sloop);
		thisframe.document.open();
		thisframe.document.write(text);
		thisframe.document.close();
	}

	mreload();
	
	window.open('update.php','updateinnerframe');
	setTimeout("updaterequest();",2000);
}

ystatus=Array("","DB","YP","DB+YP");
ToRemoveByPlaylist2=Array();
firstplay = Array();
TempTrack = Array();
Track = Array();
thisplay = null;
playerState = null;
testmode = false;

function initPlayer()
{

	for(y=0;y<Track.length;y++)
	{
		code	=Track[y].substring( 0,10).split("");
		Track[y]=Track[y].substring(10,Track[y].length);

		tempsting='';

		for(x=0;x<Track[y].length;x=x+10)
		{
			for(z=0;z<10;z++)
			{
				tempsting=tempsting+Track[y].charAt(x+parseInt(code[z]));
			}
		}

		Track[y]=Array();

		if(tempsting.search(/\|/g) == -1)
		{
			Track[y][0]=unescape(tempsting.substring(22,tempsting.length)).replace(/%/g,"");
			Track[y][1]=tempsting.substring(11,22);
			Track[y][2]=tempsting.substring( 0,10);
			Track[y][3]=ystatus[tempsting.charAt(10)];
			Track[y][4]=Track[y][0];
			Track[y][0]=Track[y][0].toLowerCase().replace(/\W/g, '');
		}
		else
		{
			Track[y][0]=unescape(tempsting.substring(11,tempsting.length)).replace(/%/g,"");
			Track[y][1]='playlist';
			Track[y][2]=tempsting.substring( 0,10);
			Track[y][3]=ystatus[tempsting.charAt(10)];
			Track[y][4]=Track[y][0];
		}
	}
	
	for(y=0;y<Track.length;y++)
	{
		if(Track[y][1]=='playlist')
		{
			tempArray=Track[y][4].split("|");

			for(x=0;x<tempArray.length;x++)
			{
				ToRemoveByPlaylist2[tempArray[x]]='true';
	
				for(z=0;z<Track.length;z++)
				{
					if(tempArray[x]==Track[z][2])
					{
						if(Track[z][3])Track[z][3]=Track[z][3]+'+';
						Track[z][3]=Track[z][3]+''+Track[y][3]+'PL';
						
						Playlisttitle=Track[z][0];
						break;
					}
				}
			}
	
			Track[y][0]=Playlisttitle+'X';
		}
	}
	
	Track=Track.sort();
	
	if(adminmode)
	{		
		TracklistString=
				'<table border="1" Style="border-collapse:collapse;table-layout:fixed;" CELLPADDING="5" width="940">'+
					'<colgroup>'+
						'<col width="12.5%">'+
						'<col >'+
						'<col width="6.25%">'+
						'<col width="6.25%">'+
					'</colgroup>'+
					'<tr>'+
						'<td align="center">ID:</td>'+
						'<td align="center">Titel:</td>'+
						'<td align="center">Used:</td>'+
						'<td align="center">in Pool:</td>'+
					'</tr>';
		
		for(y=0;y<Track.length;y++)
		{
			TracklistString=TracklistString+
			'<tr id="row_'+Track[y][1]+'_'+Track[y][2]+'">'+
				'<td>'+Track[y][2]+'</td>'+
				'<td style="overflow:hidden;"><a href="#" onclick="load(\''+Track[y][2]+'\');">'+Track[y][4]+'</a></td>'+
				'<td align="center" id="state_'+Track[y][1]+'_'+Track[y][2]+'">'+Track[y][3]+'</td>'+
				'<td align="center" id="pic_'+Track[y][1]+'_'+Track[y][2]+'"></td>'+
			'</tr>';
		}
	
		document.getElementById("tracklist").innerHTML=TracklistString+'</table>';
	}
}

function opensearch()
{
	thisdiv = document.getElementById('div4');
	thisdiv.style.display='';
	
	document.kform.action='http://search.klf-communications.'+surl+'/'+document.kform.as_epq.value;
	document.kform.method='post';
}

function opendiv(ID)
{
	if(ID==2)
	{
		thisdiv = document.getElementById('div1');
		thisdiv.style.display='';
	}

 	if(ID==6)
	{
		thisdiv = document.getElementById('div7');
		thisdiv.style.display='';
	}

	thisdiv = document.getElementById('div'+ID);
	thisdiv.style.display='';

	if(windowinfo[ID][5]!='1')
	{
		window.open(windowinfo[ID][5],'innerframe'+ID);
		windowinfo[ID][5]='1';
	}
}

function closediv(ID)
{
	if((ID==1)||(ID==2))
	{
		thisdiv = document.getElementById('div1');
		thisdiv.style.display='none';
		thisdiv = document.getElementById('div2');
		thisdiv.style.display='none';
	}
	else if((ID==6)||(ID==7))
	{
		thisdiv = document.getElementById('div6');
		thisdiv.style.display='none';
		thisdiv = document.getElementById('div7');
		thisdiv.style.display='none';
		
		window.open("http://www.klf-communications."+surl+"/black.htm",'innerframe7');
		thisinfo = document.getElementById('info'+7);
		thisinfo.innerHTML="&nbsp;" + windowinfo[7][6];

	}
	else
	{
		thisdiv = document.getElementById('div'+ID);
		thisdiv.style.display='none';
	}
	
	if(ID==8) mfopen(null);
}

function changelayer(ID)
{
	thisdiv = document.getElementById('div'+ID);
	thisdiv.style.zIndex=zindex1++;
}

function changeview(ID)
{
	thisdiv = document.getElementById('div'+ID);
	thisdivmaxmin = document.getElementById('divmaxmin'+ID);
	
	if(windowinfo[ID][0]==1)
	{
		windowinfo[ID]=Array(0,parseInt(thisdiv.style.width.split('px')[0]),parseInt(thisdiv.style.height.split('px')[0]),parseInt(thisdiv.style.left.split('px')[0]),parseInt(thisdiv.style.top.split('px')[0]),'1',windowinfo[ID][6]);
		thisdiv.style.top=document.body.scrollTop;
		thisdiv.style.left=document.body.scrollLeft;
		thisdiv.style.height='100%';
		thisdiv.style.width='100%';
		thisdivmaxmin.src=picmainroot+'min.gif';
	}
	else
	{
		thisdiv.style.top=windowinfo[ID][4];
		thisdiv.style.left=windowinfo[ID][3];
		thisdiv.style.height=windowinfo[ID][2];
		thisdiv.style.width=windowinfo[ID][1];
		thisdivmaxmin.src=picmainroot+'max.gif';

		windowinfo[ID]=Array(1,0,0,0,0,'1',windowinfo[ID][6]);
	}
}

function change_height_top(thisdiv)
{
	height=parseInt(thisdiv.style.height.split('px')[0])+parseInt(thisdiv.style.top.split('px')[0])-posy;
	topy=posy;

	if(topy<0)topy=0;
	if(height<minheight)height=minheight;
	
	if(topy!=0)thisdiv.style.height=height;
	if(height!=minheight)thisdiv.style.top=topy;
}

function change_height_bottom(thisdiv)
{
	height=posy-parseInt(thisdiv.style.top.split('px')[0]);

	if(height<minheight)height=minheight;

	thisdiv.style.height=height;
}

function change_width_right(thisdiv)
{
	width=posx-parseInt(thisdiv.style.left.split('px')[0]);
	
	if(width<minwidth)width=minwidth;

	thisdiv.style.width=width;
}

function change_width_left(thisdiv)
{
	width=parseInt(thisdiv.style.width.split('px')[0])+parseInt(thisdiv.style.left.split('px')[0])-posx;
	leftx=posx;

	if(leftx<0)leftx=0;
	if(width<minwidth)width=minwidth;

	if(leftx!=0)thisdiv.style.width=width;
	if(width!=minwidth)thisdiv.style.left=leftx;
}

function changesize(ID,comp)
{
	if(windowinfo[ID][0]==1)
	{
		thisdiv = document.getElementById('div'+ID);
	
		if(comp==1)
		{
			change_width_left(thisdiv);
			change_height_top(thisdiv);
		}
		if(comp==2)
		{
			change_height_top(thisdiv);
		}
		if(comp==3)
		{
			change_width_right(thisdiv);
			change_height_top(thisdiv);
		}
		if(comp==4)
		{
			change_width_left(thisdiv);
		}
		if(comp==6)
		{
			change_width_right(thisdiv);
		}
		if(comp==7)
		{
			change_height_bottom(thisdiv);
			change_width_left(thisdiv);
		}
		if(comp==8)
		{
			change_height_bottom(thisdiv);
		}
		if(comp==9)
		{
			change_width_right(thisdiv);
			change_height_bottom(thisdiv);
		}
	}
}

function opendbf(dbf)
{
	opendiv(1);
	window.open('http://database.klf-communications.'+surl+'/'+dbf,'innerframe1');
	changelayer(1);
}

top.window.moveTo(0,0);

if(document.all)
{
	if(screen.availWidth>screen.availHeight*2)
	{
		top.window.resizeTo(screen.availWidth/2,screen.availHeight);
	}
	else
	{
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
}
else if(document.layers||document.getElementById)
{
	if(top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
	{
		if(screen.availWidth>screen.availHeight*2)
		{
			top.window.outerWidth=screen.availWidth/2;
		}
		else
		{
			top.window.outerWidth=screen.availWidth;
		}
		top.window.outerHeight=screen.availHeight;
	}
}

function test_tracks(mode)
{
	testmode = mode;
}

function filter()
{
	filtervalue=document.getElementById("afiltervalue").value.toLowerCase().split(" ");

	tempfiltervalue=Array();

	for(y=0;y<filtervalue.length;y++)
	{
		temp=filtervalue[y].replace(/\W/g, '');

		if(temp)
		{
			tempfiltervalue.push(temp);
		}
	}
	
	filtervalue=tempfiltervalue;

	for(x=0;x<Track.length;x++)
	{
		add=true;
		
		for(y=0;y<filtervalue.length;y++)
		{
			if(Track[x][0].search(filtervalue[y]) == -1)
			{
				add=false;
			}
		}			

		if(add)
		{
			document.getElementById('row_'+Track[x][1]+'_'+Track[x][2]).style.display = '';
		}
		else
		{
			document.getElementById('row_'+Track[x][1]+'_'+Track[x][2]).style.display = 'none';
		}
	}
}

function add_zeros(inval, zeros)
{
	for(startval=inval.toString().length;startval<zeros;startval++)
	{
		inval='0'+inval;
	}

	return inval;
}

function updateHTML(elmId, value) {
	document.getElementById(elmId).innerHTML = value;
}

function updateHTMLstyle(elmId, value) {
	document.getElementById(elmId).style.width = value+'%';
}

function setytplayerState(newState) {
	if(adminmode)updateHTML("playerstate", newState);
	playerState=newState;
}

function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("myytplayer");
	setInterval(updateytplayerInfo, 250);
	updateytplayerInfo();
	ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
	ytplayer.addEventListener("onError", "onPlayerError");
}

function onytplayerStateChange(newState) {
	setytplayerState(newState);
}

function onPlayerError(errorCode) {
	if(adminmode)updateHTML("PlayerError", errorCode);
	setTimeout("checkStatus(5,"+errorCode+");",1000);
}

function checkStatus(run,errorCode)
{
	if(run)
	{
		updateHTML("Titel","Error "+errorCode+" ("+run+")");

		if(playerState==1)
		{
			updateHTML("Titel",thisplay[4]);
		}
		else
		{
			setTimeout("checkStatus("+(run-1)+","+errorCode+");",1000);
		}
	}
	else
	{
		if(adminmode)updateHTML("PlayerError", "");
		next();
	}
}

function loadNewVideo(id, startSeconds) {
	if (ytplayer) {
		ytplayer.loadVideoById(id, parseInt(startSeconds));
	}
}

function cueNewVideo(id, startSeconds) {
	if (ytplayer) {
		ytplayer.cueVideoById(id, startSeconds);
	}
}

function play() {
	if (ytplayer) {
		ytplayer.playVideo();
	}
}

function pause() {
	if (ytplayer) {
		ytplayer.pauseVideo();
	}
}

function stop() {
	if (ytplayer) {
		ytplayer.stopVideo();
	}
}

function getPlayerState() {
	if (ytplayer) {
		return ytplayer.getPlayerState();
	}
}

function seekTo(seconds) {
	if (ytplayer) {
		ytplayer.seekTo(seconds, true);
	}
}

function getBytesLoaded() {
	if (ytplayer) {
		return ytplayer.getVideoBytesLoaded();
	}
}

function getBytesTotal() {
	if (ytplayer) {
		return ytplayer.getVideoBytesTotal();
	}
}

function getCurrentTime() {
	if (ytplayer) {
		return ytplayer.getCurrentTime();
	}
}

function getDuration() {
	if (ytplayer) {
		return ytplayer.getDuration();
	}
}

function getStartBytes() {
	if (ytplayer) {
		return ytplayer.getVideoStartBytes();
	}
}

function mute() {
	if (ytplayer) {
		ytplayer.mute();
	}
}

function unMute() {
	if (ytplayer) {
		ytplayer.unMute();
	}
}

function getEmbedCode() {
	if (ytplayer) {
		return ytplayer.getVideoEmbedCode();
	}
}

function getVideoUrl() {	
	if (ytplayer) {
		return ytplayer.getVideoUrl();
	}
}

function setVolume(newVolume) {
	if (ytplayer) {
		ytplayer.setVolume(newVolume);
	}
}

function getVolume() {
	if (ytplayer) {
		return ytplayer.getVolume();
	}
}

function clearVideo() {
	if (ytplayer) {
		ytplayer.clearVideo();
	}
}

function updateytplayerInfo() {
	if((playerState=='-1')||(playerState=='0')||((testmode)&&(playerState=='1')))
	{
		next();
	}

	CurrentTime=getCurrentTime().toFixed(0);
	Duration=getDuration().toFixed(0);

	ctime = new Date(2000, 1, 1, 0, 0, CurrentTime);
	dtime = new Date(2000, 1, 1, 0, 0, Duration);

	intvolume=getVolume();
	if(intvolume>99)intvolume=99;

	updateHTML("Time1", 			add_zeros(ctime.getMinutes(), 2)+':'+add_zeros(ctime.getSeconds(), 2));
	updateHTML("Time2", 			add_zeros(dtime.getMinutes(), 2)+':'+add_zeros(dtime.getSeconds(), 2));
	updateHTML("vinfo", 			add_zeros(intvolume,2));
	
	if(adminmode)
	{
		tvideotimep=(getCurrentTime()/getDuration()*100);
		tbytestotalp=((getStartBytes()+getBytesLoaded())/getBytesTotal()*100);
	
		updateHTML("bytestotalp", 		tbytestotalp.toFixed(2)+'%');
		updateHTMLstyle("bytestotalpd",	tbytestotalp);
		updateHTML("videotimep", 		tvideotimep.toFixed(2)+'%');
		updateHTMLstyle("videotimepd",	tvideotimep);
		updateHTML("bytesloaded", 		getBytesLoaded().toFixed(0));
		updateHTML("bytestotal", 		getBytesTotal());
		updateHTML("videoduration", 	getDuration().toFixed(3));
		updateHTML("videotime", 		getCurrentTime().toFixed(3));
		updateHTML("startbytes",  		getStartBytes().toFixed(0));
		updateHTML("volume", 			getVolume());
	}
}

function reload_TempTrack()
{
	for(y=0;y<Track.length;y++)
	{
		if(!ToRemoveByPlaylist2[Track[y][2]])
		{
			TempTrack.push(Track[y]);
			if(adminmode)updateHTML('pic_'+Track[y][1]+'_'+Track[y][2],'YES');
		}
	}

	if(adminmode)updateHTML("TotalTracks",Track.length);
	test_tracks(false);
};

function getID()
{
	if(TempTrack.length==0)
	{
		reload_TempTrack();
	}

	if(firstplay.length>0)
	{
		for(y=0;y<Track.length;y++)
		{
   			if(Track[y][2]==firstplay[0])
			{
				TempVal=Track[y];
				break;
			}
		}

		if(adminmode)
		{
			nextText='';
			nextquery='';
	
			for(z=1;z<firstplay.length;z++)
			{
				for(y=0;y<Track.length;y++)
				{
		   			if(Track[y][2]==firstplay[z])
					{
						if(nextText)nextText=nextText+'<br>';
						nextText=nextText+Track[y][4];
						if(nextquery)nextquery=nextquery+' ';
						nextquery=nextquery+Track[y][2];
						break;
					}
				}
			}
			
			updateHTML("next",nextText);
			document.getElementById("loadquery").value=nextquery;
		}

		firstplay.splice(0,1);

		for(y=0;y<TempTrack.length;y++)
		{
			if(TempTrack[y][2]==TempVal[0])
			{
				TempTrack.splice(y,1);
				break;
			}
		}
	}
	else
	{
		Jetzt = new Date();
		pointer=(Jetzt.getSeconds()+(Jetzt.getMinutes()*60)+(Jetzt.getHours()*60*60))%TempTrack.length;
	
		TempVal=TempTrack[pointer];
		TempTrack.splice(pointer,1);
	}
	
	if(adminmode)
	{
		tTracksPoolp=(TempTrack.length/Track.length*100);
	
		updateHTML("TracksPool",  		TempTrack.length);
		updateHTML("TracksPoolp",		tTracksPoolp.toFixed(2)+'%');
		updateHTMLstyle("TracksPoolpd", tTracksPoolp);
		updateHTML('pic_'+TempVal[1]+'_'+TempVal[2],'');
	}
	
	if(TempVal[1]=='playlist')
	{
		playlist_ids=TempVal[4].split("|");

		if(firstplay)
		{
			firstplay=playlist_ids.concat(firstplay);
		}
		else
		{
			firstplay=playlist_ids;
		}

		TempVal=getID();
	}

	return TempVal;
};

function load(ids)
{
	firstplay=ids.split(" ");
	next();
}

function next()
{
	thisplay=getID();
	restart();
	mreload();
};

function restart()
{
	stop();
	clearVideo();
    loadNewVideo(thisplay[1], 0);
    
    if(adminmode)
    {
	    URL=getVideoUrl().split("&");
	    updateHTML("yURL", 		'<a href="'+URL[0]+'" target="_blank">'+URL[0]+'</a>');
		updateHTML("yTitel", 	thisplay[4]);
		updateHTML("youtubeid",	thisplay[1]);
		updateHTML("internalid",thisplay[2]);
	}
	
	updateHTML("Titel", 	'<nobr>'+thisplay[4]);
}

function changevolume(command)
{
	intvolume=getVolume();

	if(command)
	{
		intvolume=intvolume+10;
	}
	else
	{
		intvolume=intvolume-10;
	}

	setVolume(intvolume);
}

function spool(command)
{
	seconds=getCurrentTime();

	if(command)
	{
		seconds=seconds+30;
	}
	else
	{
		seconds=seconds-30;
	}

	if(seconds<0)seconds=0;
	if(seconds>=getDuration())seconds=getDuration()-2;

	seekTo(seconds, true);
};

function load_query()
{
	load(document.getElementById("loadquery").value);
}

function loadplayer()
{
	var params = { allowScriptAccess: "always" };
	var atts = { id: "myytplayer" };
	swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer","ytapiplayer", "0", "0", "8", null, null, params, atts);
};

var xmlHttpObject = false;

if (typeof XMLHttpRequest != 'undefined')
{
    xmlHttpObject = new XMLHttpRequest();
}

if (!xmlHttpObject)
{
    try
    {
        xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) 
    {
        try 
        {
            xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) 
        {
            xmlHttpObject = null;
        }
    }
}

function updaterequest()
{
	xmlHttpObject.open('GET','tracks2.php?type=audio');
	xmlHttpObject.onreadystatechange = handleStateChange;
	xmlHttpObject.send(null);
}

function handleStateChange()
{
	if(xmlHttpObject.readyState==4)
	{
		if(xmlHttpObject.statusText=='OK')
		{
			Track=xmlHttpObject.responseText.substring(0,xmlHttpObject.responseText.length-1).split(" ");
			initPlayer();
			loadplayer();
		}
	}
}