function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  winName = searchAndReplace(winName, " ", "_");
  winName = searchAndReplace(winName, "-", "_");
  window.open(theURL,winName,features);
}

//maskin a teaser
function closeTeaser(teaser){
    with(teaser){
      active = false;
      img_header.src=path_deactivated;
      img_image.style.display="none";
      div_description.style.display="none";
      ahref_mapArea.href="javascript:switchteaser('"+name+"');";
      ahref_mapArea.target = "";
    }
}
//open a teaser
function openTeaser(teaser){
  with(teaser){
    active = true;
    img_header.src=path_activated;
    img_image.style.display="block";
    div_description.style.display="block";    
    ahref_mapArea.href=link_page;
    ahref_mapArea.target = ahref_mapAreaTarget;
  }
}
//maskin all teaser descriptions and images
function closeAllTeasers() {
  for (var i=0;i<teasers.length;i++) {
    closeTeaser(teasers[i]);
  }
}

//maskin and demasking the teaser (description and images) by parameter value [Layer_Name]
function switchteaser(Layer_Name){
  closeAllTeasers();
  for (var i=0;i<teasers.length;i++) {
    if(teasers[i].name==Layer_Name){
      if(teasers[i].active){
        closeTeaser(teasers[i]);
      }else{
        openTeaser(teasers[i]);
      }
    }
  }
}

function teaser(name, active, img_header, headerpath_activated, headerpath_deactivated,img_image, div_description, ahref_mapArea, ahref_mapAreaTarget, link_page ){
  var GECKO = document.getElementById? 1:0 ;
  var IE = document.all? 1:0 ;

  this.name=name;
  this.active = active;
  this.path_activated = headerpath_activated;
  this.path_deactivated = headerpath_deactivated;

  this.img_header = document.getElementById(img_header);
  this.img_image = document.getElementById(img_image);
  this.div_description = document.getElementById(div_description);
  
  // variables for linking
   this.ahref_mapArea = document.getElementById(ahref_mapArea);
   this.ahref_mapAreaTarget = ahref_mapAreaTarget;
   this.link_page = link_page;
}

function searchAndReplace(QuellText, SuchText, ErsatzText){
  // Fehlerpruefung
  if ((QuellText == null) || (SuchText == null)) {
    return null;
  }
  if ((QuellText.length == 0) || (SuchText.length == 0)) {
    return QuellText;
  }
  // Kein ErsatzText ?
  if ((ErsatzText == null) || (ErsatzText.length == 0)) {
   ErsatzText = "";
  }
  var LaengeSuchText = SuchText.length;
  var LaengeErsatzText = ErsatzText.length;
  var Pos = QuellText.indexOf(SuchText, 0);
  while (Pos >= 0) {
    QuellText = QuellText.substring(0, Pos) + ErsatzText + QuellText.substring(Pos + LaengeSuchText);
    Pos = QuellText.indexOf(SuchText, Pos + LaengeErsatzText);
  }
  return QuellText;
}

//alter the source of dom element (the path will be edited by the phytenscript to add the url prefix)
function alterSRC(source,id){
      document.getElementById(id).src=source;
}
//alter the source of dom element (the path will not edited by the phytenscript)
function alterSRCWithoutPy(source,id){
      document.getElementById(id).src=source;
}