function getCode(eid) {
	code = eid.substr(2,eid.length-2);
	if (isNaN(code)) return code.substr(0,2); // Diffusion code
	else return code; //Regular geographic location
}

function getType(eid) { return eid.substr(0,2); }

function getChildsType(type) {
	if (type == 're') return 'co';
	else return 'pr';
}

function getChildCount(eid) {
	typeT = getType(eid);
	codeT = getCode(eid);
	if (typeT == 'co') {
		for (i = 0; i < cnts.length; i++)
			if (cnts[i][1] == codeT) return cnts[i][4];
	}
	else if (typeT == 're') return rgs[codeT][1];
}

function name(eid) {
	typeT = getType(eid);
	codeT = getCode(eid);
	if (typeT == 'co') {
		for (i = 0; i < cnts.length; i++)
			if (cnts[i][1] == codeT) return cnts[i][2];
	}
	else if (typeT == 're') return rgs[codeT][0];

	else {
		for (i = 0; i < provs.length; i++)
			if (provs[i][1] == codeT) return cnts[i][2];
	}
}

function parentID(eid) {
	code = getCode(eid);
	type = getType(eid);
	if ((type == 'pr') && isNaN(code)) return eid.substr(4,eid.length-4); //Diffusion code (National)
	else if (type == 'co') vec = cnts; //Country
	else vec = provs; // Regular province

	for (i = 0; i < vec.length; i++)
		if (vec[i][1] == code) return vec[i][0];
}
	