function swProgram(hostingId) {

 	var hostingId = document.getElementById(hostingId);

	var labels = document.getElementsByTagName('label');
	for ( var i = 0; i < labels.length; i++)
	{
		labels[i].className = '';
	}

	hostingId.className = 'checked';
	return false;
}
function randomPassword(length)
{
  chars = "abcdefghkmnprsuvwxABCDEFGHKLMNPRSTUVWX23456789";
  pass = ""; 
  for(x=0;x<length;x++)
  {
    i = Math.floor(Math.random() * chars.length);
    pass += chars.charAt(i);
  }
  return pass;
}
function generate_password()
{
  passwd = document.getElementById("password");
  passwd.value = randomPassword(8);
  passwd_again = document.getElementById("password_again");
  passwd_again.value = passwd.value;
  generatedPasswd = document.getElementById("generatedPasswd");
  if (generatedPasswd) {
    generatedPasswd.innerHTML = "<strong>Generovane heslo: </strong>"+passwd.value;
  }
  return false;
}


function checkbox_action(f){
  var t=0;
  var c=f['id[]'];
  action = f.action.value;
  if (c.length == undefined){
    //pouze jeden checkbox - neni pole
    c.checked?t++:null;
  }else{
    for(var i=0;i<c.length;i++){
      c[i].checked?t++:null;
    }
  }
  var action_text = f.action.options[f.action.selectedIndex].text.toLowerCase();
  if ((t > 1)&&(action != 'delete')){
    alert("Hups ! Chcete-li "+action_text+", zaškrtněte prosím pouze jednu položku.");
    return false;
  }
  if ((t < 1)&&(action == 'delete')){
    alert("Hups ! Chcete-li "+action_text+", zaškrtněte prosím alespoň jednu položku.");
    return false;
  }
  if ((t < 1)&&(action != 'delete')){
    alert("Hups ! Chcete-li "+action_text+", zaškrtněte prosím položku u které chcete tuto akci provést.");
    return false;
  }
  return true;
}

