function RemoveArrayDuplicates(a) {
 tmpary = new Array();
 for(ii=0;ii<a.length;ii++){
  if(!DoesArrayContain(tmpary, a[ii])){
   tmpary.length+=1;
   tmpary[tmpary.length-1]=a[ii];
  }
 }
 return tmpary;
}
 
function DoesArrayContain(a, e) {
 for(iii=0;iii<a.length;iii++)if(a[iii]==e)return true;
 return false;
}

function mousetogrid(x3,y3)
{
var gy3=0,gx3=0;
	if ((x3 > 0) && (x3 < 40)){x3=1; gx3=1;}
	if ((x3 > 41) && (x3 < 80)){x3=41; gx3=2;}
	if ((x3 > 81) && (x3 < 120)){x3=81; gx3=3;}
	if ((x3 > 121) && (x3 < 160)){x3=121; gx3=4;}
	if ((x3 > 161) && (x3 < 200)){x3=161; gx3=5;}
	if ((x3 > 201) && (x3 < 240)){x3=201; gx3=6;}
	if ((x3 > 241) && (x3 < 280)){x3=241; gx3=7;}
	if ((x3 > 281) && (x3 < 320)){x3=281; gx3=8;}
	if ((x3 > 321) && (x3 < 360)){x3=321; gx3=9;}
	if ((x3 > 361) && (x3 < 400)){x3=361; gx3=10;}
	if ((x3 > 401) && (x3 < 440)){x3=401; gx3=11;}
	if ((x3 > 441) && (x3 < 480)){x3=441; gx3=12;}
	if ((x3 > 481) && (x3 < 520)){x3=481; gx3=13;}
	if ((x3 > 521) && (x3 < 560)){x3=521; gx3=14;}
	if ((x3 > 561) && (x3 < 600)){x3=561; gx3=15;}
	if ((x3 > 601) && (x3 < 640)){x3=601; gx3=16;}
	if ((x3 > 641) && (x3 < 680)){x3=641; gx3=17;}
	if ((x3 > 681) && (x3 < 720)){x3=681; gx3=18;}
	if ((x3 > 721) && (x3 < 760)){x3=721; gx3=19;}
	if ((x3 > 761) && (x3 < 800)){x3=761; gx3=20;}
	if ((x3 > 801) && (x3 < 840)){x3=801; gx3=21;}
	if ((x3 > 841) && (x3 < 880)){x3=841; gx3=22;}
	if ((x3 > 881) && (x3 < 920)){x3=881; gx3=23;}
	if ((x3 > 921) && (x3 < 960)){x3=921; gx3=24;}
	if ((x3 > 961) && (x3 < 1000)){x3=961; gx3=25;}
	if ((x3 > 1001) && (x3 < 1040)){x3=1001; gx3=26;}
	if ((x3 > 1041) && (x3 < 1080)){x3=1041; gx3=27;}
	if ((x3 > 1081) && (x3 < 1120)){x3=1081; gx3=28;}
	if ((x3 > 1121) && (x3 < 1160)){x3=1121; gx3=29;}
	if ((x3 > 1161) && (x3 < 1200)){x3=1161; gx3=30;}
	if ((y3 > 0) && (y3 < 40)){y3=1; gy3=1;}
	if ((y3 > 41) && (y3 < 80)){y3=41; gy3=2;}
	if ((y3 > 81) && (y3 < 120)){y3=81; gy3=3;}
	if ((y3 > 121) && (y3 < 160)){y3=121; gy3=4;}
	if ((y3 > 161) && (y3 < 200)){y3=161; gy3=5;}
	if ((y3 > 201) && (y3 < 240)){y3=201; gy3=6;}
	if ((y3 > 241) && (y3 < 280)){y3=241; gy3=7;}
	if ((y3 > 281) && (y3 < 320)){y3=281; gy3=8;}
	if ((y3 > 321) && (y3 < 360)){y3=321; gy3=9;}
	if ((y3 > 361) && (y3 < 400)){y3=361; gy3=10;}
	if ((y3 > 401) && (y3 < 440)){y3=401; gy3=11;}
	if ((y3 > 441) && (y3 < 480)){y3=441; gy3=12;}
	if ((y3 > 481) && (y3 < 520)){y3=481; gy3=13;}
	if ((y3 > 521) && (y3 < 560)){y3=521; gy3=14;}
	if ((y3 > 561) && (y3 < 600)){y3=561; gy3=15;}
	if ((y3 > 601) && (y3 < 640)){y3=601; gy3=16;}
	if ((y3 > 641) && (y3 < 680)){y3=641; gy3=17;}
	if ((y3 > 681) && (y3 < 720)){y3=681; gy3=18;}
	if ((y3 > 721) && (y3 < 760)){y3=721; gy3=19;}
	if ((y3 > 761) && (y3 < 800)){y3=761; gy3=20;}
	if ((y3 > 801) && (y3 < 840)){y3=801; gy3=21;}
	if ((y3 > 841) && (y3 < 880)){y3=841; gy3=22;}
	if ((y3 > 881) && (y3 < 920)){y3=881; gy3=23;}
	if ((y3 > 921) && (y3 < 960)){y3=921; gy3=24;}
	if ((y3 > 961) && (y3 < 1000)){y3=961; gy3=25;}
	if ((y3 > 1001) && (y3 < 1040)){y3=1001; gy3=26;}
	if ((y3 > 1041) && (y3 < 1080)){y3=1041; gy3=27;}
	if ((y3 > 1081) && (y3 < 1120)){y3=1081; gy3=28;}
	if ((y3 > 1121) && (y3 < 1160)){y3=1121; gy3=29;}
	if ((y3 > 1161) && (y3 < 1200)){y3=1161; gy3=30;}
	return [x3,y3,gx3,gy3];
}


function EraseTxt()
{
var eraseListTxtId="", Erasetxt1="", parent, child;
			
			ClearDiv ("eraseListDiv");
			
			for (i = 0; i < arytxt.length; i++) {
				if (arytxt[i].length > 6)
				{
					if (arytxt[i].substring(0,5) != "0er0s")
					{
					fnVal=textstrProps(arytxt[i]);
					Erasetxt1=fnVal[0];
					Erasetxt1=Erasetxt1.replace(/b0r8/g, " ");
					eraseListTxtId="eraseListTxtId" + i;
					addToEraseList(Erasetxt1 ,eraseListTxtId, i);
					}
				}
			}
			
//addEvent(document.getElementById('all'), 'click', setCheckboxes);

	//alert ("showed list");
	monitorEraseList = 'y';
}

//erase2
function addToEraseList(theEraseTxt, eraseListTxtId, indi)
{
    var eraseListDivh = document.getElementById('eraseListDiv');

    var eraseListDiv = document.createElement('input');
    eraseListDiv.type = 'checkbox';
    eraseListDivh.appendChild(eraseListDiv);
    eraseListDiv.id = eraseListTxtId;
	eraseListDiv.value = theEraseTxt;
    var newtext = eraseListDivh.appendChild(document.createTextNode(theEraseTxt));
	newtext.id = eraseListTxtId + "txt";
	
	var o2 = document.getElementById("eraseListDivDoButton").style;
	o2.position = "absolute"; 
	o2.top = 200;
	o2.left = 1200;
	o2.zIndex = 999;
	o2.width = 900;
	o2.height = 40;
	o2.padding = 4;
	o2.background="#DEBA4F";
	o2.visibility = "visible";
	var o = document.getElementById("eraseListDiv").style;
	o.position = "absolute"; 
	o.visibility = "visible";
	o.background="#9E7E20";
	o.color = "FFFFFF";
	o.zIndex = 999;
	o.width = 908;
	o.height = 1200;
	o.top = 230;
	o.left = o2.left;
}

function eraseListSelected ()
{
	var ind=0;
	var txtno="", txt="";
	var collection = document.getElementById("eraseListDiv").getElementsByTagName('INPUT');
    for (i=0; i<collection.length; i++) {
        if ((collection[i].type.toUpperCase()=='CHECKBOX') && (collection[i].checked == true))
		{
			txt=collection[i].id;
			txt=txt.replace(/eraseListTxtId/g, "");
			txt=txt.replace(/txt/g, "");
			txtno = txt * 1;
			arytxt[txtno]="0er0s" + arytxt[txtno];
			t5="txtno" + txtno;
			drawtextstrStyle(t5,arytxt[txtno],0,0);
		}
    }
	HideEraseList ();
}

function eraseListCanc ()
{
HideEraseList ();
}

function ClearDiv (theDiv)
{
	var parent = document.getElementById(theDiv);

	if ( parent.hasChildNodes() )
		{
			while ( parent.childNodes.length >= 1 )
				{
					parent.removeChild( parent.firstChild );       
				} 
		}
}

function HideDiv (theDiv)
{
	var o = document.getElementById(theDiv).style;
	o.position = "absolute"; 
	o.visibility = "hidden";
	o.zIndex = 1;
	o.width = 1;
	o.height = 1;
	o.top = 2000;
	o.left = 2000;
}

function HideEraseList ()
{
monitorEraseList == 'n'
ClearDiv ("eraseListDiv");
HideDiv ("eraseListDiv");
HideDiv ("eraseListDivDoButton");
}
