var cl = new Array("cl0","cl1","cl2","b3","b4","b1","b2","n","nt");
var mB = 0;
var cC = "";
var cPC = cl[0];
var styles="";
function cPl(col){
	cPC="cl"+col.substr(1,6);
	if(styles.indexOf(cPC)<0){
		document.styleSheets[0].addRule("td."+cPC,"border-top:1px solid #ff9900;border-left:1px solid #ff9900;font-family:Tahoma;font-size:7px;text-align:center;background-color:"+col+";color:"+col+";cursor:default;height:12px;width:10px;", 0);
		styles=styles+cPC;
	}
}
function pMD(){
	var cell=window.event.srcElement,col;
	col=cell.style.background;cPC="cl"+col.substr(1,6);cC="";cPl(col);
	indicator.style.background=col;
	window.event.returnValue=false;
	window.event.cancelBubble=true;
}
function mDown(){
	mB=window.event.button;
	if(mB<1||mB>2)return;
	var cell=window.event.srcElement;
	if(mB==1) if(cell.className==cPC) cell.className=cl[0];else cell.className=cPC;
	else if(mB==2) if(cell.className==cl[2]) cell.className=cl[0];else cell.className=cl[2];
	cC = cell.className;
	window.event.returnValue=false;
	window.event.cancelBubble=true;
}
function mOver(){
	var cell=window.event.srcElement;
	if(cC!="")cell.className=cC;
	window.event.returnValue=false;
	window.event.cancelBubble=true;
}
function mUp(){
	mB=0;cC="";
	window.event.returnValue=false;
	window.event.cancelBubble=true;
}
function c(){
	window.event.returnValue=false;
	window.event.cancelBubble=true;
}
function a1Col(col){return colnum[col];}
function a2Col(col){
	var i=0,rc=colnum[col];
	i+=parseInt(rc.substr(1,1),16)+parseInt(rc.substr(3,1),16)+parseInt(rc.substr(5,1),16);
	if(i>15)return "000000";else return "FFFFFF";
}
function adT(num){
	document.write("<table class="+cl[8]+" cellspacing=0 cellpadding=0>");
	for(j=0;j<num.length;j++){
		document.write("<tr>");
		for(i=0;i<num[j].length;i+=2){
			if(i%10==0&&i>0) document.write("<td class="+cl[6]+" height=2 width=1><img src=/pic/1.gif></td>");
			if(num[j][i]==0) document.write("<td class="+cl[7]+" height=12 width=10>&nbsp</td>");
			else document.write("<td class="+cl[7]+" height=12 width=10 title='"+num[j][i]+"' style='background:#"+a1Col(num[j][i+1])+";color:#"+a2Col(num[j][i+1])+"' onmousedown='pMD()'>"+num[j][i]+"</td>");
		}
		document.write("</tr>");
	}
	document.write("</table>");
}
function adL(num){
	document.write("<table class="+cl[8]+" cellspacing=0 cellpadding=0>");
	for(j=0;j<num[0].length;j+=2){
		if(j%10==0&&j>0) document.write("<tr><td class="+cl[5]+"><img src=/pic/1.gif></td></tr>");
		document.write("<tr>");
		for(i=0;i<num.length;i++) 
			if(num[i][j]==0) document.write("<td class="+cl[7]+" height=12 width=10>&nbsp</td>");
			else document.write("<td class="+cl[7]+" height=12 width=10 title='"+num[i][j]+"' style='background:#"+a1Col(num[i][j+1])+";color:#"+a2Col(num[i][j+1])+"' onmousedown='pMD()'>"+num[i][j]+"</td>");
		document.write("</tr>");
	}
	document.write("</table>");
}
function adM(num1,num2){
	var cur=0;
	document.write("<table id=net cellspacing=0 cellpadding=0 class="+cl[4]+">");
	for(j=0;j<num2[0].length;j+=2){
		if(j%10==0&&j>0) document.write("<tr class="+cl[4]+"></tr>");
		document.write("<tr>");
		for(i=0;i<num1[0].length;i+=2){
			if(i%10==0&&i>0) document.write("<td class="+cl[3]+" height=2 width=1><img src=/pic/1.gif></td>");
			var c1=cl[0];
			document.write("<td class='"+c1+"' onmouseup='mUp()' onmousedown='mDown()' onmouseover='mOver()' oncontextmenu='c()' onselectstart='c()'	height=12 width=10>X</td>");
		}
		document.write("</tr>");
	}
	document.write("</table>");
}
document.write('<table border="3" cellspacing="0" cellpadding="0" align="center" class="alltext">');
document.write('<tr><td id="indicator" align=center style="background:#ff9900;">&nbsp</td><td>');
adT(a1num1);
document.write('</td></tr><tr><td>');
adL(a1num2);
document.write('</td><td>');
adM(a1num1,a1num2);
document.write('</td></tr></table>');
