/*Copyright Gim.co.il*/

function xdig (C) {
 C = C.toUpperCase();
	switch (C)
	 {
	case "A":
    case "B":
    case "C":
    case "D":
    case "E":
    case "F":
    case "G":
    case "H":
    case "I":
    case "K":
    case "L":
    case "M":
    case "N":
    case "O":
    case "P":
	
 
     return (String.fromCharCode((C.charCodeAt(0)+1)/3+28));
     break;
		case "R":
		case "S":
		case "T":
		case "U":
		case "V":
		case "W":
		case "X":
		case "Y":
		case "Q": 
			return (String.fromCharCode((C.charCodeAt(0))/3+28));
			break;
		case "Z":
			return "7";
		default:
			return C;
	}   
			
}

function Mid(str, start, len)
{

    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}

function PhoneLettersToDigits(phonen) {
				var i=0;
				var mida;
				var digg;
				var result="";
				
					for (i=0;i<=phonen.length;i++){
						mida = Mid(phonen,i,1);
						digg = xdig(mida);
						result += digg;
					}
return result;
	}
	
function compute(form){
var phonenum = form.phonenum.value;
var res;
		res = PhoneLettersToDigits(phonenum);
		form.res.value = res;

		
}
		
	
