var c_el = new Array();
function change(id)
{
  c_el[id] = getE(id);
  if (c_el[id] != null && c_el[id] != '')
  {
    if(c_el[id].style.display == "none" || c_el[id].style.display == "") //|| c_el[id].style.display == ""
      c_el[id].style.display = "block"; //block nicht, damit es in tabellen geht!
    else
      c_el[id].style.display = "none";
  }
}

function show(id)
{
  c_el[id] = getE(id);
  if (c_el[id] != null && c_el[id] != '')
    c_el[id].style.display = "block"; //block nicht, damit es in tabellen geht!
}
function hide(id)
{
  c_el[id] = getE(id);
  if (c_el[id] != null && c_el[id] != '')
    c_el[id].style.display = "none";
}


//dependent, immer im selben popup öffnen!
function popup(loc, width, height, scroll)
{
  if(width != null && height != null && scroll != null)
  {  
    lft=(screen.availWidth)?(screen.availWidth-width)/2:100;
    tp=(screen.availHeight)?(screen.availHeight-height)/2:100;
    
    p = window.open(loc,'popup','toolbar=no,width='+width+',height='+height+',screenX='+lft+',screenY='+tp+',left='+lft+',top='+tp+',scrollbars='+scroll+',resizable=yes,status=no,menubar=no,directories=no,location=no,dependent=no');
    p.focus();
  }
}


function htmlPopup(imageloc, width, height, scroll)
{
  if(width != null && height != null && scroll != null)
  {  
    HTML = "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n<html><head><meta http-equiv='content-type' content='text/html; charset=UTF-8'><style>body, html{margin:0;padding:0;background-color:#FFFFFF;}</style></head><body><img src='"+ imageloc +"'/><br/></body></html>";
    if(typeof(popupImage) != "undefined" && popupImage != null)
    {
      if (self.innerHeight && popupImage.innerHeight) 
      {
        popupImage.innerWidth=width;
        popupImage.innerHeight=height;
      }
      else
        popupImage.close();
    }
      
    popupImage = window.open("",'htmlpopup','width='+width+',height='+height+',screenX=25,screenY=25,left=25,top=25,toolbar=no,scrollbars='+scroll+',resizable=yes,status=no,menubar=no,directories=no,location=no,dependent=yes');
    popupImage.document.open();
    popupImage.document.write(HTML);
    popupImage.document.close();
    popupImage.focus();
  }
}

//Text-Counter JS
function textCounter(field, cntfield, maxlimit) 
{
  if(field != null && cntfield != null)
  {
  if (field.value.length > maxlimit) 
    field.value = field.value.substring(0, maxlimit);
  else 
    cntfield.innerHTML = maxlimit - field.value.length;
  }
}


function toggler(showid, elementstr)
{
  for (i = 0; i < 200; i++)
  { 
    if(getE(elementstr+i))
    {
      if(elementstr+i == elementstr+showid)
      { 
        if(getE(elementstr+i).style.display == "block")
          getE(elementstr+i).style.display = "none";
        else
          getE(elementstr+i).style.display = "block";
      } 
      else
        getE(elementstr+i).style.display = "none";
    }
  }
}

//Usage: <a href="javascript:void(0)" onClick="boldize(this);">bold</a>
function boldize(obj)
{
	if(obj.style.fontWeight == '' || obj.style.fontWeight == 'normal' )
	  obj.style.fontWeight = "bold";
  else
	  obj.style.fontWeight = "normal";
}

//TOOL: leading zeros
function LZ(x) {return(x<0||x>9?"":"0")+x} 

//TOOL: getElementById
function getE(myel_id){if(document.getElementById(myel_id) != null && document.getElementById(myel_id) != '' && document.getElementById(myel_id) != 'undefined') return document.getElementById(myel_id);}


