/*
// ####################################################################################################
// # 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,lg,pf,id,InhId) {
   if (pf == '../' || !document.getElementById('popup_content')) {
      url = pf+'media_view.php?typ=' + typ + '&lg=' + lg + '&pf=' + pf + '&id=' + id + '&InhId=' + InhId;
      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_content').style.top           = window.pageXOffset + (window.innerHeight/2);
         document.getElementById('popup_content').style.position      = 'fixed';
         document.getElementById('popup_content').style.display       = 'block';
         if (document.getElementById('popup_background')) document.getElementById('popup_background').style.display    = 'block';
      } else if (document.all) {
         document.all('bluepage_body').style.overflowY                = 'hidden';
         document.all('bluepage').style.marginRight                   = '17px';
         document.all('popup_content').style.top                      = document.body.scrollTop + ((document.body.clientHeight)/2);
         document.all('popup_content').style.display                  = 'block';
         if (document.all('popup_background')) document.all('popup_background').style.display               = 'block';
      }
      if (typ == 'rdb' || typ == 'gal' || typ == 'fgal') {
         makeRequest(typ,lg,pf,id,InhId); 
      } else if (typ == 'flv') {
         makeRequest(typ,lg,pf,id,InhId);
      } else {
         makeRequest(typ,lg,pf,id,InhId);
      }
   }
}

function popup_close() {
   if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
      document.getElementById('popup_content').style.display       = 'none';
      document.getElementById('popup_content').innerHTML           = '';
      if (document.getElementById('popup_background')) document.getElementById('popup_background').style.display    = 'none';
   } else if (document.all) {
      document.all('popup_content').style.display                  = 'none';
      document.all('popup_content').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                   = '0';
      }
   }
}

function img_view(ds,lg,pf,inhId) {
   url = pf + './img_view.php?ds=' + ds + '&lg=' + lg + '&inhId=' + inhId;
   opt = 'location=no,scrollbars=auto,toolbar=no,resizable=yes,left=' + ((screen.availWidth-720)/2) + ',top=' + (((screen.availHeight-650)/2)-20) + ',width=665,height=650';
   galwindow = window.open(url,'_blank',opt);
   galwindow.moveTo(((screen.availWidth-720)/2),((screen.availHeight-650)/2)-20)
}


var http_request = false;

function makeRequest(typ,lg,pf,id,InhId) {
   var url = 'incl/request.ajax.php?InhId='+InhId+'&id='+id+'&lg='+lg+'&pfad='+pf+'&typ='+typ+'&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_content').innerHTML = http_request.responseText;
         } else {
            var xmldoc = http_request.responseXML;
            var r_typ = xmldoc.getElementsByTagName('typ').item(0).firstChild.data;
            if (r_typ == 'gal')         { // Galerie
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_content').innerHTML = r_html;
            } else if (r_typ == 'fgal') { // FTP-Galerie
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_content').innerHTML = r_html;
            } else if (r_typ == 'sorbio') { // Sorbiodatenbank
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_content').innerHTML = r_html;
            } else if (r_typ == 'flv')  { // Flashmovie
               var flv_html       = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               var flv_file       = xmldoc.getElementsByTagName('file').item(0).firstChild.data;
               var flv_player     = xmldoc.getElementsByTagName('player').item(0).firstChild.data;
               var flv_img        = xmldoc.getElementsByTagName('img').item(0).firstChild.data;
               var flv_win        = xmldoc.getElementsByTagName('win').item(0).firstChild.data;
               var flv_w          = xmldoc.getElementsByTagName('width').item(0).firstChild.data;
               var flv_h          = xmldoc.getElementsByTagName('height').item(0).firstChild.data;
               var flv_auto       = xmldoc.getElementsByTagName('autostart').item(0).firstChild.data;
               var flv_repeat     = xmldoc.getElementsByTagName('repeat').item(0).firstChild.data;
               var flv_controlbar = xmldoc.getElementsByTagName('controlbar').item(0).firstChild.data;
               var flv_stretching = xmldoc.getElementsByTagName('stretching').item(0).firstChild.data;
               
               document.getElementById('popup_content').innerHTML = flv_html;
	   	      
               var flashvars = {};
                  flashvars.backcolor = "0x000000";
                  flashvars.frontcolor = "0xDEE1DF";
                  flashvars.lightcolor = "0xC7CCC9";
                  flashvars.midroll = "0";
                  flashvars.overstretch = "true";
                  flashvars.smoothing = "true";
                  if (flv_auto) flashvars.autostart = flv_auto;
                  flashvars.volume = "100";
                  if (flv_stretching) flashvars.stretching = flv_stretching;
                  flashvars.width = flv_w;
                  flashvars.height = flv_h;
                  if (flv_controlbar) flashvars.controlbar = flv_controlbar;
                  if (flv_repeat) flashvars.repeat = flv_repeat;
                  if (flv_img) flashvars.image = flv_img;
                  flashvars.file = flv_file;
                  //flashvars.skin = "incl/Kleur.swf"
               var params = {};
                  params.scale = "noscale";
                  params.salign = "TL";
                  params.quality = "high";
                  params.menu = "false";
                  params.wmode = "transparent";
                  params.allowfullscreen = "true";
                  params.allowscriptaccess = "always";
               var attributes = {};
               swfobject.embedSWF("incl/"+flv_player,flv_win,flv_w,flv_h, "8.0.0","incl/expressInstall.swf", flashvars, params, attributes);

            } else if (r_typ == 'wcam' || r_typ == 'wcamv') { // Webcam
               var wcam_file      = xmldoc.getElementsByTagName('file').item(0).firstChild.data;
               var wcam_src       = xmldoc.getElementsByTagName('src').item(0).firstChild.data;
               var wcam_timestamp = xmldoc.getElementsByTagName('timestamp').item(0).firstChild.data;
               var wcam_lg       = xmldoc.getElementsByTagName('lg').item(0).firstChild.data;
               var wcam_pf       = xmldoc.getElementsByTagName('pfad').item(0).firstChild.data;
               var wcam_intv     = xmldoc.getElementsByTagName('intv').item(0).firstChild.data;

               var wcam_id        = xmldoc.getElementsByTagName('id').item(0).firstChild.data;
               if (r_typ == 'wcamv') {
                  document.getElementById('wcam_'+wcam_id).src = wcam_src+wcam_file;
                  if (document.getElementById('wcam_timestamp_'+wcam_id)) document.getElementById('wcam_timestamp_'+wcam_id).innerHTML = wcam_timestamp;
               } else {
                  var wcam_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
                  document.getElementById('popup_content').innerHTML = wcam_html;
               }
               webcamCounter(wcam_id,wcam_lg,wcam_pf,wcam_intv,1)
            }
         }
      } else {
         //makeRequest(typ,lg,pf,id,InhId);
         location.reload();
         //alert('Bei dem Request ist ein Problem aufgetreten.');
      }
   }
}

function hover_li(sel,w,h) {
   if (h == 'H') classZusatz = ' li_sitenav_h'; else classZusatz = '';
   if (w == true) {
      sel.parentNode.parentNode.className = 'li_sitenav2' + classZusatz;
   } else {
      sel.parentNode.parentNode.className = 'li_sitenav' + classZusatz;
   }
}

function addbookmark() {   // IE
   if (document.all && navigator.userAgent.indexOf('Opera') <= -1) {
      var bookmarkurl   = document.URL
      var bookmarktitle = document.title;
      window.external.AddFavorite(bookmarkurl,bookmarktitle)
   } else {
      alert("Dieser Link funktioniert nur bei Benutzern des Internet-Explorers.\n\nBenutzen Sie bitte die Tastenkombination fÃ¼r\nNetscape/Mozilla:\t\tSTRG+D,\nOpera:\t\t\tSTRG+T.")
   }
}

function newhomepage(site) {   // IE
   if (document.all && navigator.userAgent.indexOf('Opera') <= -1) {
      site.style.behavior='url(#default#homepage)';
      site.setHomePage(location.href);
   } else {
      alert("Dieser Link funktioniert nur bei Benutzern des Internet-Explorers.\n\nBenutzen Sie bitte die Tastenkombination fÃ¼r\nNetscape/Mozilla:\t\tSTRG+D,\nOpera:\t\t\tSTRG+T.")
   }
}


function open_extern(url,att,w,h) {
   posh = parseFloat(((screen.availHeight-h)/2)-20);
   posw = parseFloat((screen.availWidth-w)/2);
   opt = att + ',left=' + posw + ',top=' + posh + ',width='+w+',height='+h;
   extWindow = window.open(url,'_blank',opt);
   extWindow.focus();
}


function frml_checked(box) {
   if (box[0].checked == true) {
      for(i=1;i<box.length; i++) box[i].checked = true;
   }
}


function change_galpic(gal,zhr) {
	galobject           = ie ? document.all('galZoomArea_'+gal) : document.getElementById('galZoomArea_'+gal);
   galobject.innerHTML = window['galeriesrc_'+gal][zhr];
   
   galtxtobj_content   = ie ? document.all('galtxt_'+gal+'_'+zhr) : document.getElementById('galtxt_'+gal+'_'+zhr);
   galtxtobj           = ie ? document.all('galTxtArea_'+gal)   : document.getElementById('galTxtArea_'+gal);
   galtxtobj.innerHTML = galtxtobj_content.innerHTML;

}

function setgalerie(id) {
   var config = {
      "id" : id,  
      "speed" : 4,  
		"galobject" : 'jsgal_zoom'+id,  
		"galnavobj" : 'gal_vcont'+id,
		"galtxtobj" : 'jsgal_zoom_titel'+id,  
		"crossobj"  : 'gal_content'+id
   };
   function ini(){
      galerie = new gal(config);
      return false;
   }
   setTimeout(ini,20);
}
function gal(config) {
   var ie  = document.all;  
	var dom = document.getElementById;
	this.config        = config;  
	this._id           = config['id'];  
	this._galobject    = ie ? document.all(config['galobject']) : document.getElementById(config['galobject']);  
	this._galnavobj    = ie ? document.all(config['galnavobj']) : document.getElementById(config['galnavobj']);  
	this._galtxtobj    = ie ? document.all(config['galtxtobj']) : document.getElementById(config['galtxtobj']);  
	this._crossobj     = ie ? document.all(config['crossobj'])  : document.getElementById(config['crossobj']);  
   this._contentwidth = this._crossobj.offsetWidth;
   this._speed        = config['speed'];
   var galerie        = this;

   this.getcontent_width();
}

gal.prototype.change_galpic = function (idNr) {
   this._galobject.innerHTML = window.galeriesrc[this._id+'_'+idNr];
   var galtxtsrc    = ie ? document.all('jsgal_imgtxt_'+this._id+'_'+idNr)     : document.getElementById('jsgal_imgtxt_'+this._id+'_'+idNr);
   this._galtxtobj.innerHTML = galtxtsrc.innerHTML;

}

gal.prototype.moveleft = function (newId) {
   if (newId == true && galerie._id != newId) {
      setgalerie(newId);
      setTimeout("galerie.moveleft(newId)",30);
   } else {
      if (window.moverightvar) clearTimeout(moverightvar);
      if (parseInt(this._crossobj.style.left)<=-1) this._crossobj.style.left = parseInt(this._crossobj.style.left)+this._speed+"px";
      this.moveleftvar = setTimeout("galerie.moveleft()",20);
   }
}

gal.prototype.moveright = function (newId) {
   if (newId == true && galerie._id != newId) {
      setgalerie(newId);
      setTimeout("galerie.moveright(newId)",30);
   } else {
      if (gal.moveleftvar) clearTimeout(gal.moveleftvar);
      if (parseInt(this._crossobj.style.left)>=(this._contentwidth*(-1)+(this._galnavobj.offsetWidth)+1)) this._crossobj.style.left = parseInt(this._crossobj.style.left) - this._speed  + "px";
      this._crossobj.left -= this._speed;
      this.moverightvar = setTimeout("galerie.moveright()",20);
   }
}

gal.prototype.stopscroll = function (){
   if (galerie.moveleftvar)  clearTimeout(galerie.moveleftvar);
   if (galerie.moverightvar) clearTimeout(galerie.moverightvar);
}
gal.prototype.getcontent_width = function (){
   this._contentwidth = this._crossobj.offsetWidth;
}

/*
function openKeyBoard(frml,lg) {
   document.getElementById('bluepage_vkeyboard').innerHTML = '<iframe src="incl/vkeyboard.php?frml='+frml+'&lg='+lg+'" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="100%" height="100%" style="border:thin outset"></iframe>'
   document.getElementById('bluepage_vkeyboard').style.display = 'block';
   
}
*/
function changeAlphabet(templ,whl) {
   if (document.all) {
      document.all('dbase_'+templ+'_alphabet_1').style.display = 'none';
      document.all('dbase_'+templ+'_alphabet_2').style.display = 'none';
      document.all('dbase_'+templ+'_alphabet_'+whl).style.display = 'block';
   } else if (document.getElementById) {
      document.getElementById('dbase_'+templ+'_alphabet_1').style.display = 'none';
      document.getElementById('dbase_'+templ+'_alphabet_2').style.display = 'none';
      document.getElementById('dbase_'+templ+'_alphabet_'+whl).style.display = 'block';
   }
}
function viewSelLetter(templ,letter) {
   document.forms['dbselform_'+templ].dbsearchreq.value = letter;
   document.forms['dbselform_'+templ].dbsearch.value = '';
   document.forms['dbselform_'+templ].submit();
}



function getElementsByClassName(class_name){
   var all_obj,ret_obj=new Array(),j=0,teststr;
   if(document.all)all_obj=document.all;
   else if(document.getElementsByTagName && !document.all)all_obj=document.getElementsByTagName("*");
   for(i=0;i<all_obj.length;i++) {
      if(all_obj[i].className.indexOf(class_name)!=-1) {
         teststr=","+all_obj[i].className.split(" ").join(",")+",";
         if(teststr.indexOf(","+class_name+",")!=-1)  {
            ret_obj[j]=all_obj[i];
            j++;
         }
      }
   }
   return ret_obj;
}



function ReplaceClass(search,replace){
   var obj=getElementsByClassName(search);
   for(i=0;i<obj.length;i++){
      obj[i].className=replace;
   }
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
} 

function setLG(lang,other_lg,frml_id,zugang){        
   var pflicht = new Array(); 
   var button  = new Array(); 
   var land = new Array(); 
   var selboxen = new Array(); 
   var version = new Array(); 
   
   if(zugang != 'intern'){
      document.getElementById('frml_'+frml_id).frml_mail_lg.value = lang; // sprache der mail bestimmen...                 
   }
   
   pflicht['de'] = '(* Pflichtangabe)';
   pflicht['en'] = '(* mandatory data)',
   pflicht['ns'] = '(* obligatoriske pódaśe)',      
   pflicht['os'] = '(* obligatoriske podaće)',      
   pflicht['ru'] = '(* обязательны для заполнения)';
                                                   
   button['de'] = 'SENDEN',
   button['en'] = 'SUBMIT',
   button['ns'] = 'wótpósłaś',      
   button['os'] = 'wotpósłać',      
   button['ru'] = 'Отправить';
   
   land['de'] = 'Bitte Land auswählen....',
   land['en'] = 'Please select your country...',
   land['ns'] = 'pšosym kraj wuzwóliś...',      
   land['os'] = 'prošu kraj wuzwolić...',      
   land['ru'] = 'Выберете страну...';

   version['de'] = 'Sprachversion';
   version['en'] = 'version';
   version['ns'] = 'rěcna wersija';
   version['os'] = 'rěčna wersija';
   version['ru'] = 'язык';


   var all_lang =  other_lg.split('|');
   var lg_anz = all_lang.length-1;   
   
   for(var i=0;i<lg_anz;i++){
      if(all_lang[i]==lang){
         var lg_idx = i;
      }
   }
   
   
   var selboxen = document.getElementById('frml_'+frml_id).getElementsByTagName('select');
   for(var i=0; i<selboxen.length; i++){
      var box_id = selboxen[i].id;
      if(document.getElementById(box_id).options[0].text == land['de'] || document.getElementById(box_id).options[0].text == land['en'] || document.getElementById(box_id).options[0].text == land['ns'] || document.getElementById(box_id).options[0].text == land['os'] || document.getElementById(box_id).options[0].text == land['ru'] ) {
         document.getElementById(box_id).options[0].text = land[lang]; 
      }else{
         var current_value = document.getElementById(box_id).options[document.getElementById(box_id).selectedIndex].value;
         var opt_name = document.getElementById(box_id).name
         opt_name = opt_name.split('[');
         var optf = str_replace(']','',opt_name[1]); 
         var optlg_id = 'opt'+frml_id+'_'+current_value+'_'+optf+'_'+lang; 
         var opt_text = document.getElementById(optlg_id).innerHTML;
   
         document.getElementById(box_id).options[document.getElementById(box_id).selectedIndex].text = opt_text;
         //alert(document.getElementById(optlg_id).innerHTML);
         
         for(var j=0; j<document.getElementById(box_id).options.length;j++){
            var opt_value = document.getElementById(box_id).options[j].value; 
            var optlg_id = 'opt'+frml_id+'_'+opt_value+'_'+optf+'_'+lang; 
            var opt_text = document.getElementById(optlg_id).innerHTML;
                     
            document.getElementById(box_id).options[j].text = opt_text;
         
         }
      }
   }

   for(var i = 0; i<lg_anz; i++) {
      ReplaceClass('frml_label_'+all_lang[i],'frml_no_label_'+all_lang[i]) ;
      //document.getElementById('frml_'+all_lang[i]).style.backgroundPosition = 'right -35px ';    //navpic
      document.getElementById('frml_'+frml_id+'_'+all_lang[i]).className = 'frml_lg';
      document.getElementById('frml_'+frml_id+'_'+all_lang[i]).style.backgroundImage = 'url("images/lg_'+all_lang[i]+'.png")';     
   }
   
   ReplaceClass('frml_no_label_'+lang,'frml_label_'+lang);  // Tausch in Sichtbar 
   document.getElementById('frml_'+frml_id+'_'+lang).className = 'frml_lg2'; 
   
   //document.getElementById('frml_'+lang).style.backgroundPosition = 'right 0';  //navpic 
   document.getElementById(frml_id+'_pflicht').innerHTML = pflicht[lang];
   document.getElementById(frml_id+'_button').value = button[lang]; 
   document.getElementById('frml_'+frml_id+'_'+lang).style.backgroundImage = 'url("images/lg_'+lang+'.png")'; 
   document.getElementById('lng_version_'+frml_id).innerHTML = version[lang];
}