function isIE() {
  return navigator.appName.indexOf("Explorer") > 0;
}

/*------------------------------------------------------------------------------------------------*\
| FrameSet Kontrolle                                                                               |
\*------------------------------------------------------------------------------------------------*/

//Leitet bei aktiviertem Javascript auf frame um
function scriptTest(window) {
  window.location.href = "frames/current/index.html";
}

function genMain() {

  var resY = window.top.document.documentElement.clientHeight + 1;
  var resX = 0, resY = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    resX = window.innerWidth;
    resY = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    resX = document.documentElement.clientWidth;
    resY = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    resX = document.body.clientWidth;
    resY = document.body.clientHeight;
  } 
  
  return "<iframe id='main' name='main' src='../../intro.html?resX=" + resX + "&resY=" + resY + "' scrolling='no' frameborder='0'>" + 
         "  no iframe supported" + 
         "</iframe>";
  
  
}


//realisiert das Überspringen des Intro
function skip() {
   base = window.parent.frames['main'].location.href;
   base = base.substring(0, base.lastIndexOf("/"));  
   window.parent.frames['main'].location.href = base + '/main.html'; 
}


//setzt der Weihnachtsseite die Mütze auf
function mainLoaded(window) {
//   m = window.parent.document.getElementById('muetzeOben');
//   if (m) m.className = "muetzeOben";      
//   m = window.parent.document.getElementById('muetzeUnten');
//   if (m) m.className = "muetzeUnten";  
}

//initialisiert menu, löst Popups und NewsFlash aus, lädt lastAkt
function menuLoaded(window) {
  footer = window.top.document.getElementById("footer");
  footer.innerHTML = "";//"aktualisiert am 19.07.2010"
  footer.onclick   = null;
  markMenu(window, "home");
  //showInitialPopup(window);  
   alertNew(window, 'news');
}

// Klasse im Menu hervorheben
function markMenu(window, name) {
  links = window.document.links;
  for (i = 0; i < links.length; i++) {				  
		if (links[i].className == name) {
			links[i].style.fontSize = 16;
			links[i].style.fontWeight = 800;
		} else {				
			links[i].style.fontWeight = "";
			links[i].style.fontSize = "";				
		}
	}
}

//wird bei änderung des contents aufgerufen
function load(window) {

  if (isIE()) {
    checkPicLine(window);
  }
  
  if (window.document.body.className == "events") {    
	  markMenu(window.parent.menu, 'events');
  }
  
  if (window.document.body.className == "trends") {
	  markMenu(window.parent.menu, 'trends');
  }
  
  if (window.document.body.className == "home") {
	  markMenu(window.parent.menu, 'home');
  }
  
  p = window.parent;
	if (window.document.body.className == "leistungen") {
	  markLeistungenMenu(window);
	  p = p.parent;
  }
    
}

function initLeistungen(window) {  
  if (window.location.search.indexOf("show=bp") > 0) window.frames[1].location.href="bp/p01.html";
  if (window.location.search.indexOf("show=hh") > 0) window.frames[1].location.href="hh/index.html";
  if (window.location.search.indexOf("show=sm") > 0) window.frames[1].location.href="sm/1.html";
}

function loadLeistung(window, table) {  
//   window.parent.frames[1].location.href = table.parentElement.href;
}

//Setzt den Klassennamen des selektierten Menus auf marked
function markLeistungenMenu(window) {
  loc = window.location.href;   
  if (loc.indexOf("fh") >= 0) toMark=0;
  if (loc.indexOf("hh") >= 0) toMark=1;
  if (loc.indexOf("sm") >= 0) toMark=2;
  if (loc.indexOf("hv") >= 0) toMark=3;
  if (loc.indexOf("bp") >= 0) toMark=4;
  
  links = window.parent.frames[0].document.links;  
  for (i = 0; i < links.length; i++) {
    links[i].className = (i == toMark) ? "marked" : "unmarked";
  }
}






/*------------------------------------------------------------------------------------------------*\
| Special-Effects                                                                                  |
\*------------------------------------------------------------------------------------------------*/

function alertNew(window, linkName) { 
  BlinkWindow = window;
  BlinkCount  = 8;
  BlinkLink   = null
  var links   = window.document.links
  for (var i=0; i<links.length; i++) {
    if (links[i].className == linkName) {
      BlinkLink = links[i]
      break;
    } 
  }
  
  blink();
}

function blink() {
  if (BlinkCount <= 0) return;   
  BlinkLink.style.color = (BlinkCount-- % 2 == 0) ? "rgb(52, 52, 52)" : "white"
  BlinkWindow.setTimeout("blink();", 500); 
}

function showInitialPopup(window) {
  w = 700;
  h = 700;
  
  popup = window.open("content/xmas/popup.html", "xmas", "menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width="+w+",height="+h);
  
  mw = window.screen.availWidth;
  mh = window.screen.availHeight; 
  popup.moveTo((mw-w)/2, (mh-h)/2);
}

//Hebt bestimmtes Autogramm bei Referenzen hervor
function setAutogramm(num, window) {      
  if (num == "") {
    num = "01";
  }
  index = num-1;  
  images = window.document.images;
  links = window.document.links;
  images[5].src = "autogramme_" + num + ".jpg";
  for (i = 0; i < links.length-1; i++) {
    if (index == i) {            	
	links[i].style.fontWeight = 800;
    } else {				
	links[i].style.fontWeight = "";
    }
  }  
  if (index < 5) {    
  } else if (index < 8) {
    index++;
  } else {
    index = 21-index;
  }  
  for (i = 0; i < images.length; i++) {
    if (index == i) {            	
	images[i].parentNode.style.backgroundColor = "#CCCCCC";
    } else {			
        images[i].parentNode.style.backgroundColor = "";	
    }    
  }    
}

function trendsPreview(link, document) {
  var offset = "";
  if (link != null) offset = (/\/(\d\d)\//.exec(link.href))[1] + "/"; 
  
  images = document.images;
  for (i = 1; i <= images.length; i++) images[i-1].src = offset + "[" + i + "].jpg";    
}

/*------------------------------------------------------------------------------------------------*\
| Presse und Events                                                                                |
\*------------------------------------------------------------------------------------------------*/

//hinterlegt LI bei Presse und Events grau
function markItem(tr) {  
  tr.cells[0].style.background = "#CCCCCC url('../deco.gif') center no-repeat";
  tr.cells[1].style.background = "#CCCCCC";
  if (tr.cells.length > 2) {
    tr.cells[2].style.background = "#CCCCCC url('../sep.gif')  center no-repeat";
    tr.cells[3].style.background = "#CCCCCC"; 
  }
}

//hebt graue Hinterlegung bei LI von Presse und Events auf
function unmarkItem(tr) {  
  tr.cells[0].style.background = "url('../deco.gif') center no-repeat";
  tr.cells[1].style.background = "";
  if (tr.cells.length > 2) {
    tr.cells[2].style.background = "url('../sep.gif')  center no-repeat";
    tr.cells[3].style.background = "";
  }
}


//Öffnet Popup-Fenster zum Anzeigen einer Pressemeldung
function showPopup(window, content, w) {  
  
  h = 0.9 * window.screen.availHeight;
  w = 0.9 * window.screen.availWidth;
  
  popup = window.open(content, "popup", "menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h); 
              
  popup.moveTo(0, 0);
}

function showPressePopup(window, offset, max, quelle) {
  showPopup(window, "popup.html?p" + offset + "_1.pdf;" + escape(quelle) + ";1;" + max);
}

function showFlashPopup(window, vidName) {
  loc  = window.location.href;
  os   = loc.indexOf("content");
  base = loc.substring(0, os);
  path = loc.substring(os, loc.lastIndexOf('/'));
  
  popup = base+"_res/flashPopup.html?" + escape("../" + path + "/" + vidName + ".swf");    
  
  w = 480;
  h = 360;
  
  popup = window.open(popup, "video", "menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h);
  
  mw = window.screen.availWidth;
  mh = window.screen.availHeight;
  
  popup.moveTo((mw-w)/2, (mh-h)/2);
}

function generateFlashPopupBody(window) {

  vidName = unescape(window.location.search.substring(1));    

  return "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " +
         "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' " +
         "width='480' " +
         "height='360'>\n" +
         
         "<param name='movie' value='" + vidName + "'>\n" +
         "<param name='quality' value='high'>\n" +
         
         "<embed src='" + vidName + "' quality='high' " +
         "pluginspage='http://www.macromedia.com/go/getflashplayer'" +
         "type='application/x-shockwave-flash' " +
         "width='480' " +
         "height='360'/>\n" +
         
         
         "</object>";         
}

//Erzeugt dynamischen Inhalt des PressePopups
function generatePopupBody(window, cnt, quelle, akt, max) {

  //bei Anfahrt
  if(!quelle) quelle = "<a href='http://www.map24.de' target='_new'><img src='map24.gif' border='0'></a>";
  

  if (quelle.indexOf("|") >= 0) {
      attr = quelle.split("|"); 
      q = attr[akt-1];
  } else {
      q = quelle;
  }
  
  html =          '  <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">              \n'+
                  '    <tr height="500"><td colspan="2">                                    \n'+
                  '      <iframe marginwidth="0" marginheight="0" scrolling="no" src="' + cnt +'" width="100%" height="100%" frameborder="0"></iframe>\n'+
                  '    </td></tr>                                                                 \n';

  if (max > 1 || q.length > 0) {
    html +=       '    <tr height="20" class="text">                                                          \n'+
                  '      <td class="src">'                                                           ;
    if (q.length > 0) {
      html +=     '<span>Quelle: </span> ' + q                                                       ;
    }
    html +=       '</td>                                                                          \n'+
                  '      <td class="nav">                                                         \n';
    
    if (max > 1) {
      html +=     '        <span class="page">Seite: </span>                                      \n';
      if (akt == 1) {
        html +=   '        <span class="inakt">&nbsp;&lt;&nbsp;</span>                            \n';
      } else {
        html +=   '        <a class="sl" href=' + getPopupLink(cnt, quelle, parseInt(akt)-1, max) + '>&nbsp;&lt;&nbsp;</a>\n'; 
      }
      
      for (var i = 1; i <= max; i++) {
        if (i == akt) {
          html += '        <span class="page">&nbsp;' + i + '&nbsp;</span>                        \n';
        } else {  
          html += '        <a class="sl" href=' + getPopupLink(cnt, quelle, i, max) + '>&nbsp;' + i + '&nbsp;</a> \n';
        }
      }
       
      html +=     '&nbsp;&nbsp;'                                                                     ; 
      if (akt == max) {
        html +=   '        <span class="inakt">&nbsp;&gt;&nbsp;</span>                            \n';
      } else {
        html +=   '        <a class="sl" href=' + getPopupLink(cnt, quelle, parseInt(akt)+1, max) + '>&nbsp;&gt;&nbsp;</a>\n'; 
      }
    }
    
    html +=       '      </td>                                                                    \n'+
                  '    </tr>                                                                      \n'; 
  }       
  html +=         '  </table>                                                                     \n'; 
  
  return html;              
}

//setzt Link-href zusammen
function getPopupLink(cnt, quelle, i, max) {
  newCnt = cnt.substring(0, cnt.indexOf("_")) + "_" + i + ".pdf";
  return '"popup.html?' + newCnt + ';' + escape(quelle) + ';' + i + ';' + max + '"';  
}


function showPicPopup(src) {  
  src = src.replace(/\.(...)$/, ".g.$1");
  img = new Image();
  img.onload = function() {
    w = img.width + 30;
    h = img.height + 30;
  
    popup = window.open(src, "picture", "menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h); 
              
    popup.moveTo((window.screen.availWidth-w)/2, (window.screen.availHeight-h)/2);
  };  
  img.src = src; 
  
  
}



/*------------------------------------------------------------------------------------------------*\
| Einheitliche Inhaltserzeugung                                                                    |
\*------------------------------------------------------------------------------------------------*/

function alertSize() {
  
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}


function genContent_TE(caption, page, maxPage, content, id) {
  noBack = page < 0;
  page   = Math.abs(page);
  return  "<table class=TE " + (id ? "id="+id+" " : '') + "cellpadding=0 cellspacing=0 border=0>"                                     +    
          "  <tr class=hr>"                                                                           +                                                  
          "    <td class=textStrong>" + caption + "</td>"                                             + 
          "    <td class=text>"                                                                       + 
          "      <div class=sl>" + (page==maxPage
                   ?  "&nbsp;"                            
                   : ("<a href=" + (page+1) + ".html>weiter &gt;&gt;</a>"))                  +
          "      </div>"                                                                              +
          "      <div class=sl>" + (noBack 
                   ?  "&nbsp;" 
                   : ("<a href=" + (page==1 ? "../index" : (page-1)) + ".html>&lt;&lt; zurück</a>")) +          
          "      </div>"                                                                              +
          "    </td>"                                                                                 +
          "  </tr>"                                                                                   +
          "  <tr class=content><td colspan=2>"                                                        +
               content                                                                                +                
          "  </td></tr>"                                                                              +
          "</table>"                                                                                  ;    
}

function genContent_TE_headPic(page, maxPage, content) {
  return genContent_TE("<img src='" + page + ".jpg'>",page, maxPage, content);
}




function genContent_TE_picLine(caption, page, maxPage, picCount, text, picAligns, resizable) {    

  con =   "    <table id=picLine cellpadding=0 cellspacing=0 border=0>"                                          +
	        "      <tr class=text><td class=content colspan=" + picCount + ">"                          + 	      
	                 text                                                                               +        
          "      </td></tr>"                                                                          +
          "      <tr class=pic>"                                                                      ;

  for (var i=1; i<=picCount; i++) {    
    con +="        <td width=" + (100/picCount) + "%";
    if (picAligns) switch(picAligns.charAt(i-1)) {
      case 'r': con += " style=' text-align:right'";
      case 'c': con += " style=' text-align:center'";
      case 'l': con += " style=' text-align:left'";
    }    
    con +="><img src=" + Math.abs(page) + "_" + i + ".jpg";
    if (resizable) con += " onclick='showPicPopup(this.src)' class='resizable'";
    con += "></td>";
  }
    
  con +=  "  </tr>"                                                                                   +
          "</table>"                                                                                  ;            
  return genContent_TE(caption, page, maxPage, con);
}

function genContent_TE_2x3(caption, page, maxPage, t1, t2, swap) {
  ct1 = "<td colspan=2 class=text>" + t1 + "</td>";
  ct2 = "<td colspan=2 class=text>" + t2 + "</td>";
  ci1 = "<td rowspan=2 class=pic><img src=" + page + "_1.jpg></td>";
  ci2 = "<td rowspan=2 class=pic><img src=" + page + "_2.jpg></td>";
  ci3 = "<td rowspan=2 class=pic><img src=" + page + "_3.jpg></td>";
  ci4 = "<td rowspan=2 class=pic><img src=" + page + "_4.jpg></td>";
  con = "<table id=zxd cellpadding=0 cellspacing=0 border=0'><tr>";
  
  if (swap) con += ct1 + ci1 + ci2; 
  else      con += ci1 + ci2 + ct1;
              
  con += "</tr><tr>" + ci3 + ci4 + "</tr><tr>" + ct2 + "</tr></table>";
  return genContent_TE(caption, page, maxPage, con);
}

//nur für IE notwendig
function checkPicLine(window) {  
  var t = window.document.getElementById("picLine");  
  var rows  = t.childNodes[0].childNodes; 
  var rPic  = rows[rows.length-1];
  var pics  = rPic.childNodes;  
  var h     = 0;    
  for (var i=0; i<pics.length; i++) h = Math.max(h, pics[i].childNodes[0].height);  
  rPic.style.height  = h;
  rows[0].style.height = 390-h;
  if (rows.length == 3) {
    rows[0].style.height = 370-h;
    rows[1].style.height = 20;    
  }  
    
}

function genContent_TE_2picInline(caption, page, maxPage, p1, p2, p3) {
  con =   "<p class=text>";  
  if (p1.length > 0) con += p1 + "<br><br>";  
  con += "<img src=" + page + "_1.jpg align=right style='padding: 0px 0px 5px 5px'> " + p2 + "<br><br>" +
         "<img src=" + page + "_2.jpg align=left  style='padding: 0px 5px 5px 0px'> " + p3 + "</p>" ;                     
  return genContent_TE(caption, page, maxPage, con);
}


function genContent_TE_vid(caption, page, maxPage, text, vid) {  
  return genContent_TE(caption, page, maxPage,
    "<table class=text cellpadding=0 cellspacing=0 border=0>"                         +
    "  <tr><td colspan=3> " + text  + "</td></tr>"                                    +
    "  <tr height=1>"                                                                 +
    "    <td class=center><img src=1_1.jpg></td>"                                     +
    "    <td>" + vid + "</td>"                                                        +
    "    <td class=center><img src=1_3.jpg></td>"                                     +
    "  </tr>"                                                                         +
    "  <tr height=1 valign=bottom>"                                                   +
    "    <td class=center colspan=3 style='padding-top:10px'><img src=1_2.jpg></td>"  +
    "  </tr>"                                                                         +
    "</table>"
  );
}


function genContent_Vid(name, wmvSize, flashSize) {
  res = "<table class=video align=center border=0><tr>";
  if (flashSize) res += "<td class=flash>" + 
                        "  <div onClick=\"showFlashPopup(window, '" + name + "')\" title='" + flashSize + "MB Flash' />" +
                        "</td> ";
  if (wmvSize)   res += "<td class=wmv><a href=" + name + ".wmv title='" + wmvSize + "MB WMV' /></td>";
  return res + "</tr></table>";
}



//highslide fuctions
function fillGallery(title, num) {
  var dir = window.location.href;
  dir = "../../" + dir.substring(dir.lastIndexOf("content"), dir.lastIndexOf("/"));
  
  var gallery = window.top.document.getElementById("hsgallery");
  gallery.innerHTML = "";
  for (i=0; i<num; i++) gallery.innerHTML += "<a href='" + dir + "/" + i + ".jpg' "       +
                                             "class='highslide' "                         +
                                             "onclick='return hs.expand(this)'"           +
                                             "title='" + title + "' " + //' ["+(i+1)+"/"+num+"]'"  +
                                             "/>";
}

function showGallery(index) {
  var starter = window.top.document.getElementById("hsGalleryStarter");
  starter.setAttribute("index", index);
  starter.click(); 
}

function genContent_TE_gallery(caption, page, maxPage, thumbnails, height, text, fixedTarget) {    

  con =   "    <table id=picLine cellpadding=0 cellspacing=0 border=0>"                               +
	        "      <tr class=text><td class=content colspan=" + thumbnails.length + ">"                 +
	                 text                                                                               +
          "      </td></tr>"                                                                          +
          "      <tr class=pic>"                                                                      ;
  for (var k=0; k<thumbnails.length; k++) {
    var i = thumbnails[k];
    var h = (i.length && i.length > 1 && i[1]) ? i[1] : height;
    var a = (i.length && i.length > 2 && i[2]) ? i[2] : "center";
    if (i.length) i = i[0];
    var t = fixedTarget != null ? fixedTarget : i;
    con +="<td width='" + (100/thumbnails.length) + "%' style=' text-align:"+a+"'>" +
          "  <img src='" + i + ".jpg' height='"+h+"' onclick='showGallery(" +  t + ")' class='resizable'>" +
          "</td>";
  }
  con +=  "  </tr></table>";
  return genContent_TE(caption, page, maxPage, con);
}


