/*
// ####################################################################################################
// # Datei inc.js V 1.0
// ####################################################################################################
// # Copyright © 2004-2007 ISS-Oberlausitz
// # Author: T.Hojenski
// # Email: info@iss-ol.de
// # URL:   http://www.bluepage-cms.com
// # Diese Datei gehört zu dem kommerziellen bluepage - CMS der ISS-Oberlausitz
// # Bitte beachten Sie die Lizenzbedingungen.
// # Unberechtigte Nutzung, Änderung oder Weitergabe über die Lizenzbedingungen hinaus
// # sind strafbar.
// # Eine unberechtigte Verwendung auch von Teilen des CMS-Systems kann zu Schadensersatz-
// # und/oder Unterlassungsansprüchen führen.
// # Das Entfernen der Copyrighthinweise ist untersagt.
// ####################################################################################################
*/
/* DATEI: *.js */


/* Javascript Datei BLUEPAGE CMS 09 -2007 */
/* Copyright by ISS-Oberlausitz */
/* Author: T.Hojenski */

var ie  = document.all;
var dom = document.getElementById;

function popup(typ,id,date) {
   pf = '';
   if (pf == '../' || !document.getElementById('popup_content')) {
      url = pf+'media_view.php?typ='+typ+'&id='+id+'&date='+date;
      opt = 'location=no,scrollbars=auto,toolbar=no,resizable=yes,left=' + ((screen.availWidth-725)/2) + ',top=' + (((screen.availHeight-620)/2)-20) + ',width=720,height=620';
      galwindow = window.open(url,'_blank',opt);
    //  galwindow.moveTo(((screen.availWidth-725)/2),((screen.availHeight-620)/2)-20)
   } else {
      if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
         document.getElementById('popup_error').style.top           = window.pageXOffset + (window.innerHeight/2);
         document.getElementById('popup_error').style.position      = 'fixed';
         document.getElementById('popup_error').style.display       = 'block';
         //alert('test'+);
         //document.getElementById('popup_content').style.margin    =   '-290'; 
         if (document.getElementById('popup_background')) document.getElementById('popup_background').style.display    = 'block';

      } 
         makeRequest(typ,id,date); 
      
   }
}

function popup_close() {
   if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
      document.getElementById('popup_error').style.display       = 'none';
      document.getElementById('popup_error').innerHTML           = '';
      if (document.getElementById('popup_background')) document.getElementById('popup_background').style.display    = 'none';
   } else if (document.all) {
      document.all('popup_error').style.display                  = 'none';
      document.all('popup_error').innerHTML                      = '';
      if (document.all('popup_background')) {
         document.all('popup_background').style.display               = 'none';
         document.all('bluepage_body').style.overflowY                = 'scroll';
         document.all('bluepage').style.marginRight                   = '60';
      }
   }
}



function makeRequest(typ,id,date) {
   var url = 'incl/request.ajax.php?typ='+typ+'&id='+encodeURIComponent(id)+'&date='+date+'&zh='+Math.random();
   http_request = false;
   http_request.responseText = '';
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
         http_request.overrideMimeType('text/xml');
      }
   } else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e) {}
      }
   }
   if (!http_request) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = requestContents;
   http_request.open('GET', url, true);
   http_request.send(null);
}


function requestContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         
         if (http_request.getResponseHeader("Content-Type").substr(0,9) == 'text/html') {
            document.getElementById('popup_error').innerHTML = http_request.responseText;
            document.getElementById('popup_hidden').innerHTML = http_request.responseText;
         } else {
            var xmldoc = http_request.responseXML;
            var r_typ = xmldoc.getElementsByTagName('typ').item(0).firstChild.data;
            
            if (r_typ == 'rplaner_changeOrt')         { // Raumplaner Ortswechsel
               var r_html = xmldoc.getElementsByTagName('htmlhaus').item(0).firstChild.data;
               document.getElementById('rplaner_Haus').innerHTML = r_html;
               var r_html2 = xmldoc.getElementsByTagName('htmlraum').item(0).firstChild.data;
               document.getElementById('rplaner_Raum').innerHTML = r_html2;
            } else if (r_typ == 'rplaner_changeOrt_edit'){
               var r_html = xmldoc.getElementsByTagName('htmlhaus').item(0).firstChild.data;
               document.getElementById('rplaner_Haus').innerHTML = r_html;
               //var r_html2 = xmldoc.getElementsByTagName('htmlraum').item(0).firstChild.data;
               //document.getElementById('rplaner_Raum').innerHTML = r_html2;
            } else if (r_typ == 'res_Standort'){             // Ressourcenverwaltung Standortswechsel
               var r_html = xmldoc.getElementsByTagName('htmlraum').item(0).firstChild.data;
               document.getElementById('resRaum').innerHTML = r_html;            
            } else if (r_typ == 'rplaner_changeHaus') { // Raumplaner Hauswechsel
               var r_html = xmldoc.getElementsByTagName('htmlraum').item(0).firstChild.data;
               document.getElementById('rplaner_Raum').innerHTML = r_html;
            } else if (r_typ == 'carplaner_changeStandort')         { // Carplaner Standortswechsel
               var r_html = xmldoc.getElementsByTagName('htmlbereich').item(0).firstChild.data;
               document.getElementById('carplaner_bereich').innerHTML = r_html;
               var r_html2 = xmldoc.getElementsByTagName('htmlfahrzeug').item(0).firstChild.data;
               document.getElementById('carplaner_fahrzeug').innerHTML = r_html2;
            } else if (r_typ == 'carplaner_changeBereich') { // Carplaner Bereichwechsel
               var r_html = xmldoc.getElementsByTagName('htmlfahrzeug').item(0).firstChild.data;
               document.getElementById('carplaner_fahrzeug').innerHTML = r_html;
            } else {
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_hidden').innerHTML = r_html;
               var popup_height = document.getElementById('bluepage_popup_gal').offsetHeight-90;     //absolutpositionierten objekt
               var popup_width = document.getElementById('bluepage_popup_gal').offsetWidth;
               document.getElementById('popup_hidden').innerHTML = '';                               //damit keine doppelten ids entstehen
              
               //alert(document.body.offsetHeight);
               //document.getElementById('popup_window_height').style.display="block";
               if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
                  var top = (document.body.offsetHeight-popup_height)/2;
                  document.getElementById('popup_error').style.top           = top;
               } else {   
                  document.all('bluepage_body').style.overflowY                = 'hidden';
                  document.all('bluepage').style.marginRight                   = '77px';
                  document.all('popup_error').style.top                      = document.body.scrollTop + ((document.body.clientHeight)/2) - ((popup_height+20)/2);
                  document.all('popup_error').style.display                  = 'block';
               }
               if (document.all('popup_background')) document.all('popup_background').style.display = 'block';
               var left = (document.body.offsetWidth-popup_width)/2;
               //alert(document.body.offsetHeight);
               document.getElementById('popup_error').style.left = left;
               document.getElementById('popup_error').innerHTML = r_html;   
            }
         }
      } else {
         //makeRequest(typ,lg,pf,id,InhId);
         location.reload();
         //alert('Bei dem Request ist ein Problem aufgetreten.');
      }
   }
}

var selRow = '';
function setline(theRow, linecolor) {
   if (selRow != theRow) {
      if (linecolor == '' || typeof(theRow.style) == 'undefined') { return false; }
      if (typeof(document.getElementsByTagName) != 'undefined') { var theCells = theRow.getElementsByTagName('td'); }
      else if (typeof(theRow.cells) != 'undefined') { var theCells = theRow.cells; }
      else return false;
      var rowCellsCnt  = theCells.length;
      for (var c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = linecolor; }
      return true;
   }
}



function ViewNavbar(navbar) {
   if(document.all) {
      NavBar = document.all('bluepage_btnbar')
   } else if(document.getElementById) {
      NavBar = document.getElementById('bluepage_btnbar')
   }
   if (navbar != '') {
      if(document.all) {
         NavBar.innerHTML = document.all(navbar).innerHTML;
      } else if(document.getElementById) {
         NavBar.innerHTML = document.getElementById(navbar).innerHTML;
      }
      NavBar.style.display = 'block';
   } else {
      NavBar.style.display = 'none';
   }
}


// ##################

function changeRaumplaner(typ,vr) {
   makeRequest(typ,vr,'');
}

function changeCarplaner(typ,vr) {
   makeRequest(typ,vr,'');
}

function changeRessourcen(typ,vr){
   makeRequest(typ,vr,'');
}


