/** ET-TelConvert-1998 (for personal and non-profit use) (c) Copyright 2005, Dr. Bedilu Habte. bediluh@telecom.net.et All rights reserved. Permission is granted to use this software in personal and non-profit applications ONLY, subject to the following restrictions: The origin of this software must not be misrepresented. If you use this software in a product, an acknowledgment in the product is required. The copyright notice must not be modified or removed from any of the source code. YOU MAY MODIFY OR REDISTRIBUTE THE SOFTWARE. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT OR INDIRECT DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE. For commercial use please contact: bediluh@telecom.net.et JavaScript code remain the intellectual property of Dr. Bedilu Habte. (c) Copyright 2005. All rights reserved. */ // variable for old and new telephon numbers var oldTel, newTel; // variable for the number of digits in the old telephon // (length of 2, 3, 6 or 7 are possible) var digs = 0; // variable for old and new area codes var oldCode, newCode; // variable for number to be added in front var add; // message as a final output var msg; /** Addis Ababa Normal Fixed Line Numbers */ // North Addis var AAf1 = new Array(11,12,14,22,23,24,25,27,31,35,55,56,57,58,87,88); // West Addis var AAf2 = new Array(13,36,37,38,59,70,75,76,77,78,79,83,84); // South West Addis var AAf3 = new Array(20,21,30,41,48,49,71,72,73,74); // South Addis var AAf4 = new Array(16,19,32,33,34,39,40,42,43,65,66,67,68); // Central Addis var AAf5 = new Array(15,17,44,50,51,52,53,54); // East Addis var AAf6 = new Array(18,26,29,45,46,47,60,61,62,63,80,81,85); // All normal fixed var AAfall = new Array(AAf1,AAf2,AAf3,AAf4,AAf5,AAf6); // array of starting of special old numbers in Addis AASold = new Array(315,316,318,883,599,820,835,825,306,308,380,389,415,387,640,648,865,860,875); // array of starting of special new numbers in Addis ( to be changed to) AASnew = new Array(1320,1330,1340,1860,2580,2820,2850,2860,3310,3320,3380,3390,3420,3870,6640,6650,6860,6870,6880); /** Mobile Numbers */ // group 1 add in front "1" var AAm1 = new Array(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, 40,41,42,43,44,45,46,47,48,49,50,60,61,62,63,64,65,66,67,68,69, 84,86,87,88,89); // group 2 add in front "4" var AAm2 = new Array(30,31,70,71,72); // group 3 add in front "5" var AAm3 = new Array(32,33,73,74,75); // group 4 add in front "6" var AAm4 = new Array(58,82,83); // group 5 add in front "7" var AAm5 = new Array(55,57,80,81); // group 6 add in front "8" var AAm6 = new Array(34,35,76,77); // All normal fixed var AAmall = new Array(AAm1,AAm2,AAm3,AAm4,AAm5,AAm6); // Array of special (service) numbers var service = new Array(97,98,99,900,901,902,903,904,905,906,907,908, 911,912,913,915,916,918,919,929, 950,951,952,953,954,955,956,957,958, 959,960,961,962,963,964,965,966,967,969); // check whether numbers are typed and // length is 2, 3, 6 or 7 function checkNum(input) { var onlyThese ="0123456789"; digs = input.length; if(digs != 2 && digs != 3 && digs != 6 && digs != 7) return false; for (var i = 0; i < digs.length; i++) if (onlyThese.indexOf(input.charAt(i)) < 0 ) return false; return true; } // Addis and environs function convertTelephon(code, number){ oldCode = code; oldTel = number; newTel = ""; msg = "Please check your input, and try again.
";
// first check numbers are input
if(checkNum(oldTel)){
// first call function to convert the area code
convertCode(code);
//if(digs == 2 || digs == 3) convertService(oldTel);
if(code == "01"){ // for fixed normal/chordless lines (code = 01)
if (digs == 7) convertWireless(oldTel);
else if(digs == 6) convertAddis(oldTel);
else if(digs == 2 || digs == 3) convertService(oldTel);
} else if(code == "09"){ // for mobile or handy (code = 09)
if(digs == 6) convertMobile(oldTel);
} else if(code == "091"){ // for VSAT Service
if(digs == 6) convertVsat(oldTel);
} else { // for regional fixed telephone numbers (code 02 - 08)
if(digs == 6) convertRegional(oldTel);
else if(digs == 2 || digs == 3) convertService(oldTel);
}
// output converted value
if (newTel != "") outMsg();
else outErr(msg);
} else {
outErr(msg);
}
}
// to convert area codes
function convertCode(c){
newCode = "";
switch(c) {
case "01":
newCode = "11";
break;
case "02":
newCode = "22";
break;
case "03":
newCode = "33";
break;
case "04":
newCode = "34";
break;
case "05":
newCode = "25";
break;
case "06":
newCode = "46";
break;
case "071": // this region has two cases!!
newCode = "47";
oldCode = "7";
break;
case "072":
newCode = "57";
oldCode = "7";
break;
case "08":
newCode = "58";
break;
case "09":
newCode = "91";
break;
case "091":
newCode = "98";
break;
}
}
// to convert telephone numbers in Addis Ababa and Environs
function convertAddis(n){
newTel = "";
// get the first two digits from the telephon number
var first2 = n.substring(0,2);
// get the first three digits from the telephon number
var first3 = n.substring(0,3);
// check for special numbers with irregular change
for(i=0;i ";
parent.frames[1].document.write(msg);
}
" );
var eutoeth = ("To call from Europe (U.K., France, Germany, etc): (00) 251 " + newCode + " " + newTel + "
" );
var kenyatoeth = ("To call from Nairobi, Kenya: (000) 251 " + newCode + " " + newTel + "
" );
msg = (prev.small()).strike() + " " + curr + "
" + "" + ustoeth + "
" + eutoeth + "
" + kenyatoeth + "" + "