﻿// Replaces all instances of the given substring.
String.prototype.replaceAll = function(
			strTarget, // The substring you want to replace
			strSubString // The string you want to replace in.
		) {
	var strText = this;
	var intIndexOfMatch = strText.indexOf(strTarget);

	// Keep looping while an instance of the target string
	// still exists in the string.
	while (intIndexOfMatch != -1) {
		// Relace out the current instance.
		strText = strText.replace(strTarget, strSubString)

		// Get the index of any next matching substring.
		intIndexOfMatch = strText.indexOf(strTarget);
	}

	// Return the updated string with ALL the target strings
	// replaced out with the new substring.
	return (strText);
}

function Make64StringFrom144String(pos) {
	var strPos64 = "";

	for (var i = 26; i < 118; i++) 
	{
		var c = pos.substring(i, i + 1);
		if (c != '_') {
			{
				strPos64 += String.fromCharCode(c.charCodeAt(0));
			}
		}
	}
	
	return strPos64;
}

function Make144StringFrom64String(pos) {
	var strPos144 = "__________________________";

	for (var i = 0; i < 64; i++) 
	{
		strPos144 += pos.substring(i, i + 1);

		if ((i + 1) % 8 == 0) {
			strPos144 += "____";
		}
	}

	strPos144 += "______________________";

	return strPos144;
}
