function hebforchar(mystr)
{
	strret = "";
	//alert(mystr);
	for(hebx = 0; hebx < mystr.length ; hebx++){
		addin = "";
		doblank = 0;
		//alert(hebx);
		switch(mystr.substr(hebx,1)){
			case "a":
				addin = "alef";
				break;
			case "b":
				addin = "bet";
				break;	
			case "g":
				addin = "gimmel";
				break;	
			case "d":
				addin = "dalet";
				break;	
			case "h":
				addin = "hey";
				break;	
			case "v":
				addin = "vav";
				break;	
			case "z":
				addin = "zayin";
				break;	
			case "c":
				addin = "ches";
				break;	
			case "e":
				addin = "tes";
				break;	
			case "y":
				addin = "yud";
				break;	
			case "k":
				addin = "chaf";
				break;	
			case "K":
				addin = "fchaf";
				break;	
			case "l":
				addin = "lamed";
				break;	
			case "m":
				addin = "mem";
				break;	
			case "M":
				addin = "fmem";
				break;	
			case "n":
				addin = "nun";
				break;	
			case "N":
				addin = "fnun";
				break;	
			case "s":
				addin = "samech";
				break;	
			case "i":
				addin = "ayin";
				break;	
			case "p":
				addin = "pey";
				break;	
			case "P":
				addin = "fpey";
				break;	
			case "x":
				addin = "tzaddi";
				break;	
			case "X":
				addin = "ftzaddi";
				break;	
			case "q":
				addin = "koof";
				break;	
			case "r":
				addin = "reish";
				break;	
			case "w":
				addin = "shin";
				break;	
			case "t":
				addin = "tav";
				break;
			case '"':
				addin = "deelee";
				break;
			case "'":
				addin = "singdeelee";
				break;
			case " ":
				doblank = 1;
				addin = "<img src='/images/blank.gif' height=1 width=10 border=0>";
				break;
			case "'":
				doblank = 1;
				addin = "'";
				break;
		};
		if (doblank){
		strret = addin + strret
		} else {
		strret = "<img src='/letters/" + addin + ".gif' align=absmiddle border=0>" + strret;
		};
	};
	//alert(strret);
	return strret;
}

function numtohebchar(mynum, doyear)
{
	rspstr = "";
	x = Number(mynum);
	if(doyear == 1){
		if(x >= 1000){
			x = x % 1000;
		};
	} else {
		if(x >= 1000){
			rspstr = "''" + numtohebchar(Math.floor(x / 1000));
		};
	};
	if(x >= 400){
		amttavs = Math.floor(x / 400);
		x =  x % 400;
		for(y = 0; y < amttavs; y++){
			rspstr = hebforchar("t") + rspstr;
		};
	};
	if(x >= 300){
		x =  x % 300;
		rspstr = hebforchar("w") + rspstr;
	};
	if(x >= 200){
		x =  x % 200;
		rspstr = hebforchar("r") + rspstr;
	};
	if(x >= 100){
		x =  x % 100;
		rspstr = hebforchar("q") + rspstr;
	};
	if(x >= 90){
		x =  x % 90;
		rspstr = hebforchar("x") + rspstr;
	};
	if(x >= 80){
		x =  x % 80;
		rspstr = hebforchar("p") + rspstr;
	};
	if(x >= 70){
		x =  x % 70;
		rspstr = hebforchar("i") + rspstr;
	};
	if(x >= 60){
		x =  x % 60;
		rspstr = hebforchar("s") + rspstr;
	};
	if(x >= 50){
		x =  x % 50;
		rspstr = hebforchar("n") + rspstr;
	};
	if(x >= 40){
		x =  x % 40;
		rspstr = hebforchar("m") + rspstr;
	};
	if(x >= 30){
		x =  x % 30;
		rspstr = hebforchar("l") + rspstr;
	};
	if(x >= 20){
		x =  x % 20;
		rspstr = hebforchar("k") + rspstr;
	};
	if(x >= 10){
		if( x == 15 || x == 16){
			x = x % 9;
			rspstr = hebforchar("e") + rspstr;
		} else {
			x =  x % 10;
			rspstr = hebforchar("y") + rspstr;
		};
	};
	if (doyear == 1){
		rspstr = hebforchar('"') + rspstr;
	};
	if(x >= 9){
		x =  x % 9;
		rspstr = hebforchar("e") + rspstr;
	};
	if(x >= 8){
		x =  x % 8;
		rspstr = hebforchar("c") + rspstr;
	};
	if(x >= 7){
		x =  x % 7;
		rspstr = hebforchar("z") + rspstr;
	};
	if(x >= 6){
		x =  x % 6;
		rspstr = hebforchar("v") + rspstr;
	};
	if(x >= 5){
		x =  x % 5;
		rspstr = hebforchar("h") + rspstr;
	};
	if(x >= 4){
		x =  x % 4;
		rspstr = hebforchar("d") + rspstr;
	};
	if(x >= 3){
		x =  x % 3;
		rspstr = hebforchar("g") + rspstr;
	};
	if(x >= 2){
		x =  x % 2;
		rspstr = hebforchar("b") + rspstr;
	};
	if(x >= 1){
		x =  x % 1;
		rspstr = hebforchar("a") + rspstr;
	};
	if(doyear != 1 ){
		whereinsert = rspstr.indexOf("><");
		if(whereinsert != -1){
			whereinsert += 1;
			firstone = rspstr.substring(0,whereinsert);
			secondone = rspstr.substring(whereinsert,rspstr.length);
			rspstr = firstone + hebforchar('"') + secondone;
		}else{
			rspstr = hebforchar("'") + rspstr;
		};
	};
	//alert(rspstr);
	return rspstr;
}

