/*
// ####################################################################################################
// # Datei js/vkeyboard.js 1.0  (bluepageCMS V2.5.8.)
// ####################################################################################################
// # Copyright © 2009 ISS-Oberlausitz
// # Author: T.Hojenski
// # Email: info@iss-ol.de
// # URL:   http://www.iss-ol.de
// # Diese Datei gehört zu dem kommerziellen BLUEPAGE - CMS der ISS-Oberlausitz
// # Bitte beachten Sie die Lizenzbedingungen.
// # Unberechtigte Nutzung, Änderung oder Weitergabe über die Lizenzbedingungen hinaus
// # sind strafbar.
// # Eine unberechtigte Verwendung auch von Teilen des CMS-Systems kann zu Schadens-
// # und/oder Unterlassungsansprüchen führen.
// # Das Entfernen der Copyrighthinweise ist untersagt.
// # Weitere Informationen unter http://www.bluepage-cms.com.
// ####################################################################################################
*/        
 var frmlinput = '' 
 var frmlopener = '' 
var charsL = ["ˇacc","1","2","3","4","5","6","7","8","9","0","ß","´acc","BackSp","||","Tab","q","w","e","r","t","z","u","i","o","p","ü","+","Enter","||","Caps","a","s","d","f","g","h","j","k","l","ö","ä","ł","||","Shift","<","y","x","c","v","b","n","m",",",".","-","Shift","||","Control","Alt","Space","AltGr","Control"];
var charsH = ["°acc","!","\"","§","$","%","&","/","(",")","=","?","`acc","BackSp","||","Tab","Q","W","E","R","T","Z","U","I","O","P","Ü","*","Enter","||","Caps2","A","S","D","F","G","H","J","K","L","Ö","Ä","Ł","||","Shift",">","Y","X","C","V","B","N","M",";",":","_","Shift","||","Control","Alt","Space","AltGr","Control"];
var charsA = ["ˇ","»","«","„","‚","'","\"","{","[","]","}","ß","´","BackSp","||","Tab","@","","€","","","","","","","","","~","Enter","||","Caps","","","","","","","","","","","","'","||","Shift","|","","","","","","","µ","","","","Shift","||","Control","Alt","Space","AltGr","Control"];
var charsAH = ["","","²","³","","","","{","[","]","}","\\","","BackSp","||","Tab","@","","€","","","","","","","","","~","Enter","||","Caps","","","","","","","","","","","","#","||","Shift","|","","","","","","","µ","","","","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars1 = ["ˇ","1","2","3","4","5","6","7","8","9","0","ß","´acc","BackSp","||","Tab","","","ĕ","ř","ť","ž","","","","","","+","Enter","||","Caps","","š","ď","","","","","","ľ","","","","||","Shift","<","","","č","","","ň","",",",".","-","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars1H = ["ˇ","!","\"","§","$","%","&","/","(",")","=","?","`acc","BackSp","||","Tab","","","Ĕ","Ř","Ť","Ž","","","","","","*","Enter","||","Caps","","Š","Ď","","","","","","Ľ","","","","||","Shift",">","","","Č","","","Ň","",";",":","_","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars2  = ["°","1","2","3","4","5","6","7","8","9","0","ß","´acc","BackSp","||","Tab","","","ė","","","ż","ů","","","","","+","Enter","||","Caps","","","ſ","","","","","","","","","","||","Shift","","","","","","","","",",",".","-","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars2H  = ["°","!","\"","§","$","%","&","/","(",")","=","?","`acc","BackSp","||","Tab","","","Ė","","","Ż","Ů","","","","","*","Enter","||","Caps","","","","","","","","","","","","","||","Shift","","","","","","","","","","","","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars3 = ["^acc","1","2","3","4","5","6","7","8","9","0","ß","´","BackSp","||","Tab","","","é","ŕ","","ź","ú","í","ó","","","+","Enter","||","Caps","á","ś","đ","","","","","","ĺ","","","","||","Shift","<","ý","","ć","","","ń","",",",".","-","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars3H = ["°acc","!","\"","§","$","%","&","/","(",")","=","?","`acc","BackSp","||","Tab","","","É","Ŕ","","Ź","Ú","Í","Ó","","","*","Enter","||","Caps","Á","Ś","Đ","","","","","","Ĺ","","","","||","Shift",">","Ý","","Ć","","","Ń","",";",":","_","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars4 = ["^acc","1","2","3","4","5","6","7","8","9","0","ß","`","BackSp","||","Tab","","","","ę","","","","","","","","","Enter","||","Caps","ą","ş","","","","","","","","","","","||","Shift","<","","","ç","","","","",",",".","-","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars4H = ["^","!","\"","§","$","%","&","/","(",")","=","?","`","BackSp","||","Tab","","","","Ę","","","","","","","","","Enter","||","Caps","Ą","Ş","","","","","","","","","","","||","Shift",">","","","Ç","","","","","","","","Shift","||","Control","Alt","Space","AltGr","Control"];
var chars5  = ""
var chars5H = ""

 var selCharsSet = charsL;
 var selCaps = 0;
 var CapsClass = 'Caps';
 var selAltGr = 0;
 var selShift = 0;
 var AltGrClass = 'AltGr';

 function changeCarSet(charSet) {
    if (charSet) {
       if (selCharsSet == charSet) selCharsSet = charsL; else selCharsSet = charSet;
       if(charSet == charsH) CapsClass = 'Caps2';   else CapsClass = 'Caps'; 
       if(charSet == charsA) AltGrClass = 'AltGr2'; else AltGrClass = 'AltGr'; 
    } else {
       if (selCharsSet == charsL) { selCharsSet = charsH; } 
       else if (selCharsSet == charsA) { selCharsSet = charsAH; }
       else if (chars1 && selCharsSet == chars1) { selCharsSet = chars1H; } else if (selCharsSet == chars1H) { selCharsSet = chars1; }
       else if (chars2 && selCharsSet == chars2) { selCharsSet = chars2H; } else if (selCharsSet == chars2H) { selCharsSet = chars2; }       
       else if (chars3 && selCharsSet == chars3) { selCharsSet = chars3H; } else if (selCharsSet == chars3H) { selCharsSet = chars3; }       
       else if (chars4 && selCharsSet == chars4) { selCharsSet = chars4H; } else if (selCharsSet == chars4H) { selCharsSet = chars4; }
       else if (chars5 && selCharsSet == chars5) { selCharsSet = chars5H; } else if (selCharsSet == chars5H) { selCharsSet = chars5; }
       else { 
          selCharsSet = charsL; selCaps = 0; selAltGr = 0; 
          if (selShift == 0) selShift = 1; else selShift = 0;
       }
       CapsClass = 'Caps';
       AltGrClass = 'AltGr';
    }
    if (selCharsSet != charsH) selCaps = 0;
    if (selCharsSet != charsAH) selAltGr = 0;
    writeKeyboard();
 }


function writeKeyboard() {
 var html = '';
 for(var i = 0; i < selCharsSet.length; i++) {
    if (selCharsSet[i] == '||') {
       html += "<br>";
    } else if (selCharsSet[i] == '') {
       html += "<button type=\"button\" disabled=\"disabled\">&nbsp;</button>";
    } else if (selCharsSet[i].length > 1) {
       if (selCharsSet[i] == 'Shift') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick='changeCarSet();'>"+selCharsSet[i]+"</button>";
       } else if (selCharsSet[i] == 'Caps' || selCharsSet[i] == 'Caps2') {
          html += "<button name='"+selCharsSet[i]+"' id='Caps' type=\"button\" class=\"Caps\" onclick='if (selCaps == 1 && selCharsSet == charsH) { changeCarSet(charsL); selCaps = 0; } else { changeCarSet(charsH); selCaps = 1; }'>Caps</button>";
       } else if (selCharsSet[i] == 'AltGr') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(charsA); \">AltGr</button>";
       } else if (selCharsSet[i] == 'AltGr2') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"if (selAltGr == 1 && selCharsSet == charsAH) { changeCarSet(charsAH); selAltGr = 0; } else { changeCarSet(charsA); selAltGr = 1; } /*changeCarSet(charsA);*/ \">AltGr</button>";
       } else if (selCharsSet[i] == '^acc') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(chars1);\">^</button>";
       } else if (selCharsSet[i] == 'ˇacc') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(chars5);\">ˇ</button>";
       } else if (selCharsSet[i] == '°acc') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(chars2);\">°</button>";
       } else if (selCharsSet[i] == '´acc') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(chars3);\">´</button>";
       } else if (selCharsSet[i] == '`acc') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"changeCarSet(chars4);\">`</button>";
       } else if (selCharsSet[i] == 'Enter') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"frmlopener.submit()\">"+selCharsSet[i]+"</button>";
       } else if (selCharsSet[i] == 'Space') {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" onclick=\"getchar(' ');\">"+selCharsSet[i]+"</button>";
       } else {
          html += "<button name='"+selCharsSet[i]+"' type=\"button\" class=\""+selCharsSet[i]+"\" disabled=\"disabled\">"+selCharsSet[i]+"</button>";
       }
    } else if (selCharsSet[i].length == 1) {
       html += "<button name='"+selCharsSet[i]+"' type=\"button\" onclick=\"getchar('"+selCharsSet[i]+"');\">"+selCharsSet[i]+"</button>";
    } else {
       html += "<button type=\"button\" disabled=\"disabled\">&nbsp;</button>";
    }
 }
 document.getElementById('keyboard').innerHTML = html;
  
 var deadkey = '';
 deadkey += "<button name=\"ˇacc\" type=\"button\" class=\"Deadkey\" onclick=\"changeCarSet(chars1);\">ˇ</button>"
 deadkey += "<button name=\"°acc\" type=\"button\" class=\"Deadkey\" onclick=\"changeCarSet(chars2);\">°</button>"
 deadkey += "<button name=\"´acc\" type=\"button\" class=\"Deadkey\" onclick=\"changeCarSet(chars3);\">´</button>"
 deadkey += "<button name=\"`acc\" type=\"button\" class=\"Deadkey\" onclick=\"changeCarSet(chars4);\">`</button>"
 document.getElementById('keyboard_deadkey').innerHTML = deadkey;
 document.getElementById('Caps').className = CapsClass;
 frmlinput.focus();
}

function getchar(charobj) {
   if (!frmlinput && top.document.getElementById('search')) frmlinput = document.forms['test']['search'];

   if (document.selection) { // für IE
      var str = document.selection.createRange().text;
      frmlinput.focus();
      var sel = document.selection.createRange();
      sel.text = charobj; //.innerHTML;
      if (selCaps == 0) { selCharsSet = charsL; writeKeyboard(); }
      frmlinput.focus();
      return;
   } else if ((typeof frmlinput.selectionStart) != 'undefined') { // für Mozilla
      var selLength = frmlinput.textLength;
      var selStart = frmlinput.selectionStart;
      var selEnd = frmlinput.selectionEnd;
      var s1 = (frmlinput.value).substring(0,selStart);
      var s2 = charobj; //.innerHTML
      var s3 = (frmlinput.value).substring(selEnd, selLength);
      frmlinput.value = s1 + s2 + s3;
      if (selCaps == 0) { selCharsSet = charsL; writeKeyboard(); }
      return;
   } else insert(charobj.innerHTML);
}


var iedom=document.all||document.getElementById

var ie=document.all
var moz=document.getElementById && !document.all
var Keyboardview=false
var Keyboard_on=false

function Keyboard_writeHTML() {
   if (iedom) {
      KeyboardObj=document.all? document.all("bluepage_vkeyboard") : document.getElementById("bluepage_vkeyboard");
   }
}
function ietruebody(){
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function bluepage_openKeyBoard(lg,id,inp,frml) {
   if(Keyboardview==true) { 
      hideKeyboard(); 
      return false 
   }
   frmlopener = top.document.forms[frml];
   frmlinput = top.document.forms[frml][inp];
   writeKeyboard();

   Keyboardview=true;
   Keyboard_on=false
}
function hideKeyboard() {
   if (iedom){
      Keyboardview=false;
      KeyboardObj.style.visibility = "hidden";
      Keyboard_on=false
      KeyboardObj.style.left = "-1000px";
   }
}
function positionKeyboard(e){
   if (Keyboardview==true && Keyboard_on==false) {
      if (navigator.userAgent.indexOf('Opera') > -1) var opera = true;
      var curX=(moz)?e.pageX+10 : opera? window.event.clientX : window.event.clientX; // x;
      var curY=(moz)?e.pageY-10 : opera? window.event.clientY : window.event.clientY; // y;
      KeyboardObj.style.left = !opera? curX-KeyboardObj.offsetWidth :  curX+((ietruebody().scrollLeft))-(KeyboardObj.offsetWidth);
      if (!moz) KeyboardObj.style.top = curY+((ietruebody().scrollTop))+20; else KeyboardObj.style.top = curY+25; //-kalobj.offsetHeight;
      KeyboardObj.style.visibility = "visible";
   } else {
      if (ie) hideKeyboard()
   }

   Keyboard_on=true;
}

Keyboard_writeHTML();

document.onclick=positionKeyboard;



