function tableSelect(objForm, objCheckBox, objCheckBoxName)
{
  for(var i = 0; i < objForm.elements.length; i++)
  {
    var o = objForm.elements[i];

    if (o.name.substr(0, 4) == 'cbox' || o.name == objCheckBoxName)
    {
      o.checked = objCheckBox.checked;
    }
  }
}

function confirmDelete(objForm, name, idx)
{
  if (confirm('Wollen Sie den Eintrag "' + name + '" wirklich löschen?') == true)
  {
    objForm.deleteindex.value = idx;
    objForm.savedata.value = 5;

    objForm.submit();
  }
}

function confirmDeleteImage(objForm, savedata)
{
  if (confirm('Wollen Sie das Bild wirklich löschen?\n\nWarnung: Das Bild wird unwiderruflich gelöscht.') == true)
  {
    objForm.savedata.value = savedata;

    objForm.submit();
  }    
}

function submitFormular(objForm, savedata)
{
  objForm.savedata.value = savedata;

  objForm.submit();    
}

function resetDoc(objForm)
{
  objForm.search.value = '';
  objForm.search_zip.value = '';
  objForm.search_city.value = '';
  
  objForm.submit();
}

function openWinXY(url, x, y, width, height, resizable, scrollbar)
{
  var s;
  
  if (resizable)
    s = 'resizable=yes';
  else
    s = 'resizable=no';
    
  if (scrollbar)
    s = s + ',toolbar=yes,location=no,status=no,scrollbars=yes,menubar=no,titlebar=no,width=' + width + ',height=' + height + ',left=' + x + ',top=' + y;
  else    
    s = s + ',toolbar=no,location=no,status=no,scrollbars=no,menubar=no,titlebar=no,width=' + width + ',height=' + height + ',left=' + x + ',top=' + y;

  window.open(url, '_blank', s);  
}

function openWin(url, width, height, resizable, scrollbar)
{
  openWinXY(url, 40, 40, width, height, resizable, scrollbar);
}

function openPrintWin(url, width)
{
  var height;
  
  height = 80 * screen.availHeight / 100;
  
  window.open(url, '_blank', 'resizable=yes,toolbar=yes,location=no,status=no,scrollbars=yes,menubar=no,titlebar=no,width=' + width + ',height=' + height + ',left=40,top=40');
}  

function openImage(imageURL)
{
  window.open('showimage.php?image=' + imageURL, '_blank', 'resizable=yes,toolbar=no,location=no,status=no,scrollbars=no,menubar=no,titlebar=no,width=660,height=520,left=40,top=40');  
}

function openFlashMovie(movie, preview, width, height)
{
  window.open('playmovie.php?movie=' + movie + '&preview=' + preview, '_blank', 'resizable=yes,toolbar=no,location=no,status=no,scrollbars=no,menubar=no,titlebar=no,width=' + width + ',height=' + height + ',left=40,top=40');  
}

function closeWindowAndRefreshOpener()
{
  if (opener != null)
    if (opener.location != null)
    {  
      opener.location.reload();
      window.close();
    }
}

function setcursoron(obj, on)
{
  if (on == true)
    obj.style.cursor = 'pointer';
  else
    obj.style.cursor = 'auto';
}

function setmenuon(obj, on, color)
{
  setcursoron(obj, on);    
  obj.style.backgroundColor = color;
}

function setmenuon_table(obj, tdname, on)
{
  setcursoron(obj, on);    

  var i = 1;

  for (;;)
  {
    tdobj = document.getElementById(tdname + i);
    if (tdobj == null)
      break;
    else if (on == true)
    {
      if (i == 1)
        tdobj.style.backgroundColor = '#FFE0E0';
      else    
        tdobj.style.backgroundColor = '#F0F0F0';
    }
    else
      tdobj.style.backgroundColor = '#FFFFFF';
      
    i++;
  }
}

function toggleID(id, visible)
{
  thisId = document.getElementById(id);
  if (thisId != null)
  {
    if (visible >= 0)
    {
      if (visible > 0)
        thisId.style.display = "";
      else
        thisId.style.display = "none";
    }
    else if (thisId.style.display == "none")
      thisId.style.display = "";
    else
      thisId.style.display = "none";
  }
}

function setFocus(objName)
{
  obj = document.getElementById(objName);
  if (obj != null)
    obj.focus();
}

function login_showPasswordInput(show)
{
  toggleID("id_space1", 1 - show);
  toggleID("id_forgetpasswordinfo", 1 - show);
  toggleID("id_forgetpasswordinput", show);
      
  if (show == 1)
    setFocus("email_address");
  else
    setFocus("username");
}

function sendAdminEMails(idForm)
{
	var objForm = document.getElementById(idForm);
	var objInput = document.getElementById('sendemails');
	if (objForm != null && objInput != null)
	{
		objInput.value = '1';
		objForm.submit();
	}
}