﻿function $(id) { return document.getElementById(id); }
var input=$("area");
var Eמ2Heb=0;



function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}



function typeText(item){
	
	var input=$("area");
	var lt=item.length;
	
		
	
	input.focus();
	if (input.setSelectionRange) {
         var srt = input.selectionStart;
         var len = input.selectionEnd;
        if (srt < len) srt++;
         input.value = input.value.substr(0, srt) + item + 
		 input.value.substr(len);
         input.setSelectionRange(srt+lt , srt+lt);
		 input.focus();
	}
	else{
	var range=document.selection.createRange();
	range.text=item;}
	input.focus();
	input.scrollTop = input.scrollHeight;	
	
	

	
	}
	
	function cktype(item){
		
	if(item==" ") item="&nbsp;";
		   editor.insertHtml(item);    
	
	
	}


function typeLetter(item){
		
		item=String.fromCharCode(item);
		
		
	if(	isdefined('CKEDITOR') )  
		cktype(item)
	else
		typeText(item);	
	
return;
	
}



	
function ajaxpost(op){
		var input = $("area").value;
		var para = 'text=' + encodeURIComponent(input);
		var http = null;
		if (window.XMLHttpRequest) {
		http = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
		http = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (http != null) {
		http.open("POST", "save.php", true);
		http.setRequestHeader(
		"Content-Type",
		"application/x-www-form-urlencoded");
		http.send(para);
		}
		
}

function openYoutube() {
	var input=$("area").value;
	var encode = encodeURI(input);
	MeinFenster = window.open("http://www.youtube.com/results?search_type=&search_query="+encode);
  }
function openGoogle() {
	var input=$("area").value;
	var encode = encodeURI(input);
	MeinFenster = window.open("search/?cx=partner-pub-4113742750586426:uf790y-bx62&cof=FORID%3A10&ie=UTF-8&q="+encode);
 }

function btnBackspace() 
	{    
		var target = $("area");
		target.focus();
		//gecko
        if (target.setSelectionRange) {
         var srt = target.selectionStart;
         var len = target.selectionEnd;
        if (srt < len) srt++;
         target.value = target.value.substr(0, srt - 1) + 
		 target.value.substr(len);
         target.setSelectionRange(srt - 1, srt - 1);
		 target.focus();
        } else 
		// Ex
		if (target.createTextRange) {
		 self.VKI_range = document.selection.createRange();
         try { self.VKI_range.select(); } 
		catch(e) {}
		  self.VKI_range = document.selection.createRange();
          if (!self.VKI_range.text.length) 
		  self.VKI_range.moveStart('character', -1);
          self.VKI_range.text = "";
		  target.focus();
          }	
		else target.value = target.value.substr(0, target.value.length - 1);
		     target.focus();
	
}

function FontSize(n) {
   var p = $("area");
      if(p.style.fontSize) {
         var s = parseInt(p.style.fontSize.replace("px",""));
      } else {
         var s = 24;
      }
      s=s-n;
      p.style.fontSize = s+"px";
      $("font-display").style.display ='block';	
      $("font-display").innerHTML=s;
	  window.setTimeout(function()
	  {$("font-display").style.display ='none';},4000);		
      $("area").focus();

}
	
		

var ok=0;
function umw(){
if(ok==0){
$("actif").style.background ='url(theme/actif.png) 0px -51px';
$("off").firstChild.nodeValue ='(on)';
ok=1;

}
else if(ok==1){	
$("actif").style.background ='url(theme/actif.png) 0px 0px';
$("off").firstChild.nodeValue ='(off)';
ok=0;
}
}

var heb2eng=new Array('a','א', 
'A','ע',
'b','ב',
'c','ס',
'd','ד',
'e','י',
'f','פ',
'g','ג',
'h','ח',
'H','כ',
'i','י',
'j','ג',
'K','ק',
'k','כ',
'כ ','ך',
'l','ל',
'm','מ',
'מ ','ם ',
'n','נ',
'נ ','ן ',
'o','ו',
'p','פ',
'פ ','ף ', 
'q','ק', 
'r','ר',
's','ס',	'S','ש',	'תt','ט',	't','ת', 'תz','צ', 	
'u','ו', 
'v','ה', 
'w','ש',
'x','אקס',
'y','י',
'z','ז');
function printTable(delimiter){
	var text="<ul>";
	for(i=0;i<heb2eng.length;i=i+2){
		text+="\t<li><strong>"+heb2eng[i]+"</strong>"+delimiter+heb2eng[i+1]+"</li>";
		
	}
	text+="</ul>";
	
	return text;
}

function Ersetzung(){
	
	//this.value=toHebrew(this.value);
	Eמ2Heb=1;
	if(ok==1){
    br=$("area").value;
	for(i=0;i<heb2eng.length;i=i+2){
		br=br.replace(RegExp(heb2eng[i],"g"),heb2eng[i+1]);
	
	}
	
		
	var obj=$("area");
	obj.scrollTop=obj.scrollHeight;
	$("area").value=br;
	}
}	

