function delconf(string) {
  return confirm('Pro smazání položky s názvem "'+string+'" stiskněte tlačítko "ok". Pokud položku smazat nechcete, vyberte volbu "zrušit"');
}

// multi select
function sel_all (idname,id1,id2) {
  for(i=id1;i<=id2;i++)
    document.getElementById(idname+'-'+i).checked = true;
}

// multi select
function desel_all (idname,id1,id2) {
  for(i=id1;i<=id2;i++)
    document.getElementById(idname+'-'+i).checked = false;
}

// multi select
function inv_all (idname,id1,id2) {
  for(i=id1;i<=id2;i++)
    document.getElementById(idname+'-'+i).checked = !document.getElementById(idname+'-'+i).checked;
}

function winopen(url, sizex, sizey) {
  sizex = sizex + 40
  sizey = sizey + 70
  win = window.open(url+'&js=1', '','toolbar,width='+sizey+',height='+sizex+',menubar=no,status=no,toolbar=no,scrollbars=auto,resizable=yes');
  return (typeof(win)=='object') ? false : true;
}



var mlength;

function progresbar (element, maxlength, mlength) {
}

function countChars(element,maxlength){

  var mlength = document.getElementById(element).value.length;
  var pBar    = document.getElementById(element+'_bar');

  if (mlength > maxlength) {
    alert('NELZE VLOŽIT VÍCE NEŽ '+ maxlength +' ZNAKŮ');
    document.getElementById(element).value = document.getElementById(element).value.substr(0,maxlength);
    mlength = maxlength;
  } else if (mlength > maxlength * 0.75) {
     pBar.style.backgroundColor = 'red';
  } else if (mlength > maxlength * 0.40) {
     pBar.style.backgroundColor = '#FF8000';
  } else if (mlength > maxlength * 0.20) {
     pBar.style.backgroundColor = 'black';
  } else if (mlength > maxlength * 0.10) {
     pBar.style.backgroundColor = 'ThreedDarkShadow';
  } else if (mlength > maxlength * 0.05) {
     pBar.style.backgroundColor = 'gray';
  } else {
     pBar.style.backgroundColor = 'silver';
  }

  var maxWidths = document.getElementById(element+'_main').style.width;
  var maxWidth  = maxWidths.substr(0,maxWidths.length -2)-2;

  var newWidth = maxWidth/maxlength*mlength;
  var procento = Math.round((mlength/maxlength*100)-0.4)+'%' + ' [' + mlength + '/' + maxlength + ']';
  pBar.style.width = newWidth+'px';
  document.getElementById(element+'_val').innerHTML=procento;
}

