var msg="Welcome to BITRONICA.COM .."
var delay=150
var timerId
var maxCount=0
var currCount=1
var menu=1
var isShowIntelBit=0
var isLoadIntelBit=0

var bit_x=Math.round(Math.random()*9)+1;
var bit_y=Math.round(Math.random()*9)+1;

function timer()
{
	var seed=Math.round(Math.random()*19)+1;
	var element=Math.round(Math.random()*8)+1;
	switch(seed)
	{
		case 1 : document.getElementById("td_"+element).style.backgroundColor='#FFFF99'; break;
		case 2 : document.getElementById("td_"+element).style.backgroundColor='#FFCC66'; break;
		case 3 : document.getElementById("td_"+element).style.backgroundColor='#FF9933'; break;
		case 4 : document.getElementById("td_"+element).style.backgroundColor='#FF6600'; break;
		case 5 : document.getElementById("td_"+element).style.backgroundColor='#993300'; break;
		case 6 : document.getElementById("td_"+element).style.backgroundColor='#CC3300'; break;
		case 7 : document.getElementById("td_"+element).style.backgroundColor='#330000'; break;
		case 8 : document.getElementById("td_"+element).style.backgroundColor='#FFFFCC'; break;
		case 9 : document.getElementById("td_"+element).style.backgroundColor='#660000'; break;
		case 10 : document.getElementById("td_"+element).style.backgroundColor='#990000'; break;
		default : document.getElementById("td_"+element).style.backgroundColor='#FFFFFF'; break;
	}
	if (maxCount==0) {
		maxCount=30000
	}
//	window.status=msg
	currCount++
	msg=msg.substring(1,msg.length)+msg.substring(0,1)
	if (currCount>=maxCount) {
		timerID=0
		window.status=""
		return
	} else {
		timerId=setTimeout("timer()", delay)
	}
	// bit-1
	if (isLoadIntelBit==0)
	{
		if (document.getElementById("isShowIntelBit").value=="1") {isShowIntelBit=1;}
		isLoadIntelBit=1;
	}
	if (isShowIntelBit==1) {
		var bit_move=Math.round(Math.random()*7)+1;
		if (verify(bit_x,bit_y,bit_move)==true) {
			switch(bit_move)
			{
			case 1: bit_x=bit_x-1; bit_y=bit_y-1;break;
			case 2: bit_x=bit_x+0; bit_y=bit_y-1;break;
			case 3: bit_x=bit_x+1; bit_y=bit_y-1;break;
			case 4: bit_x=bit_x+1; bit_y=bit_y+0;break;
			case 5: bit_x=bit_x+1; bit_y=bit_y+1;break;
			case 6: bit_x=bit_x+0; bit_y=bit_y+1;break;
			case 7: bit_x=bit_x-1; bit_y=bit_y+1;break;
			case 8: bit_x=bit_x-1; bit_y=bit_y+0;break;
			}
			document.getElementById("td_"+bit_y+"_"+bit_x).style.backgroundColor='Maroon';
		}
	}
}

function verify(bit_x,bit_y,bit_move) {
	switch(bit_move)
	{
		case 1: if ((bit_x==1)||(bit_y==1)) return false;break;
		case 2: if ((bit_y==1)) return false;break;
		case 3: if ((bit_x==10)||(bit_y==1)) return false;break;
		case 4: if ((bit_x==10)) return false;break;
		case 5: if ((bit_x==10)||(bit_y==10)) return false;break;
		case 6: if ((bit_y==10)) return false;break;
		case 7: if ((bit_x==1)||(bit_y==10)) return false;break;
		case 8: if ((bit_x==1)) return false;break;
	}
	return true;
}

function email(n1,n2,n3) {
	return n1+"@"+n2+"."+n3;
}

function addPopup(text,x,y) {
	var popup=window.createPopup()
	var popupBody=popup.document.body
	popupBody.style.border="solid 1px Maroon"
	popupBody.style.padding="1px"
	popupBody.style.fontFamily="Tahoma, Arial"
	popupBody.style.fontSize=10
	popupBody.style.color='Maroon'
	popupBody.innerHTML=text
	popup.show(x,y+15,150,15,document.body)
}

