// JavaScript Document
function createSquareArray(x,y){
	var ar = Array();
	for (i=0;i<x;i++){
		ar[i] = Array();
		ar[i].length = y;
	}
	return ar;
}
function createTable(a,ar){
	//size 
	var nbrRow = ar.length;
	var nbrCol = ar[0].length;
	//container 
	var container = document.getElementById(a);
	//div between container and the table to set attributes
	var el = document.createElement("div");
	//because creatElement("table") doesn't work with ie
	var myTableHtml = "";
	myTableHtml +='<table border="0" padding="0" spacing="0">';
	//create the table html code
	for(i = 0;i<nbrRow;i++){
		myTableHtml += "<tr>";
		for(j=0;j<nbrCol;j++){
			myTableHtml += "<td>";
			if (ar[i][j]){
				myTableHtml += ar[i][j];
			}else{
				myTableHtml += "&nbsp;";
			}
			myTableHtml += "</td>";
		}
		myTableHtml += "</tr>";
	}
	myTableHtml += "</table>";
	//attach the table to the div and the div to the container
	el.innerHTML = myTableHtml;
	container.appendChild(el);
	return el.childNodes[0];
}

function removeLastElement(a){
	var container = document.getElementById(a);
	if (!container.hasChildNodes){
		return;
	}else{
		container.removeChild(container.lastChild);
	}
}
function removeElementId(cid){
		aNode = document.getElementById(cid);
		aNode.parentNode.removeChild(aNode);
}

