function smileys(open, end){
    var tArea = document.myForm.S1;
    var isIE = (document.all)? true : false;
    var open = (open)? open : "";
    var end = (end)? end : "";tArea.focus();

    if(isIE){
        var curSelect = document.selection.createRange();
        if(arguments[2]){
            curSelect.text = open + arguments[2] + "]" + curSelect.text + end;
        } else {
            curSelect.text = open + curSelect.text + end;
        }
    } else if(!isIE && typeof tArea.selectionStart != "undefined"){
        var selStart = tArea.value.substr(0, tArea.selectionStart);
        var selEnd = tArea.value.substr(tArea.selectionEnd, tArea.value.length);
        var curSelection = tArea.value.replace(selStart, '').replace(selEnd, '');
        if(arguments[2]){
            tArea.value = selStart + open + arguments[2] + "]" + curSelection + end + selEnd;
        } else {
            tArea.value = selStart + open + curSelection + end + selEnd;
        }
    } else {
        tArea.value += (arguments[2])? open + arguments[2] + "]" + end : open + end;
    }
}


/* do html umiestni:

do inputu daj: onkeyup="passwordStrength(this.value, desc)"

*/
var desc = new Array();
    desc[0] = "krátke heslo";
    desc[1] = "veľmi slabé heslo";
    desc[2] = "slabé heslo";
    desc[3] = "dobré heslo";
    desc[4] = "veľmi dobré heslo";
    desc[5] = "vynikajúce heslo";
    
function passwordStrength(password1, desc) {

  var score = 0;
  //ak je heslo väčšie ako 7 znakov, dostane 1 bod
  if (password1.length > 4) score++;
  //ak heslo obsahuje malé aj veľké znaky, dostane 1 bod
  if ( ( password1.match(/[a-z]/) ) && ( password1.match(/[A-Z]/) ) ) score++;
  //ak heslo obsahuje číslicu, dostane 1 bod
  if (password1.match(/\d+/)) score++;
  //ak heslo obsahuje špeciálny znak z množiny, dostane 1 bod
  if ( password1.match(/.[!,/,\\,|,<,>,@,=,#,",$,,§,%,^,°,',`,',&,*,?,_,~,-,(,)]/) ) score++;
  //ak je heslo väčšie ako 12 znakov, dostane 1 bod
  if (password1.length > 6) score++;
  //hodnota pre menej ako 6 znakov
  if (password1.length < 6) score = 0;
  //6 alebo 7 malých alebo veľkých písmen v jednom hesle, aby sa zabránilo falošnému hodnoteniu
  if ( ( password1.length > 5 ) && ( score == 0 ) ) score++;

  document.getElementById("passwordDescription").innerHTML = desc[score];
  document.getElementById("passwordStrength").className = "strength" + score;
}






