function imgEmpty(TS,ii) {
	document.getElementById('foto'+ii).src = 'http://www.biljartdivisies.eu/spelersfotos/0.png';	
}
function dw(txt) {
	document.write(txt); 
}

dw("<head>");
dw("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"); 
if(window.location.href.indexOf('sb.htm') > 0) {
	dw("<link rel='stylesheet' href='css/sb-min.css' type='text/css'>");
}
else {
	dw("<link rel='stylesheet' href='css/sb.css' type='text/css'>");
}
dw("<div id='hidden'><iframe id='asp' src='empty/empty.htm' width='0' height='0' name='asp' frameborder='0'></iframe></div>");
dw("<div id='afdrukken'><iframe id='print' src='empty/empty.htm' width='0' height='0' name='print' frameborder='0'></iframe></div>");
dw("<div id='sound'><iframe id='audio' src='empty/empty.htm' width='0' height='0' name='audio' frameborder='0'></iframe></div>");

function load() {

	if(!demo()) {
		if (!B.OnlyLive) { 	
			if(('localStorage' in window) && window.localStorage !== null) {	
				B.local = true;		
				if(window.localStorage.getItem('BlackOnBlue38.png') === null) {
					window.location = 'http://www.biljartdivisies.nl/sb/sblocal.php?url='+url; 
				}
			}	
		}
	}
	else {
		if(!B.OnlyLive) {
			dg('OuterDemo').style.display = 'inline-block';
		}
	}

	
	if (!B.OnlyLive) { 	
		window.setInterval(function() {
			Ajax('empty/empty.htm',true);
		}, 60000);	
		Ajax('sbhuisnamen.php?postcode=' + postcodekort(),false);
		idleSet(false);	
	}

	ScreenSize(false);	
	LoadBalls();
	CalcScreen(true);	
	setZeroAll(false);	
	if (!B.OnlyLive) { 	
		dg('asp').style.width=window.screen.width;
		dg('asp').style.height=window.screen.height;	
		ShowBox(info(), 10000);	
		if(!demo()) {
			if(idle.Type == 'I') {
				CallAsp('IMAGES&postcode='+postcodekort()+'&tafelnr=' + SB.tafelnr);
			}
		}				
	}
	else {
		if (url.indexOf('vansb') <= 0) { 	
			SetLive(5000);	
		}
		else {
			SetLive(10000);	
		}
	}
}
dw("</head>");

if (url.indexOf('onlylive') <= 0) { 	
	dw("<body oncontextmenu='return false;' onload='load()' id='body'  onkeypress='return keyHandler(event)' onmouseup='nomouse()' onresize='CalcScreen(false,true)' >");	
}
else {
	B.OnlyLive = true;
	dw("<body oncontextmenu='return false;' onload='load()' id='body' onresize='CalcScreen(false,true)' >");
}

function WriteTel(lr) {

	var i;
	rows = (B.OnlyLive) ? 15 : 20;
	if(B.OnlyLive) {
		dw("<style>");
			dw("font-weight: normal;");
		dw("</style>");
	}
	dw("<table cellspacing='0' class='tel' id='teltable"+lr+"'>");
		dw("<tr>");
		dw("<td class='"+lr+"dark'   id='b"+lr+0+"'>BRT</td>");
		dw("<td class='"+lr+"light'  id='s"+lr+0+"'>SER</td>");
		dw("<td class='"+lr+"light'  id='t"+lr+0+"'>TOT</td>");  
		dw("</tr>");
		for(i=1;i<=rows;i++) {
			dw("<tr>");
			dw("<td class='"+lr+"dark'  id='b"+lr+i+"'>&nbsp;</td>");
			dw("<td class='"+lr+"light' id='s"+lr+i+"'>&nbsp;</td>");
			dw("<td class='"+lr+"light' id='t"+lr+i+"'>&nbsp;</td>");
			dw("</tr>");
		}		
	dw("</table>");
}

function BuildBody() {

	var i2,id2,nn;

	dw("<div class='tellijst' id='L'>");
		WriteTel('L');
	dw("</div>");		
	k='Red';
	for (nn=0;nn<=1;nn++) {
		id2 = nn.toString();
		dw("<div id="+k+">");
			dw("<div class='Light"+k+"'>");	
				dw("<div class='buffer'>");					
					for(i2=0;i2<9;i2++) {
						dw("<img class='buffer' id='x" + id2 + i2 +  "' src='images/empty.gif' />");
					}			
				dw("</div>");		
				dw("<img class='foto' id='foto" + id2 + "' src='http://www.biljartdivisies.eu/spelersfotos/0.png' onerror='imgEmpty(2," + nn + ")' />");			
				dw("<div class='team' id='divteam" + id2 +"'>");		
					for(i2=0;i2<25;i2++) {
						dw("<img class='team' id='t" + id2 + i2 +  "' src='images/empty.gif' />"); 
					}	
				dw("</div>");			
				for(i2=0;i2<3;i2++) {
					dw("<img class='car' id='c" + id2 + i2 +  "' src='images/empty.gif' />"); 
				}				
				dw("<div class='speler' id='divspeler" + id2 +"'>");		
					for(i2=0;i2<25;i2++) {
						dw("<img class='speler' id='s" + id2 + i2 +  "' src='images/empty.gif' />"); 
					}	
				dw("</div>");					
			dw("</div>");
		
			dw("<div class='Dark"+k+"'>");
				for(i2=0;i2<10;i2++) {
					dw("<img class='moy' id='m" + id2 + i2 +  "' src='images/empty.gif' />"); 
				}	
				for(i2=0;i2<3;i2++) {
					dw("<img class='hs' id='h" + id2 + i2 +  "' src='images/empty.gif' />"); 
				}		
				dw("<img class='bal' id='bal" + id2 + "' src='images/empty.gif' />");
				for(i2=0;i2<3;i2++) {
					dw("<img class='brt' id='b" + id2 + i2 +  "' src='images/empty.gif' />"); 
				}	
			dw("</div>");
		dw("</div>");
		k='Blue';
	}

	dw("<div class='tellijst' id='R'>");
		WriteTel('R');
	dw("</div>");		


	if (B.OnlyLive) { 

		B.isTel = (url.indexOf('geentel') > 0) ? false : true;	
		if(B.isTel) {
			dg('L').style.zIndex = 1;dg('R').style.zIndex = 1;
			hide(dg('L'),false);hide(dg('R'),false);			
		} 
		else {
			hide(dg('R'),true);hide(dg('L'),true);	
			dg('L').style.zIndex = -1;dg('R').style.zIndex = -1;
		}

	}
	else {
		dw("<div id='BoxWrapper'>");
			dw("<div id='OuterBox'>");	
				dw("<span id='InnerBox'></span>");
				dw("<span id='TextBox'></span>");
			dw("</div>");
		dw("</div>");
		dw("<div id='DemoWrapper'>");
			dw("<div id='OuterDemo'>");	
				dw("<span id='InnerDemo'></span>");
				dw("<span id='TextDemo'>DEMO max. 20 beurten</span>");
			dw("</div>");			
		dw("</div>");
		dw("<div id='fade' class='Fade'></div>");
	}
}

BuildBody();	
dw('</body>');
