
//          <!--   Copyright © 2001-2003 Peyknet Ltd   -->
//

var j=0;
var je=0;
var vorher;
document.onkeydown = tastd;
document.onkeyup = tastu;
var shiftO = 0 ;
var shiftU = 0;
var alt = 0 ;
var alt2 = 0 ;
var ctrl = 0 ;
var anf=19;
var el=82;
var virt = 6;
map = new Array(60);
key = new Array(60);
var warnung = 0 ;
var native = 0 ;
function amEnde(txt){
var nachher = window.document.teingabe.elements[el].value;
if(nachher.substr(0,nachher.length) != vorher )  return 0;
else  return 1;
}
function beseitige(txt){
var nachher = window.document.teingabe.elements[el].value;
var z=nachher.charAt(nachher.length);
var z2=(nachher.charAt(nachher.length-1)).charCodeAt(0) ;
je=0;
var zz=document.JML.toutf(vorher);
var cc=zz.charCodeAt(1)
if(nachher.substr(0,nachher.length-1) != vorher )  return true;
else {
        window.document.teingabe.elements[el].value ="";
        if((z2>1568 && z2<1611) || (z2>1648 && z2<1750)){
            einfuege(vorher.substr(0,vorher.length-1) +String.fromCharCode(1610) + txt);
        }
        else {
            einfuege(vorher.substr(0,vorher.length-1) +String.fromCharCode(1740) + txt);
        }
        if (window.document.teingabe.elements[el].all)
            window.document.teingabe.elements[el].scrollTop = window.document.teingabe.elements[el].scrollHeight;
       	var input = window.document.teingabe.elements[el];
        if (input.createTextRange) {
        var range = input.createTextRange();
            range.collapse(false);
            range.select();
        }

 }
}
function merke(textE1l) {

if(textE1l.name == "subject") {
	setv(90);
	if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) )
		native = 1;
}

if(textE1l.name == "frommail") {
	setv(91);
	if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) )
		native = 1;
}

if(textE1l.name == "tomail") {
	setv(92);
	if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) )
		native = 1;
}

if(textE1l.name == "frommail2"){
	 setv(1);
	if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) )
		native = 1;
}

if(textE1l.name == "Feld_1"){
	setv(82);
	native = 0;
}

if(textE1l.name == "name") {
setv(89);
	native = 0;
}

if(textE1l.name == "name2") {
 setv(0);
	native = 0;
}

if(textE1l.name == "googleH") setv(82);
if(textE1l.name == "altavistaH") setv(85);
if(textE1l.name == "yahooH") setv(87);




if (textE1l.createTextRange)
 textE1l.caretPos = document.selection.createRange().duplicate();
}
function einfuege(txt) {
var textEl = window.document.teingabe.elements[el];
var textVorher = window.document.teingabe.elements[el].value;

if(textEl.name == "tomail" || textEl.name == "frommail"){
    if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) ){
        native = 1;
        return false;
    }
}

window.document.teingabe.elements[el].focus();
if(virt == 0||virt == 6||virt == 9){
        var f=txt.charCodeAt(0);
        if (f==40) txt=String.fromCharCode(41);
        if (f==41) txt=String.fromCharCode(40);
        if (f==123) txt=String.fromCharCode(125);
        if (f==125) txt=String.fromCharCode(123);
        if (f==91) txt=String.fromCharCode(93);
        if (f==93) txt=String.fromCharCode(91);
        if (f==60) txt=String.fromCharCode(62);
        if (f==62) txt=String.fromCharCode(60);
        if (f==187) txt=String.fromCharCode(171);
        if (f==171) txt=String.fromCharCode(187);
}

if (textEl.createTextRange && textEl.caretPos) {
          var Pos = textEl.caretPos;
          Pos.text =  Pos.text.charAt(Pos.text.length - 1) == ' ' ?  txt + ' ' : txt;
     }
else{
     window.document.teingabe.elements[el].focus();
     merke(textEl);
     window.document.teingabe.elements[el].value  = txt;
    }

   if ( virt == 6 ){
          if( je == 1) beseitige(txt);
           if( (txt == String.fromCharCode(1609) || txt == String.fromCharCode(1610)) && je == 0){
               vorher = window.document.teingabe.elements[el].value;
               je = 1;
               }
    }

    var  textNachher = window.document.teingabe.elements[el].value;
    if (textNachher.substr(0,textNachher.length -1) ==  textVorher ){
    if (window.document.teingabe.elements[el].all)
        window.document.teingabe.elements[el].scrollTop = window.document.teingabe.elements[el].scrollHeight;
    }
}
function map2(ch){
       for ( i=0;i<map.length;i++){
           if( map[i] == ch )
              return (key[i]);
        }
}
function tastd(){
	var ii,nach;
//alert(navigator.appName);

	if( window.event.keyCode ==16 && shiftU == 0){
		shift1d(); shiftU=1;
	}

	ii= window.event.keyCode;

    if (ii == 17){
    if ( !( virt == 2 || virt == 3 || virt == 4 || virt == 5 || virt == 7 || virt == 9 || virt == 11 || virt == 14 || virt == 15 || virt == 16 ) ){
        ctrl =1;
        return true;
    }
    else return false;
    }
    if ( native == 1){
    	if (ii == 8)
		window.document.teingabe.elements[el].focus();
	//native = 0 ;
	return true;
     }
    if (ctrl == 1) return true;
	if (ii == 13) return true;
    if (ii == 33) return true;
    if (ii == 34) return true;
    if (ii == 35) return true;
    if (ii == 36) return true;
	if (ii == 37) return true;
	if (ii == 38) return true;
	if (ii == 39) return true;
	if (ii == 40) return true;
	if (ii == 45) return true;
	if (ii == 46) return true;
	if (ii == 9){
		z=String.fromCharCode(9);
		einfuege(z);
	}

	if (ii == 20) shift2();

	if( (window.event.keyCode ==17 || window.event.keyCode ==18) && alt2 == 0) {
		alt1d();
		alt2=1;
	}

	if (ii == 8){
		window.document.teingabe.elements[el].focus();
		return true;
	}

	nach = map2(ii);

	if ( virt == 6 ){
		if(nach == 1609) nach = 1610;
	}
	einfuege(String.fromCharCode(nach));
	return false;
}
function tastu(){
if( window.event.keyCode ==17 &&ctrl ==1)ctrl =0;
if( window.event.keyCode ==16 && shiftU == 1) {shift1u(); shiftU=0;}
if( alt2 == 1) {alt1u(); alt2=0;}
}
function ktrl(){
 alert("Ctrl hasn`t any function in this Program\n Please use the right mouse key\n Peyknet");
}
function alt1d()
{
 if( alt2 == 0){
                var obj = window.document.teingabe.elements[57 + anf];
                var obj2 = window.document.teingabe.elements[59 + anf];
                var obj3 = window.document.teingabe.elements[el];
                with(obj3.runtimeStyle){dir = 'ltr'; }
                with(obj.runtimeStyle){backgroundColor = '#DDDDDD'; }
                with(obj2.runtimeStyle){backgroundColor = '#DDDDDD'; }
                alt =alt==1?0:1;
                //auswahlo();
                auswahlv();
                alt2=1;
        }
}
function alt1u()
{
 if( alt2 == 1){
			var obj = window.document.teingabe.elements[57 + anf];
			with(obj.runtimeStyle){backgroundColor = '#BBBBBB'; }
			var obj2 = window.document.teingabe.elements[59 + anf];
			with(obj2.runtimeStyle){backgroundColor = '#BBBBBB'; }
			alt =alt==1?0:1;
			//auswahlo();
			auswahlv();
			alt2=0;
        }
}
function shift1d()
{
 if( shiftU == 0){
                var obj = window.document.teingabe.elements[42 + anf];
                var obj2 = window.document.teingabe.elements[54 + anf];
                with(obj.runtimeStyle){backgroundColor = '#DDDDDD'; }
                with(obj2.runtimeStyle){backgroundColor = '#DDDDDD'; }
                shiftO =shiftO==1?0:1;
                shiftUU=1;
                //auswahlo();
                auswahlv();
                shiftU=1;
                shiftUU=0;
        }
}
function shift1u(){
	if( shiftU == 1){
		var obj = window.document.teingabe.elements[42 + anf];
		with(obj.runtimeStyle){backgroundColor = '#BBBBBB'; }
		var obj2 = window.document.teingabe.elements[54 + anf];
		with(obj2.runtimeStyle){backgroundColor = '#BBBBBB'; }
		shiftO =shiftO==1?0:1;
		//auswahlo();
		auswahlv();
		shiftU=0;
	}
}
var shiftUU=0;
function shift2(){
var obj = window.document.teingabe.elements[28 + anf];
        if(shiftO==1){
			with(obj.runtimeStyle){backgroundColor = '#BBBBBB'; }
			shiftO = 0;
        }
        else{
			with(obj.runtimeStyle){backgroundColor = '#DDDDDD'; }
			shiftO = 1;
        }
        //auswahlo();
        auswahlv();
}
function del(){
        var vor = window.document.teingabe.elements[el].value;
        window.document.teingabe.elements[el].value = vor.substr(0,vor.length-1);
        einfuege(vor.substr(0,vor.length-1));
        window.document.teingabe.elements[el].focus();
}
function setlang(nr)
{
        virt = nr;
        var obj = window.document.teingabe.lang;
        for (var r = 0; r < obj.length; r++)
            if (obj[r].checked){
				obj[r].style.backgroundColor = 'blue';
				if ( virt == 0||virt == 6||virt == 9 )
				if (window.document.teingabe.Feld_1)
				if (window.document.teingabe.Feld_1.value=="")
					window.document.teingabe.Bricht.value ="r2l"
               }
            else
                obj[r].style.backgroundColor = '#0080C0';
        auswahlv();
}
function auswahlv(){
        if ( virt == 6 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.fagO().split(","));
                else if(shiftUU==1) init(document.JML.fagU().split(","));
                else if(alt == 1) init(document.JML.dd().split(","));
                else init(document.JML.fak().split(","));
        }
        else if ( virt == 3 ) {
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.engO().split(","));
                else if(shiftUU==1) init(document.JML.engU().split(","));
                else if(alt == 1) init(document.JML.dd().split(","));
                else init(document.JML.enk().split(","));
        }
        else if ( virt == 4 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.degO().split(","));
                else if(shiftUU==1) init(document.JML.degU().split(","));
                else if(alt == 1) init(document.JML.dea().split(","));
                else init(document.JML.dek().split(","));
        }
        else if ( virt == 7 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.frgO().split(","));
                else if(shiftUU==1) init(document.JML.frgU().split(","));
                else if(alt == 1) init(document.JML.fra().split(","));
                else init(document.JML.frk().split(","));
        }
        else if ( virt == 8 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.elgO().split(","));
                else if(shiftUU==1) init(document.JML.elgU().split(","));
                else if(alt == 1) init(document.JML.ela().split(","));
                else init(document.JML.elk().split(","));
        }
        else if ( virt == 0 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.argO().split(","));
                else if(shiftUU==1) init(document.JML.argU().split(","));
                else if(alt == 1) init(document.JML.dd().split(","));
                else init(document.JML.ark().split(","));
        }
        else if ( virt == 9 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.hegO().split(","));
                else if(shiftUU==1) init(document.JML.hegU().split(","));
                else if(alt == 1) init(document.JML.hea().split(","));
                else init(document.JML.hek().split(","));
        }
        else if ( virt == 11 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.itgO().split(","));
                else if(shiftUU==1) init(document.JML.itgU().split(","));
                else if(alt == 1) init(document.JML.ita().split(","));
                else init(document.JML.itk().split(","));
        }
        else if ( virt == 5 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.nlgO().split(","));
                else if(shiftUU==1) init(document.JML.nlgU().split(","));
                else if(alt == 1) init(document.JML.nla().split(","));
                else init(document.JML.nlk().split(","));
        }
        else if ( virt == 13 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.rugO().split(","));
                else if(shiftUU==1) init(document.JML.rugU().split(","));
                else if(alt == 1) init(document.JML.dd().split(","));
                else init(document.JML.ruk().split(","));
        }
        else if ( virt == 1 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.hygO().split(","));
                else if(shiftUU==1) init(document.JML.hygU().split(","));
                else if(alt == 1) init(document.JML.dd().split(","));
                else init(document.JML.hyk().split(","));
        }
        else if ( virt == 14 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.esgO().split(","));
                else if(shiftUU==1) init(document.JML.esgU().split(","));
                else if(alt == 1) init(document.JML.esa().split(","));
                else init(document.JML.esk().split(","));
        }
        else if ( virt == 15 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.svgO().split(","));
                else if(shiftUU==1) init(document.JML.svgU().split(","));
                else if(alt == 1) init(document.JML.sva().split(","));
                else init(document.JML.svk().split(","));
        }
        else if ( virt == 16 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.trgO().split(","));
                else if(shiftUU==1) init(document.JML.trgU().split(","));
                else if(alt == 1) init(document.JML.tra().split(","));
                else init(document.JML.trk().split(","));
        }
        else if ( virt == 10 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.higO().split(","));
                else if(shiftUU==1) init(document.JML.higU().split(","));
                else if(alt == 1) init(document.JML.hia().split(","));
                else init(document.JML.hik().split(","));
        }
        else if ( virt == 12 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.kygO().split(","));
                else if(shiftUU==1) init(document.JML.kygU().split(","));
                else if(alt == 1) init(document.JML.kya().split(","));
                else init(document.JML.kyk().split(","));
        }
        else if ( virt == 2 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.dagO().split(","));
                else if(shiftUU==1) init(document.JML.dagU().split(","));
                else if(alt == 1) init(document.JML.daa().split(","));
                else init(document.JML.dak().split(","));
        }
        else if ( virt == 17 ){
                if(shiftO == 1 && shiftU == 0 && shiftUU == 0) init(document.JML.csgO().split(","));
                else if(shiftUU==1) init(document.JML.csgU().split(","));
                else if(alt == 1) init(document.JML.csa().split(","));
                else init(document.JML.csk().split(","));
        }

        if(window.document.teingabe.elements[el].value  =="")
        if(virt == 0||virt == 6||virt == 9)r2l(); else l2r();
}
function kopy(u){
 for(i = 0;i< (u.length );i++)
       map[i] = u[i];
}
function auswahlo(){
        var or = document.teingabe.origin.selectedIndex;
        if ( or == 3 || or == 6|| or == 0 || virt == 17 || virt == 9 || virt == 5 || virt == 13 || virt == 12 || virt == 8)
                             kopy(document.JML.en().split(","));
        else if ( or == 4 )  kopy(document.JML.de().split(","));
        else if ( or == 7 )  kopy(document.JML.fr().split(","));
        else if ( or == 8 )  kopy(document.JML.el().split(","));
        else if ( or == 11 ) kopy(document.JML.it().split(","));
        else if ( or == 1 )  kopy(document.JML.hy().split(","));
        else if ( or == 14 ) kopy(document.JML.es().split(","));
        else if ( or == 15 ) kopy(document.JML.sv().split(","));
        else if ( or == 16 ) kopy(document.JML.tr().split(","));
        else if ( or == 10 ) kopy(document.JML.hi().split(","));
        else if ( or == 2 )  kopy(document.JML.da().split(","));
        else if ( or == 17 ) kopy(document.JML.cs().split(","));
}
function init(ff){
 for(i=0;i< ff.length ; i++)
        {
             window.document.teingabe.elements[i+ anf].value = String.fromCharCode(ff[i]);
             key[i] = ff[i];
        }
             window.document.teingabe.elements[13 + anf].value  = "BS";
             window.document.teingabe.elements[14 + anf].value = "Tab";
             window.document.teingabe.elements[27 + anf].value = "Enter";
             window.document.teingabe.elements[28 + anf].value = "Caps";
             window.document.teingabe.elements[41 + anf].value = "Enter";
             window.document.teingabe.elements[42 + anf].value = "Shift";
             window.document.teingabe.elements[54 + anf].value = "Shift";
             window.document.teingabe.elements[55 + anf].value = "Ctrl";
             window.document.teingabe.elements[57 + anf].value = "Alt";
             window.document.teingabe.elements[59 + anf].value = "Alt";
             window.document.teingabe.elements[62 + anf].value = "Ctrl";

}
function richtgl2r(){
var richt = document.teingabe.fontt.selectedIndex;
window.document.teingabe.elements[el].style.fontSize =richt*2+10 + 'px';
}
function selectState(){
}
function setv(vr){
 el=vr;
}
function fenster(){
        findKey();
        auswahlo();
        auswahlv();
//        einfuege("");
        //window.document.teingabe.elements[32].click();
        //window.document.teingabe.elements[60].click();
warnung = 0 ;
}
function findKey(){
var sysLang =  navigator.systemLanguage ;
sysLang = sysLang.substr(0,2);
var optionNr=0;
if( sysLang == "ar") optionNr = 0;
else if( sysLang == "am") optionNr = 1;
else if( sysLang == "da") optionNr = 2;
else if( sysLang == "en") optionNr = 3;
else if( sysLang == "de") optionNr = 4;
else if( sysLang == "nl") optionNr = 5;
else if( sysLang == "fa") optionNr = 6;
else if( sysLang == "fr") optionNr = 7;
else if( sysLang == "el") optionNr = 8;
else if( sysLang == "he") optionNr = 9;
else if( sysLang == "hi") optionNr = 10;
else if( sysLang == "it") optionNr = 11;
else if( sysLang == "sr") optionNr = 12;
else if( sysLang == "ru") optionNr = 13;
else if( sysLang == "es") optionNr = 14;
else if( sysLang == "sv") optionNr = 15;
else if( sysLang == "tr") optionNr = 16;
else if( sysLang == "cs") optionNr = 17;
else  optionNr = 3;
document.teingabe.origin.selectedIndex	= optionNr;
}
function kl(z){
  if ( z.charCodeAt(0) == 1609 )
     z=String.fromCharCode(1610);
  if ( z.charCodeAt(0) == 84 )
     z=String.fromCharCode(9);
  if ( z.charCodeAt(0) == 69 )
     z=String.fromCharCode(10);
einfuege(z);
}
function ctrljevor(){
 var txt = window.document.teingabe.elements[el].value;
}
function l2r(){ window.document.teingabe.elements[el].dir='ltr';}
function r2l(){ window.document.teingabe.elements[el].dir='rtl';}
function versteck(object){
document.getElementById(object).style.display == "none" ?
document.getElementById(object).style.display = "block":
document.getElementById(object).style.display = "none"  ;
}
function utf(){
var flag = true;
flag =mailktrl1(); if(flag == false)  return false;
flag =mailktrl2(); if(flag == false)  return false;
/*
window.document.teingabe.Btxt.value = document.JML.toutf(window.document.teingabe.elements[83].value);
window.document.teingabe.Bname.value = document.JML.toutf(window.document.teingabe.elements[89].value);
window.document.teingabe.Bsub.value = document.JML.toutf(window.document.teingabe.elements[90].value);
*/
 return true;
}
function mailktrl1(){
var ra_email =  /^(\s*[_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3}\s*)$/;
var tomail = document.teingabe.tomail.value;

 if ( ra_email.test(tomail) == false){
    alert("Ø¢Ø¯Ø±Ø³ Ú¯ÙŠØ±Ù†Ø¯Ù‡ Ø§Ø´ØªØ¨Ø§Ù‡ Ø§Ø³Øª \n r. email is wrong ");
    document.teingabe.tomail.focus();
    document.teingabe.tomail.select();
    return false;
   }
}
function mailktrl2(){
var ra_email =  /^(\s*[_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3}\s*)$/;
var frommail = document.teingabe.frommail.value;
   if ( ra_email.test(frommail) == false)  {
    alert("Ø¢Ø¯Ø±Ø³ ÙØ±Ø³ØªÙ†Ø¯Ù‡ Ø§Ø´ØªØ¨Ø§Ù‡ Ø§Ø³Øª \n s. email is wrong ");
    document.teingabe.frommail.focus();
    document.teingabe.frommail.select();
    return false;
   }
}